public void TestSetupCertificateValidation_Amqp_ShouldSucceed() { ITransportSettings[] transportSettings = new ITransportSettings[] { new AmqpTransportSettings(TransportType.Amqp_Tcp_Only) }; var certs = TrustBundleProvider.ParseCertificates(certificatesString); var customCertificateValidator = CustomCertificateValidator.Create(certs, transportSettings); Assert.IsNotNull(((AmqpTransportSettings)transportSettings[0]).RemoteCertificateValidationCallback); }
public void TestSetupCertificateValidation_Amqp_CallbackAlreadySet_ShouldSucceed() { var certs = TrustBundleProvider.ParseCertificates(certificatesString); var setting = new AmqpTransportSettings(TransportType.Amqp_Tcp_Only); RemoteCertificateValidationCallback callback = (sender, certificate, chain, sslPolicyErrors) => { return(true); }; setting.RemoteCertificateValidationCallback = callback; ITransportSettings[] transportSettings = new ITransportSettings[] { setting }; var customCertificateValidator = CustomCertificateValidator.Create(certs, transportSettings); Assert.IsNotNull(((AmqpTransportSettings)transportSettings[0]).RemoteCertificateValidationCallback); }
public void TestSetupCertificateValidation_Mqtt_CallbackAlreadySet_ShouldSucceed() { var trustBundleProvider = new TrustBundleProvider(); var certs = trustBundleProvider.ParseCertificates(certificatesString); var setting = new MqttTransportSettings(TransportType.Mqtt_Tcp_Only); RemoteCertificateValidationCallback callback = (sender, certificate, chain, sslPolicyErrors) => { return(true); }; setting.RemoteCertificateValidationCallback = callback; ITransportSettings[] transportSettings = new ITransportSettings[] { setting }; var customCertificateValidator = CustomCertificateValidator.Create(certs, transportSettings); Assert.AreEqual(setting.RemoteCertificateValidationCallback, callback); }
public void TestParseCertificates_EmptyCertificates_ShouldThrow() { TestAssert.Throws <InvalidOperationException>(() => TrustBundleProvider.ParseCertificates(string.Empty)); }
public void TestParseCertificates_NullCertificates_ShouldThrow() { TestAssert.Throws <InvalidOperationException>(() => TrustBundleProvider.ParseCertificates(null)); }
public void TestParseCertificates_InvalidCertificates_ShouldThrow() { TestAssert.Throws <CryptographicException>(() => TrustBundleProvider.ParseCertificates(certificateStringInvalid)); }
public void TestParseCertificates_NoCertificatesEntries_ShouldReturnNoCetificates() { var certs = TrustBundleProvider.ParseCertificates("test"); Assert.AreEqual(certs.Count(), 0); }
public void TestParseCertificates_WithNonCertificatesEntries_ShouldReturnCetificates() { var certs = TrustBundleProvider.ParseCertificates(certificatesString + certificatesString + "test"); Assert.AreEqual(certs.Count(), 2); }
public void TestParseCertificates_MultipleCerts_ShouldReturnCetificates() { var certs = TrustBundleProvider.ParseCertificates(certificatesString + certificatesString); Assert.AreEqual(certs.Count(), 2); }