Example #1
0
        public void TestIsCertPolicyCompiant_NoResolver_NoFilter_AssertTrue()
        {
            TrustModel trustModel            = new TrustModel(mockTrustChainValidator.Object);
            Mock <X509Certificate2> mockCert = new Mock <X509Certificate2>();

            trustModel.IsCertPolicyCompliant(new MailAddress("*****@*****.**"), mockCert.Object).Should().BeTrue();
        }
Example #2
0
        public void TestIsCertPolicyCompiant_NoPolicyExpression_AssertTrue()
        {
            TrustModel trustModel            = new TrustModel(mockTrustChainValidator.Object, mockPolicyResolver.Object, mockPolicyFilter.Object);
            Mock <X509Certificate2> mockCert = new Mock <X509Certificate2>();

            mockPolicyResolver.Setup(resolver => resolver.GetIncomingPolicy(new MailAddress("*****@*****.**")))
            .Returns(new List <IPolicyExpression>());

            trustModel.IsCertPolicyCompliant(new MailAddress("*****@*****.**"), mockCert.Object).Should().BeTrue();
        }
        public void TestIsCertPolicyCompiant_NoPolicyExpression_AssertTrue()
        {
            TrustModel trustModel = new TrustModel(mockTrustChainValidator.Object, mockPolicyResolver.Object, mockPolicyFilter.Object);
            Mock<X509Certificate2> mockCert = new Mock<X509Certificate2>();

            mockPolicyResolver.Setup(resolver => resolver.GetIncomingPolicy(new MailAddress("*****@*****.**")))
                .Returns(new List<IPolicyExpression>());

            trustModel.IsCertPolicyCompliant(new MailAddress("*****@*****.**"), mockCert.Object).Should().BeTrue();
        }
Example #4
0
        public void TestIsCertPolicyCompiant_PolicyNotCompliant_AssertFalse()
        {
            TrustModel trustModel            = new TrustModel(mockTrustChainValidator.Object, mockPolicyResolver.Object, mockPolicyFilter.Object);
            Mock <X509Certificate2> mockCert = new Mock <X509Certificate2>();

            mockPolicyFilter.Setup(
                filter => filter.IsCompliant(It.IsAny <X509Certificate2>(), It.IsAny <IPolicyExpression>()))
            .Returns(false);

            Mock <IPolicyExpression> mockExpression = new Mock <IPolicyExpression>();

            mockPolicyResolver.Setup(
                resolver => resolver.GetIncomingPolicy(new MailAddress("*****@*****.**")))
            .Returns(new List <IPolicyExpression> {
                mockExpression.Object
            });

            trustModel.IsCertPolicyCompliant(new MailAddress("*****@*****.**"), mockCert.Object).Should().BeFalse();

            mockPolicyFilter.VerifyAll();
        }
Example #5
0
        public void TestIsCertPolicyCompiant_PolicyExpressionError_AssertException()
        {
            TrustModel trustModel            = new TrustModel(mockTrustChainValidator.Object, mockPolicyResolver.Object, mockPolicyFilter.Object);
            Mock <X509Certificate2> mockCert = new Mock <X509Certificate2>();

            mockPolicyFilter.Setup(
                filter => filter.IsCompliant(It.IsAny <X509Certificate2>(), It.IsAny <IPolicyExpression>()))
            .Throws <PolicyProcessException>();

            Mock <IPolicyExpression> mockExpression = new Mock <IPolicyExpression>();

            mockPolicyResolver.Setup(
                resolver => resolver.GetIncomingPolicy(new MailAddress("*****@*****.**")))
            .Returns(new List <IPolicyExpression> {
                mockExpression.Object
            });

            Action action = () => trustModel.IsCertPolicyCompliant(new MailAddress("*****@*****.**"), mockCert.Object);

            action.ShouldThrow <AgentException>().WithInnerException <PolicyProcessException>();


            mockPolicyFilter.VerifyAll();
        }
        public void TestIsCertPolicyCompiant_PolicyNotCompliant_AssertFalse()
        {
            TrustModel trustModel = new TrustModel(mockTrustChainValidator.Object, mockPolicyResolver.Object, mockPolicyFilter.Object);
            Mock<X509Certificate2> mockCert = new Mock<X509Certificate2>();

            mockPolicyFilter.Setup(
                filter => filter.IsCompliant(It.IsAny<X509Certificate2>(), It.IsAny<IPolicyExpression>()))
                .Returns(false);

            Mock<IPolicyExpression> mockExpression = new Mock<IPolicyExpression>();

            mockPolicyResolver.Setup(
                resolver => resolver.GetIncomingPolicy(new MailAddress("*****@*****.**")))
                .Returns(new List<IPolicyExpression> { mockExpression.Object });

            trustModel.IsCertPolicyCompliant(new MailAddress("*****@*****.**"), mockCert.Object).Should().BeFalse();

            mockPolicyFilter.VerifyAll();
        }
 public void TestIsCertPolicyCompiant_NoResolver_NoFilter_AssertTrue()
 {
     TrustModel trustModel = new TrustModel(mockTrustChainValidator.Object);
     Mock<X509Certificate2> mockCert = new Mock<X509Certificate2>();
     trustModel.IsCertPolicyCompliant(new MailAddress("*****@*****.**"), mockCert.Object).Should().BeTrue();
 }
        public void TestIsCertPolicyCompiant_PolicyExpressionError_AssertException()
        {
            TrustModel trustModel = new TrustModel(mockTrustChainValidator.Object, mockPolicyResolver.Object, mockPolicyFilter.Object);
            Mock<X509Certificate2> mockCert = new Mock<X509Certificate2>();

            mockPolicyFilter.Setup(
                filter => filter.IsCompliant(It.IsAny<X509Certificate2>(), It.IsAny<IPolicyExpression>()))
                .Throws<PolicyProcessException>();

            Mock<IPolicyExpression> mockExpression = new Mock<IPolicyExpression>();

            mockPolicyResolver.Setup(
                resolver => resolver.GetIncomingPolicy(new MailAddress("*****@*****.**")))
                .Returns(new List<IPolicyExpression> { mockExpression.Object });

            Action action = () => trustModel.IsCertPolicyCompliant(new MailAddress("*****@*****.**"), mockCert.Object);
            action.ShouldThrow<AgentException>().WithInnerException<PolicyProcessException>();


            mockPolicyFilter.VerifyAll();
        }