internal void VerifyOutgoingMessage(CDO.Message message) { Assert.True(string.IsNullOrEmpty(message.Subject)); ContentType contentType = new ContentType(message.GetContentType()); Assert.True(SMIMEStandard.IsContentEncrypted(contentType)); }
internal void VerifyIncomingMessage(CDO.Message message) { ContentType contentType = new ContentType(message.GetContentType()); Assert.False(SMIMEStandard.IsContentEncrypted(contentType)); }
public void TestFailedDSN_SecurityAndTrustOutGoingOnly_AlwaysGenerate_AllRecipientsRejected( string untrustedRecipientMessage , List <DSNPerRecipient> perRecipientExpected) { CleanMessages(m_agent.Settings); CleanMonitor(); m_agent.Settings.InternalMessage.EnableRelay = true; m_agent.Settings.Notifications.AutoResponse = false; //don't care. This is MDN specific m_agent.Settings.Notifications.AlwaysAck = false; //don't care. This is MDN specific m_agent.Settings.Notifications.AutoDsnFailureCreation = NotificationSettings.AutoDsnOption.Always.ToString(); MdnMemoryStore.Clear(); Mock <ClientSettings> mockClientSettings = MockMdnClientSettings(); m_agent.Settings.MdnMonitor = mockClientSettings.Object; // // Process loopback messages. Leaves un-encrypted mdns in pickup folder // Go ahead and pick them up and Process them as if they where being handled // by the SmtpAgent by way of (IIS)SMTP hand off. // var sendingMessage = LoadMessage(untrustedRecipientMessage); Assert.Equal( string.Format("Error={0}", AgentError.NoTrustedRecipients), Assert.Throws <OutgoingAgentException>(() => m_agent.ProcessMessage(sendingMessage)).Message ); //No trusted recipients so not encrypted. ContentType contentType = new ContentType(sendingMessage.GetContentType()); Assert.False(SMIMEStandard.IsContentEncrypted(contentType)); // // grab the clear text dsn and delete others. // Process them as outgoing messages // bool foundDsn = false; foreach (var pickupMessage in PickupMessages()) { string messageText = File.ReadAllText(pickupMessage); if (messageText.Contains("message/delivery-status")) { foundDsn = true; Assert.DoesNotThrow(() => RunMdnOutBoundProcessingTest(LoadMessage(messageText))); // // assert not in the monitor store. // DSN messages are not monitored. // var queryMdn = BuildQueryFromDSN(LoadMessage(messageText)); var mdn = MdnMemoryStore.FirstOrDefault(m => m.MdnIdentifier == queryMdn.MdnIdentifier); Assert.Null(mdn); } } Assert.True(foundDsn); // // Now the messages are encrypted and can be handled as inbound messages. // foundDsn = false; foreach (var pickupMessage in PickupMessages()) { foundDsn = true; string messageText = File.ReadAllText(pickupMessage); CDO.Message message = LoadMessage(messageText); Assert.DoesNotThrow(() => RunMdnInBoundProcessingTest(message)); var dsnMessage = new CDOSmtpMessage(message).GetEnvelope(); Assert.True(dsnMessage.Message.IsDSN()); Assert.False(dsnMessage.Message.IsMDN()); var dsn = DSNParser.Parse(dsnMessage.Message); foreach (var perRecipient in dsn.PerRecipient) { Assert.Equal(perRecipientExpected.Count, dsn.PerRecipient.Count()); string finalRecipient = perRecipient.FinalRecipient.Address; var expectedPerRecipient = perRecipientExpected.Find(d => d.FinalRecipient.Address == finalRecipient); Assert.Equal(expectedPerRecipient.Action, perRecipient.Action); Assert.Equal(expectedPerRecipient.Status, perRecipient.Status); } } Assert.True(foundDsn); //Ensure no MDNs where created by the DSN. Assert.True(!PickupMessages().Any()); m_agent.Settings.InternalMessage.EnableRelay = false; }