Example #1
0
        public void SignedDataAsSecret_Works()
        {
            var signedData = new SignedCms();

            signedData.Decode(File.ReadAllBytes("DeveloperProfiles/test.mobileprovision"));

            var secret = signedData.AsSecret();

            Assert.Equal("v1", secret.ApiVersion);
            Assert.Equal("Secret", secret.Kind);
            Assert.Equal("kaponata.io/signedData", secret.Type);
            Assert.NotNull(secret.Metadata);
            Assert.NotNull(secret.Metadata.Labels);
            Assert.Empty(secret.Metadata.Labels);
            Assert.Equal(File.ReadAllBytes("DeveloperProfiles/test.mobileprovision"), secret.Data["signedData"]);
        }
Example #2
0
        /// <summary>
        /// Asynchronously adds a provisioning profile to the cluster.
        /// </summary>
        /// <param name="profile">
        /// A <see cref="SignedCms"/> object which represents the provisioning profile to add.
        /// </param>
        /// <param name="cancellationToken">
        /// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
        /// </param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public virtual async Task <ProvisioningProfile> AddProvisioningProfileAsync(SignedCms profile, CancellationToken cancellationToken)
        {
            if (profile == null)
            {
                throw new ArgumentNullException(nameof(profile));
            }

            var secret        = profile.AsSecret();
            var signedProfile = ProvisioningProfile.Read(profile);

            secret.Metadata.Name = signedProfile.Uuid.ToString();
            secret.Metadata.Labels[Annotations.DeveloperProfileComponent] = Annotations.ProvisioningProfile;

            await this.secretClient.CreateAsync(secret, cancellationToken).ConfigureAwait(false);

            return(signedProfile);
        }