Exemple #1
0
        public async Task UnboundCertificateCommitAndRefreshWorks()
        {
            using (BatchClient batchClient = ClientUnitTestCommon.CreateDummyClient())
            {
                string pfxFilePath = TestCommon.GetTemporaryCertificateFilePath("unboundcertificateunittest.pfx");
                try
                {
                    CertificateBuilder.CreateSelfSignedInFile("test", pfxFilePath, CommonResources.CertificatePassword);

                    const string expectedThumbprint = "ABC";
                    var          protoCertificate   = new Protocol.Models.Certificate(thumbprint: expectedThumbprint);
                    Certificate  certificate        = batchClient.CertificateOperations.CreateCertificate(
                        pfxFilePath,
                        CommonResources.CertificatePassword);

                    Assert.NotNull(certificate.ThumbprintAlgorithm);

                    await certificate.CommitAsync(additionalBehaviors : InterceptorFactory.CreateAddCertificateRequestInterceptor());

                    await certificate.RefreshAsync(additionalBehaviors : InterceptorFactory.CreateGetCertificateRequestInterceptor(protoCertificate));

                    Assert.Equal(expectedThumbprint, certificate.Thumbprint);
                    Assert.Null(certificate.ThumbprintAlgorithm);
                }
                finally
                {
                    File.Delete(pfxFilePath);
                }
            }
        }
        public void TestRandomBoundCertificateProperties()
        {
            using BatchClient client = ClientUnitTestCommon.CreateDummyClient();
            for (int i = 0; i < TestRunCount; i++)
            {
                Protocol.Models.Certificate certificateModel =
                    this.customizedObjectFactory.GenerateNew <Protocol.Models.Certificate>();

                Certificate boundCertificate = new Certificate(client, certificateModel, client.CustomBehaviors);

                ObjectComparer.CheckEqualityResult result = this.objectComparer.CheckEquality(boundCertificate, certificateModel);
                Assert.True(result.Equal, result.Message);
            }
        }
Exemple #3
0
        public async Task UnboundCertificateCommitAndRefreshWorks()
        {
            using BatchClient batchClient = ClientUnitTestCommon.CreateDummyClient();
            const string expectedThumbprint = "ABC";
            var          protoCertificate   = new Protocol.Models.Certificate(thumbprint: expectedThumbprint);
            Certificate  certificate        = new Certificate(
                batchClient,
                null,
                string.Empty,
                expectedThumbprint,
                "SHA1");

            Assert.NotNull(certificate.ThumbprintAlgorithm);

            await certificate.CommitAsync(additionalBehaviors : InterceptorFactory.CreateAddCertificateRequestInterceptor());

            await certificate.RefreshAsync(additionalBehaviors : InterceptorFactory.CreateGetCertificateRequestInterceptor(protoCertificate));

            Assert.Equal(expectedThumbprint, certificate.Thumbprint);
            Assert.Null(certificate.ThumbprintAlgorithm);
        }
Exemple #4
0
 public static IEnumerable <Protocol.RequestInterceptor> CreateGetCertificateRequestInterceptor(Protocol.Models.Certificate certificateToReturn)
 {
     return(CreateGetRequestInterceptor <Protocol.Models.CertificateGetOptions, Protocol.Models.Certificate, Protocol.Models.CertificateGetHeaders>(certificateToReturn));
 }