public void DuplicateMdnTest() { MdnManager target = CreateManager(); InitMdnRecords(); string messageId = Guid.NewGuid().ToString(); Mdn mdn = BuildMdn("945cc145-431c-4119-a8c6-7f557e52fd7d", "*****@*****.**", "*****@*****.**", "To dispatch or not dispatch", "pRocessed"); //Record first processed. Assert.Null(Record.Exception(() => target.Update(new Mdn[] { mdn }))); //Throw duplicate processed Assert.Equal(ConfigStoreError.DuplicateProcessedMdn, Assert.Throws <ConfigStoreException>(() => target.Update(mdn)).Error); //Record first dispatched. mdn.Status = "disPatched"; Assert.Null(Record.Exception(() => target.Update(mdn))); //Throw duplicate dispached Assert.Equal(ConfigStoreError.DuplicateDispatchedMdn, Assert.Throws <ConfigStoreException>(() => target.Update(mdn)).Error); mdn = BuildMdn(Guid.NewGuid().ToString(), "*****@*****.**", "*****@*****.**", "To dispatch or not dispatch", "fAiled"); target.Start(new Mdn[] { mdn }); Assert.Equal(ConfigStoreError.DuplicateFailedMdn, Assert.Throws <ConfigStoreException>(() => target.Update(mdn)).Error); }
public void AddExceptionTest() { MdnManager target = CreateManager(); InitMdnRecords(); string messageId = Guid.NewGuid().ToString(); Mdn mdn = BuildMdn("945cc145-431c-4119-a8c6-7f557e52fd7d", "*****@*****.**", "*****@*****.**", "To dispatch or not dispatch", MdnStatus.Started); Assert.Contains("Cannot insert duplicate key", Assert.Throws <SqlException>(() => target.Start(new Mdn[] { mdn })).Message); }
public void Update(Mdn mdn) { try { Store.Mdns.Update(mdn); } catch (Exception ex) { throw CreateFault("Update", ex); } }
/// <summary> ///A test for expired Mdn Dispatched Timer ///</summary> //[Fact ] May want this check to go into the timeout job. public void MissingAggregateMdnTest() { MdnManager target = CreateManager(); InitMdnRecords(); string messageId = Guid.NewGuid().ToString(); Mdn mdn = BuildMdn("945cc145-431c-4119-a8c6-7f557e52fd7d", "*****@*****.**", "*****@*****.**", "To dispatch or not dispatch", "pRocessed"); Assert.Equal(ConfigStoreError.MdnUncorrelated, Assert.Throws <ConfigStoreException>(() => target.Update(new Mdn[] { mdn })).Error); }
static DSNMessage CreateNotificationMessage(Mdn mdn, TimeoutSettings settings) { var perMessage = new DSNPerMessage(settings.ProductName, mdn.MessageId); var perRecipient = new DSNPerRecipient(DSNStandard.DSNAction.Failed, DSNStandard.DSNStatus.Permanent , DSNStandard.DSNStatus.NETWORK_EXPIRED_PROCESSED, MailParser.ParseMailAddress(mdn.Recipient)); // // The nature of Mdn storage in config store does not result in a list of perRecipients // If you would rather send one DSN with muliple recipients then one could write their own Job. // var notification = new DSN(perMessage, new List <DSNPerRecipient> { perRecipient }); var sender = new MailAddress(mdn.Sender); var notificationMessage = new DSNMessage(sender.Address, new MailAddress("Postmaster@" + sender.Host).Address, notification); notificationMessage.AssignMessageID(); notificationMessage.SubjectValue = string.Format("{0}:{1}", "Rejected", mdn.SubjectValue); notificationMessage.Timestamp(); return(notificationMessage); }
public void TestEndToEnd_GatewayIsDestination_Is_True_And_TimelyAndReliable_Not_Requestd() { CleanMessages(m_agent.Settings); m_agent.Settings.InternalMessage.EnableRelay = true; m_agent.Settings.Outgoing.EnableRelay = true; m_agent.Settings.Notifications.AutoResponse = true; m_agent.Settings.Notifications.AlwaysAck = true; m_agent.Settings.Notifications.GatewayIsDestination = true; m_agent.Settings.MdnMonitor = new ClientSettings(); m_agent.Settings.MdnMonitor.Url = "http://localhost/ConfigService/MonitorService.svc/Dispositions"; // // 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. // string textMessage = string.Format(string.Format(TestMessage, Guid.NewGuid()), Guid.NewGuid()); var sendingMessage = LoadMessage(textMessage); Assert.Null(Record.Exception(() => RunEndToEndTest(sendingMessage))); // // grab the clear text mdns and delete others. // foreach (var pickupMessage in PickupMessages()) { string messageText = File.ReadAllText(pickupMessage); if (messageText.Contains("disposition-notification")) { Assert.Null(Record.Exception(() => RunMdnOutBoundProcessingTest(LoadMessage(messageText)))); } } // // Now the messages are encrypted and can be handled // Processed Mdn's will be recorded by the MdnMonitorService // foreach (var pickupMessage in PickupMessages()) { string messageText = File.ReadAllText(pickupMessage); CDO.Message message = LoadMessage(messageText); Assert.Null(Record.Exception(() => RunMdnInBoundProcessingTest(message))); var envelope = new CDOSmtpMessage(message).GetEnvelope(); var mdn = MDNParser.Parse(envelope.Message); // // Only expect processed MDNs // Assert.Equal(MDNStandard.NotificationType.Processed, mdn.Disposition.Notification); TestMdnTimelyAndReliableExtensionField(mdn, false); } // // Test Mdn data is processed // Remember above (Settings.Notifications.GatewayIsDestination = true) // but message did not request TimelyAndReliable // var messageEnvelope = new CDOSmtpMessage(sendingMessage).GetEnvelope(); foreach (var recipient in messageEnvelope.Recipients) { var queryMdn = new Mdn(messageEnvelope.Message.IDValue , recipient.Address , messageEnvelope.Message.FromValue , MdnStatus.Processed); var mdnManager = CreateConfigStore().Mdns; var mdn = mdnManager.Get(queryMdn.MdnIdentifier); Assert.NotNull(mdn); Assert.Equal("processed", mdn.Status, StringComparer.OrdinalIgnoreCase); Assert.Equal(false, mdn.NotifyDispatched); } m_agent.Settings.InternalMessage.EnableRelay = false; }
public void Delete(Mdn obj) { throw new System.NotImplementedException(); }
public Mdn Update(Mdn obj) { throw new System.NotImplementedException(); }