public void TestManInMiddle(string fileName, string injectedWithPersonalKey, string injectedWithOrgKey) { // // Take an encrypted message, add additional recipients // OutgoingMessage outgoing = m_tester.ProcessOutgoingFile(fileName); string message = outgoing.SerializeMessage(); IncomingMessage incoming = new IncomingMessage(message, outgoing.Recipients, outgoing.Sender); Assert.DoesNotThrow(() => m_tester.AgentB.ProcessIncoming(incoming)); // // Add additional recipient not in original message // DirectAddressCollection recipients = new DirectAddressCollection(outgoing.Recipients); recipients.Add(new DirectAddress(injectedWithPersonalKey)); incoming = new IncomingMessage(message, recipients, outgoing.Sender); Assert.Throws <AgentException>(() => m_tester.AgentB.ProcessIncoming(incoming)); // // Replace recipient entirely // recipients.Clear(); recipients.Add(new DirectAddress(injectedWithPersonalKey)); incoming = new IncomingMessage(message, recipients, outgoing.Sender); Assert.Throws <AgentException>(() => m_tester.AgentB.ProcessIncoming(incoming)); // // Inject recipient with org certs // recipients.Clear(); recipients.Add(outgoing.Recipients); recipients.Add(new DirectAddress(injectedWithOrgKey)); incoming = new IncomingMessage(message, recipients, outgoing.Sender); Assert.Throws <AgentException>(() => m_tester.AgentB.ProcessIncoming(incoming)); }
public void TestManInMiddle(string fileName, string injectedWithPersonalKey, string injectedWithOrgKey) { // // Take an encrypted message, add additional recipients // OutgoingMessage outgoing = m_tester.ProcessOutgoingFile(fileName); string message = outgoing.SerializeMessage(); IncomingMessage incoming = new IncomingMessage(message, outgoing.Recipients, outgoing.Sender); Assert.DoesNotThrow(() => m_tester.AgentB.ProcessIncoming(incoming)); // // Add additional recipient not in original message // DirectAddressCollection recipients = new DirectAddressCollection(outgoing.Recipients); recipients.Add(new DirectAddress(injectedWithPersonalKey)); incoming = new IncomingMessage(message, recipients, outgoing.Sender); Assert.Throws<AgentException>(() => m_tester.AgentB.ProcessIncoming(incoming)); // // Replace recipient entirely // recipients.Clear(); recipients.Add(new DirectAddress(injectedWithPersonalKey)); incoming = new IncomingMessage(message, recipients, outgoing.Sender); Assert.Throws<AgentException>(() => m_tester.AgentB.ProcessIncoming(incoming)); // // Inject recipient with org certs // recipients.Clear(); recipients.Add(outgoing.Recipients); recipients.Add(new DirectAddress(injectedWithOrgKey)); incoming = new IncomingMessage(message, recipients, outgoing.Sender); Assert.Throws<AgentException>(() => m_tester.AgentB.ProcessIncoming(incoming)); }