public void AcceptAll_Should_ThrowException_When_AlreadyEnabled() { // Arrange SslAcceptPolicy.Reset(); SslAcceptPolicy.AcceptAll(); // Act & Assert Assert.Throws <InvalidOperationException>(() => SslAcceptPolicy.AcceptAll()); }
public void AcceptAll_Should_EnablePolicy() { // Arrange SslAcceptPolicy.Reset(); // Act SslAcceptPolicy.AcceptAll(); // Assert Assert.True(SslAcceptPolicy.Enabled); }
public void Reset_Should_DisablePolicyAfterBeingEnabled() { // Arrange SslAcceptPolicy.Reset(); SslAcceptPolicy.AcceptAll(); // Act SslAcceptPolicy.Reset(); // Assert Assert.False(SslAcceptPolicy.Enabled); }
public void OriginalPolicy_Should_ContainOriginalPolicy_When_AcceptAllIsEnabled() { // Arrange SslAcceptPolicy.Reset(); var expected = ServicePointManager.ServerCertificateValidationCallback; // Act SslAcceptPolicy.AcceptAll(); // Assert Assert.Equal(expected, SslAcceptPolicy.OriginalPolicy); }
public void AcceptAll_Should_EnableAllCertificatedToBeAccepted() { // Arrange SslAcceptPolicy.Reset(); var expected = typeof(SslAcceptPolicy.AcceptCertificatePolicy).Name; // Act SslAcceptPolicy.AcceptAll(); var actual = ServicePointManager.ServerCertificateValidationCallback.Method.DeclaringType.Name; // Assert Assert.Equal(expected, actual); }
public void Reset_Should_PutOriginalPolicy_When_OneExisted() { // Arrange SslAcceptPolicy.Reset(); ServicePointManager.ServerCertificateValidationCallback = AnotherCertificatePolicy.Validate; var expected = typeof(AnotherCertificatePolicy).Name; // Act SslAcceptPolicy.AcceptAll(); SslAcceptPolicy.Reset(); var actual = ServicePointManager.ServerCertificateValidationCallback.Method.DeclaringType.Name; // Assert Assert.Equal(expected, actual); }
public void AcceptAll_Should_AllowSelfSignedCertificate() { // Arrange SslAcceptPolicy.Reset(); var cert = LoadCertificate(); var chain = new X509Chain(); SslAcceptPolicy.AcceptAll(); // Act var actual = ServicePointManager.ServerCertificateValidationCallback.Invoke( this, cert, chain, SslPolicyErrors.None); // Assert Assert.True(actual); }