Beispiel #1
0
        public void TestPrivateKeyLookupFailure()
        {
            string fileName    = "simple.eml";
            string messageText = m_tester.ReadMessageText(fileName);

            Message message = MailParser.ParseMessage(messageText);

            message.ToValue = "*****@*****.**";  // this should force a key lookup failure
            AgentTester.CheckErrorCode <AgentException, AgentError>(
                () => m_tester.AgentA.ProcessOutgoing(new OutgoingMessage(message)),
                AgentError.NoTrustedRecipients
                );

            DirectAgent badAgent = new DirectAgent(new StaticDomainResolver(m_tester.AgentA.Domains.Domains.ToArray()),
                                                   new NullResolver(), // returns null private certs
                                                   m_tester.AgentA.PublicCertResolver,
                                                   m_tester.AgentA.TrustAnchors);

            message = MailParser.ParseMessage(messageText);
            AgentTester.CheckErrorCode <AgentException, AgentError>(
                () => badAgent.ProcessOutgoing(new OutgoingMessage(message)),
                AgentError.CouldNotResolvePrivateKey
                );

            OutgoingMessage outgoing = m_tester.AgentA.ProcessOutgoing(messageText);

            badAgent = new DirectAgent(new StaticDomainResolver(m_tester.AgentB.Domains.Domains.ToArray()),
                                       new NullResolver(),            // returns null private certs
                                       m_tester.AgentB.PublicCertResolver,
                                       m_tester.AgentB.TrustAnchors);

            AgentTester.CheckErrorCode <AgentException, AgentError>(
                () => badAgent.ProcessIncoming(outgoing.SerializeMessage()),
                AgentError.CouldNotResolvePrivateKey
                );

            badAgent = new DirectAgent(new StaticDomainResolver(m_tester.AgentB.Domains.Domains.ToArray()),
                                       new NullResolver(true),            // returns empty private cert collections
                                       m_tester.AgentB.PublicCertResolver,
                                       m_tester.AgentB.TrustAnchors);

            AgentTester.CheckErrorCode <AgentException, AgentError>(
                () => badAgent.ProcessIncoming(outgoing.SerializeMessage()),
                AgentError.CouldNotResolvePrivateKey
                );
        }
Beispiel #2
0
 public string ProcessIncomingToString(string messageText)
 {
     return(m_agentB.ProcessIncoming(messageText).SerializeMessage());
 }
Beispiel #3
0
        public void TestPrivateKeyLookupFailure()
        {
            string fileName = "simple.eml";            
            string messageText = m_tester.ReadMessageText(fileName);
            
            Message message = MailParser.ParseMessage(messageText);
            message.ToValue = "*****@*****.**";  // this should force a key lookup failure            
            AgentTester.CheckErrorCode<AgentException, AgentError>(
                () => m_tester.AgentA.ProcessOutgoing(new OutgoingMessage(message)),
                AgentError.NoTrustedRecipients
            );

            DirectAgent badAgent = new DirectAgent(new StaticDomainResolver(m_tester.AgentA.Domains.Domains.ToArray()),
                                                 new NullResolver(),  // returns null private certs
                                                 m_tester.AgentA.PublicCertResolver,
                                                 m_tester.AgentA.TrustAnchors);

            message = MailParser.ParseMessage(messageText);
            AgentTester.CheckErrorCode<AgentException, AgentError>(
                () => badAgent.ProcessOutgoing(new OutgoingMessage(message)),
                AgentError.CouldNotResolvePrivateKey
            );
            
            OutgoingMessage outgoing = m_tester.AgentA.ProcessOutgoing(messageText);

            badAgent = new DirectAgent(new StaticDomainResolver(m_tester.AgentB.Domains.Domains.ToArray()),
                                                 new NullResolver(),  // returns null private certs
                                                 m_tester.AgentB.PublicCertResolver,
                                                 m_tester.AgentB.TrustAnchors);

            AgentTester.CheckErrorCode<AgentException, AgentError>(
                () => badAgent.ProcessIncoming(outgoing.SerializeMessage()),
                AgentError.CouldNotResolvePrivateKey
            );

            badAgent = new DirectAgent(new StaticDomainResolver(m_tester.AgentB.Domains.Domains.ToArray()),
                                                 new NullResolver(true),  // returns empty private cert collections
                                                 m_tester.AgentB.PublicCertResolver,
                                                 m_tester.AgentB.TrustAnchors);

            AgentTester.CheckErrorCode<AgentException, AgentError>(
                () => badAgent.ProcessIncoming(outgoing.SerializeMessage()),
                AgentError.CouldNotResolvePrivateKey
            );
        }