public void CreateX509ChainFactory_Always_ReturnsInstance() { IX509ChainFactory factory = X509TrustStore.CreateX509ChainFactory(_logger); Assert.IsType <DotNetDefaultTrustStoreX509ChainFactory>(factory); Assert.Equal(1, _logger.Messages.Count); Assert.Equal(1, _logger.VerboseMessages.Count); Assert.True(_logger.VerboseMessages.TryDequeue(out string actualMessage)); Assert.Equal(Strings.ChainBuilding_UsingDefaultTrustStore, actualMessage); }
public void CreateX509ChainFactoryForDotNetSdk_OnWindowsAlways_ReturnsInstance() { IX509ChainFactory factory = X509TrustStore.CreateX509ChainFactoryForDotNetSdk( _logger, _fallbackCertificateBundle); Assert.IsType <DotNetDefaultTrustStoreX509ChainFactory>(factory); // 1 message from the API under test and 2 messages from this test class's constructor Assert.Equal(3, _logger.Messages.Count); Assert.Equal(1, _logger.VerboseMessages.Count); Assert.True(_logger.VerboseMessages.TryDequeue(out string actualMessage)); Assert.Equal(Strings.ChainBuilding_UsingDefaultTrustStore, actualMessage); }
public void CreateX509ChainFactoryForDotNetSdk_OnLinuxAlways_ReturnsInstance() { IX509ChainFactory factory = X509TrustStore.CreateX509ChainFactoryForDotNetSdk( _logger, _fallbackCertificateBundle); bool wasFound = TryReadFirstBundle( SystemCertificateBundleX509ChainFactory.ProbePaths, out X509Certificate2Collection certificates, out string _); var certificateBundleFactory = (CertificateBundleX509ChainFactory)factory; if (wasFound) { Assert.IsType <SystemCertificateBundleX509ChainFactory>(factory); Assert.Equal(certificates.Count, certificateBundleFactory.Certificates.Count); } else { Assert.IsType <FallbackCertificateBundleX509ChainFactory>(factory); Assert.True(certificateBundleFactory.Certificates.Count > 0); } // 1 message from the API under test and 2 messages from this test class's constructor Assert.Equal(3, _logger.Messages.Count); Assert.Equal(1, _logger.VerboseMessages.Count); Assert.True(_logger.VerboseMessages.TryDequeue(out string actualMessage)); string expectedMessage; if (wasFound) { expectedMessage = string.Format( CultureInfo.CurrentCulture, Strings.ChainBuilding_UsingSystemCertificateBundle, certificateBundleFactory.FilePath); } else { expectedMessage = string.Format( CultureInfo.CurrentCulture, Strings.ChainBuilding_UsingFallbackCertificateBundle, certificateBundleFactory.FilePath); } Assert.Equal(expectedMessage, actualMessage); }
public void CreateX509ChainFactoryForDotNetSdk_OnMacOsAlways_ReturnsInstance() { IX509ChainFactory factory = X509TrustStore.CreateX509ChainFactoryForDotNetSdk( _logger, _fallbackCertificateBundle); Assert.IsType <FallbackCertificateBundleX509ChainFactory>(factory); string expectedMessage = string.Format( CultureInfo.CurrentCulture, Strings.ChainBuilding_UsingFallbackCertificateBundle, ((CertificateBundleX509ChainFactory)factory).FilePath); // 1 message from the API under test and 2 messages from this test class's constructor Assert.Equal(3, _logger.Messages.Count); Assert.Equal(1, _logger.VerboseMessages.Count); Assert.True(_logger.VerboseMessages.TryDequeue(out string actualMessage)); Assert.Equal(expectedMessage, actualMessage); }
public X509ChainHolder() { IX509ChainFactory creator = X509TrustStore.GetX509ChainFactory(NullLogger.Instance); Chain = creator.Create(); }