public void TestRenameDomainWithAliases() { Alias alias1 = _domain.Aliases.Add(); alias1.Name = "*****@*****.**"; alias1.Value = "*****@*****.**"; alias1.Save(); Alias alias2 = _domain.Aliases.Add(); alias2.Name = "*****@*****.**"; alias2.Value = "*****@*****.**"; alias2.Save(); Alias alias3 = _domain.Aliases.Add(); alias3.Name = "*****@*****.**"; alias3.Value = "*****@*****.**"; alias3.Save(); _domain.Name = "example.com"; _domain.Save(); CustomAssert.AreEqual("*****@*****.**", _domain.Aliases[0].Name); CustomAssert.AreEqual("*****@*****.**", _domain.Aliases[0].Value); CustomAssert.AreEqual("*****@*****.**", _domain.Aliases[1].Name); CustomAssert.AreEqual("*****@*****.**", _domain.Aliases[1].Value); CustomAssert.AreEqual("*****@*****.**", _domain.Aliases[2].Name); CustomAssert.AreEqual("*****@*****.**", _domain.Aliases[2].Value); }
public void TestPOP3TransactionSafety() { Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); CustomAssert.IsTrue(SMTPClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestBody")); POP3ClientSimulator.AssertMessageCount(account.Address, "test", 1); var sim = new POP3ClientSimulator(); sim.ConnectAndLogon(account.Address, "test"); // Now delete the message using an IMAP client. var imapSimulator = new IMAPClientSimulator(); CustomAssert.IsTrue(imapSimulator.ConnectAndLogon(account.Address, "test")); CustomAssert.IsTrue(imapSimulator.SelectFolder("INBOX")); CustomAssert.IsTrue(imapSimulator.SetDeletedFlag(1)); CustomAssert.IsTrue(imapSimulator.Expunge()); CustomAssert.AreEqual(0, imapSimulator.GetMessageCount("Inbox")); CustomAssert.IsTrue(SMTPClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestBody")); IMAPClientSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1); // This deletion should not have any effect, since the POP3 connection is referencing an old message. sim.DELE(1); sim.QUIT(); CustomAssert.AreEqual(1, imapSimulator.GetMessageCount("Inbox")); }
public void TestImportOfMessageIntoOtherFolder() { string @messageText = "From: [email protected]\r\n" + "\r\n" + "Test\r\n"; Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); account.IMAPFolders.Add("Woho"); string domainPath = Path.Combine(_application.Settings.Directories.DataDirectory, "test.com"); string accountPath = Path.Combine(domainPath, "test"); Directory.CreateDirectory(accountPath); string fileName = Path.Combine(accountPath, "something.eml"); File.WriteAllText(fileName, messageText); CustomAssert.IsTrue(_application.Utilities.ImportMessageFromFileToIMAPFolder(fileName, account.ID, "Woho")); POP3ClientSimulator.AssertMessageCount("*****@*****.**", "test", 0); var sim = new IMAPClientSimulator(); sim.ConnectAndLogon("*****@*****.**", "test"); CustomAssert.AreEqual(1, sim.GetMessageCount("Woho")); sim.Disconnect(); }
public void TestChangeSeenFlag() { Account oAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); CustomAssert.IsTrue(SMTPClientSimulator.StaticSend("*****@*****.**", oAccount.Address, "Test", "test")); POP3ClientSimulator.AssertMessageCount(oAccount.Address, "test", 1); var simulator = new IMAPClientSimulator(); simulator.ConnectAndLogon(oAccount.Address, "test"); simulator.ExamineFolder("Inbox"); string flags = simulator.GetFlags(1); string body = simulator.Fetch("1 RFC822"); string flagsAfter = simulator.GetFlags(1); simulator.Close(); simulator.Disconnect(); CustomAssert.AreEqual(flags, flagsAfter); var secondSimulator = new IMAPClientSimulator(); secondSimulator.ConnectAndLogon(oAccount.Address, "test"); secondSimulator.SelectFolder("Inbox"); string secondFlags = secondSimulator.GetFlags(1); string secondBody = secondSimulator.Fetch("1 RFC822"); string secondFlagsAfter = secondSimulator.GetFlags(1); secondSimulator.Close(); secondSimulator.Disconnect(); CustomAssert.AreNotEqual(secondFlags, secondFlagsAfter); }
public void TestDeliverToMyselfOnLocalPort() { CustomAssert.AreEqual(0, _status.UndeliveredMessages.Length); // Add a route so we can conenct to localhost. AddRoutePointingAtLocalhost(1, 25, false); // Send message to this route. SMTPClientSimulator.StaticSend("*****@*****.**", "*****@*****.**", "subject", "body"); for (int i = 0; i < 40; i++) { string s = _status.UndeliveredMessages; if (s.Contains("\t\[email protected]")) { break; } Thread.Sleep(250); } // Wait for the bounce message to be delivered. TestSetup.AssertRecipientsInDeliveryQueue(0, true); string message = POP3ClientSimulator.AssertGetFirstMessageText("*****@*****.**", "test"); CustomAssert.IsTrue(message.Contains("this would mean connecting to myself.")); }
public void TestAliasLink() { Alias alias = SingletonProvider <TestSetup> .Instance.AddAlias(_domain, "mytest", "test2"); CustomAssert.AreEqual(alias.Value, _links.get_Alias(alias.ID).Value); }
public void ConfirmFileAddedToCorrectAccountFolder() { TestSetup testSetup = SingletonProvider <TestSetup> .Instance; Account oAccount = testSetup.AddAccount(_domain, "*****@*****.**", "test"); var oSimulator = new IMAPClientSimulator(); // Confirm that the public folder is empty before we start our test. string publicDir = testSetup.GetPublicDirectory(); testSetup.AssertFilesInDirectory(publicDir, 0); // Add a message to the inbox. oSimulator.Connect(); oSimulator.LogonWithLiteral("*****@*****.**", "test"); oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX {4}", "ABCD"); // Confirm it exists in the IMAP folder. CustomAssert.AreEqual(1, oSimulator.GetMessageCount("INBOX")); oSimulator.Disconnect(); // The public directory should still be empty - the message was added to the user account. testSetup.AssertFilesInDirectory(publicDir, 0); // There should be a single file in the users directory. testSetup.AssertFilesInUserDirectory(oAccount, 1); }
public void TestBasicIncrements() { Account testAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "Test'*****@*****.**", "test"); SMTPClientSimulator.StaticSend(testAccount.Address, testAccount.Address, "Test", "Test"); POP3ClientSimulator.AssertMessageCount(testAccount.Address, "test", 1); IMAPFolder inboxFolder = testAccount.IMAPFolders[0]; CustomAssert.AreEqual(1, inboxFolder.CurrentUID); CustomAssert.AreEqual(1, inboxFolder.Messages[0].UID); SMTPClientSimulator.StaticSend(testAccount.Address, testAccount.Address, "Test", "Test"); POP3ClientSimulator.AssertMessageCount(testAccount.Address, "test", 2); CustomAssert.AreEqual(2, inboxFolder.CurrentUID); CustomAssert.AreEqual(2, inboxFolder.Messages[1].UID); SMTPClientSimulator.StaticSend(testAccount.Address, testAccount.Address, "Test", "Test"); POP3ClientSimulator.AssertMessageCount(testAccount.Address, "test", 3); CustomAssert.AreEqual(3, inboxFolder.CurrentUID); CustomAssert.AreEqual(3, inboxFolder.Messages[2].UID); }
public void TestJapaneseAttachments() { Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); string attachmentName = "本本本.zip"; string filename = Path.Combine(Path.GetTempPath(), attachmentName); File.WriteAllText(filename, "tjena moss"); var message = new hMailServer.Message(); message.AddRecipient("test", account.Address); message.From = "Test"; message.FromAddress = account.Address; message.Body = "hejsan"; message.Attachments.Add(filename); message.Save(); TestSetup.AssertFolderMessageCount(account.IMAPFolders[0], 1); hMailServer.Message downloadedMessage = account.IMAPFolders[0].Messages[0]; CustomAssert.AreNotEqual(0, downloadedMessage.Attachments.Count); Attachment attachment = downloadedMessage.Attachments[0]; CustomAssert.AreEqual(attachmentName, attachment.Filename); }
public void DoubleExchange_DefaultSwap() { // arrange // ensure overflow correction occurs Memory[0x000] = (0x8000).ToOnesCompliment(); Memory[0x001] = (2).ToOnesCompliment(); Memory[0x200] = (3).ToOnesCompliment(); Memory[0x201] = (4).ToOnesCompliment(); // insert instructions Memory.LoadFixedRom(new ushort[] { 0x05400 | 0x201 }); // act - run the instruction CPU.Execute(); // assert CustomAssert.AreEqual(3, Memory[0x0]); CustomAssert.AreEqual(4, Memory[0x1]); CustomAssert.AreEqual(0xC000, Memory[0x200]); CustomAssert.AreEqual(2, Memory[0x201]); }
public void TestMoveMessageWithGlobalRule() { Account testAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "Test'*****@*****.**", "test"); // First deliver two messages to the inbox. SMTPClientSimulator.StaticSend(testAccount.Address, testAccount.Address, "Test", "Test"); POP3ClientSimulator.AssertMessageCount(testAccount.Address, "test", 1); IMAPFolder inboxFolder = testAccount.IMAPFolders[0]; CustomAssert.AreEqual(1, inboxFolder.CurrentUID); CustomAssert.AreEqual(1, inboxFolder.Messages[0].UID); SMTPClientSimulator.StaticSend(testAccount.Address, testAccount.Address, "Test", "Test"); POP3ClientSimulator.AssertMessageCount(testAccount.Address, "test", 2); CustomAssert.AreEqual(2, inboxFolder.CurrentUID); CustomAssert.AreEqual(2, inboxFolder.Messages[1].UID); CreateMoveRule(_application.Rules, "TestFolder"); // This message will be moved into the test folder. SMTPClientSimulator.StaticSend(testAccount.Address, testAccount.Address, "Test", "Test"); // Wait for the message to arrive. TestSetup.AssertFolderExists(testAccount.IMAPFolders, "TestFolder"); IMAPFolder testFolder = testAccount.IMAPFolders.get_ItemByName("TestFolder"); TestSetup.AssertFolderMessageCount(testFolder, 1); // Since the message is placed in a new folder, it should receive a unique UID. CustomAssert.AreEqual(1, testFolder.Messages.Count); CustomAssert.AreEqual(1, testFolder.CurrentUID); CustomAssert.AreEqual(1, testFolder.Messages[0].UID); }
public void DoubleExchange_SwitchingFBank() { // arrange Memory[0x000] = (0x0800).ToOnesCompliment(); Memory[0x001] = (0x000D).ToOnesCompliment(); Memory[0x004] = OnesCompliment.PositiveZero; // insert instructions Memory.LoadFixedRom(new ushort[] { 0x05400 | 0x005 }); // act - run the instruction CPU.Execute(); // assert CustomAssert.AreEqual(0x0000, Memory[0x0]); // should be set to boot interrupt + 1 instruction CustomAssert.AreEqual(0x0801, Memory[0x1]); CustomAssert.AreEqual(0x0800, Memory[0x004]); CustomAssert.AreEqual(0x000D, Memory[0x005]); // check fb and bb registers CustomAssert.AreEqual(0x0800, Memory[0x04]); CustomAssert.AreEqual(0x0800, Memory[0x06]); }
public void DoubleExchange_QRegister() { // arrange Memory[0x000] = (0x8000).ToOnesCompliment(); Memory[0x001] = (0x000D).ToOnesCompliment(); Memory[0x002] = (0x8001).ToOnesCompliment(); Memory[0x003] = (0x0400).ToOnesCompliment(); Memory.LoadFixedRom(new ushort[] { 0x05400 | 0x003 }); // act CPU.Execute(); // assert CustomAssert.AreEqual(0x8001, Memory[0x0]); CustomAssert.AreEqual(0x0400, Memory[0x1]); CustomAssert.AreEqual(0x8000, Memory[0x2]); CustomAssert.AreEqual(0x0000, Memory[0x3]); }
public void TestRenameDomainWithList() { DistributionList oList = _domain.DistributionLists.Add(); oList.Address = "*****@*****.**"; oList.Active = true; oList.Save(); DistributionListRecipient oRecipient = oList.Recipients.Add(); oRecipient.RecipientAddress = "*****@*****.**"; oRecipient.Save(); oRecipient = oList.Recipients.Add(); oRecipient.RecipientAddress = "*****@*****.**"; oRecipient.Save(); oRecipient = oList.Recipients.Add(); oRecipient.RecipientAddress = "*****@*****.**"; oRecipient.Save(); _domain.Name = "example.com"; _domain.Save(); DistributionList list = _domain.DistributionLists[0]; CustomAssert.AreEqual("*****@*****.**", list.Address); CustomAssert.AreEqual("*****@*****.**", list.Recipients[0].RecipientAddress); CustomAssert.AreEqual("*****@*****.**", list.Recipients[1].RecipientAddress); CustomAssert.AreEqual("*****@*****.**", list.Recipients[2].RecipientAddress); }
public void TestSaveMessageInExistingIMAPFolder() { Settings settings = SingletonProvider <TestSetup> .Instance.GetApp().Settings; Account oAccount1 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); // Check that the message does not exist POP3ClientSimulator.AssertMessageCount(oAccount1.Address, "test", 0); // Send a message to the account. IMAPFolder folder = oAccount1.IMAPFolders.get_ItemByName("INBOX"); hMailServer.Message oMessage = folder.Messages.Add(); CustomAssert.AreEqual(0, oMessage.State); oMessage.Body = "Välkommen till verkligheten"; oMessage.Subject = "Hej"; oMessage.Save(); CustomAssert.AreEqual(2, oMessage.State); CustomAssert.IsFalse(oMessage.Filename.Contains(settings.PublicFolderDiskName)); CustomAssert.IsTrue(oMessage.Filename.Contains(_domain.Name)); // Check that the message exists string message = POP3ClientSimulator.AssertGetFirstMessageText(oAccount1.Address, "test"); CustomAssert.IsNotEmpty(message); CustomAssert.Less(0, message.IndexOf("Hej")); }
public void TestSwedishAndChineseCombination() { Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); string swedishAndChinese = "ÅÄÖ汉语"; string attachmentName = swedishAndChinese + ".zip"; string filename = Path.Combine(Path.GetTempPath(), attachmentName); File.WriteAllText(filename, swedishAndChinese); var message = new hMailServer.Message(); message.AddRecipient("test", account.Address); message.From = "Test"; message.FromAddress = account.Address; message.Body = swedishAndChinese; message.Attachments.Add(filename); message.Save(); TestSetup.AssertFolderMessageCount(account.IMAPFolders[0], 1); hMailServer.Message downloadedMessage = account.IMAPFolders[0].Messages[0]; CustomAssert.AreNotEqual(0, downloadedMessage.Attachments.Count); Attachment attachment = downloadedMessage.Attachments[0]; CustomAssert.AreEqual(attachmentName, attachment.Filename); CustomAssert.AreEqual(swedishAndChinese + Environment.NewLine, downloadedMessage.Body); }
public void TestAccountLink() { Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "test", "test"); CustomAssert.AreEqual(account.Address, _links.get_Account(account.ID).Address); }
public void RequestingSameHeaderFieldMultipleTimesShouldReturnItOnce() { Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); string message = "From: Someone <*****@*****.**>" + Environment.NewLine + "To: Someoen <*****@*****.**>" + Environment.NewLine + "Date: Wed, 22 Apr 2009 11:05:09 \"GMT\"" + Environment.NewLine + "Subject: SubjectText" + Environment.NewLine + Environment.NewLine + "Hello" + Environment.NewLine; var smtpSimulator = new SMTPClientSimulator(); CustomAssert.IsTrue(smtpSimulator.SendRaw(account.Address, account.Address, message)); POP3ClientSimulator.AssertMessageCount(account.Address, "test", 1); var oSimulator = new IMAPClientSimulator(); string sWelcomeMessage = oSimulator.Connect(); oSimulator.Logon(account.Address, "test"); oSimulator.SelectFolder("INBOX"); string result = oSimulator.Fetch("1 BODY.PEEK[HEADER.FIELDS (Subject Subject)]"); oSimulator.Disconnect(); CustomAssert.AreEqual(1, StringExtensions.Occurences(result, "SubjectText")); }
public void DoubleClearAndSubstract_CycleRegister() { // arrange // writing int CYR will cause it to cycle right Memory[0x010] = (0x002).ToOnesCompliment(); // writing into SR will cause it to shift right Memory[0x011] = (0x004).ToOnesCompliment(); // insert instructions and test data Memory.LoadFixedRom(new ushort[] { 0x00006, // EXTEND instruction 0x04000 | 0x011, // SR address }); // act CPU.Execute(); CPU.Execute(); // assert // check value in accumulator and L CustomAssert.AreEqual(0xFFFE, Memory[0x0]); CustomAssert.AreEqual(0xFFFD, Memory[0x1]); // check value in CYR was cycled CustomAssert.AreEqual(0xC000, Memory[0x10]); // check value in SR was shifted CustomAssert.AreEqual(0x0001, Memory[0x11]); }
private void ConfirmRoutes() { Routes routes = _application.Settings.Routes; CustomAssert.AreEqual(2, routes.Count); Route route = routes[0]; CustomAssert.AreEqual("test1.com", route.DomainName); CustomAssert.AreEqual("description", route.Description); CustomAssert.AreEqual(true, route.UseSSL); CustomAssert.AreEqual(true, route.TreatSenderAsLocalDomain); CustomAssert.AreEqual(false, route.TreatRecipientAsLocalDomain); CustomAssert.AreEqual(false, route.TreatSecurityAsLocalDomain); route = routes[1]; CustomAssert.AreEqual("test2.com", route.DomainName); CustomAssert.AreEqual("description2", route.Description); CustomAssert.AreEqual(false, route.UseSSL); CustomAssert.AreEqual(false, route.TreatSenderAsLocalDomain); CustomAssert.AreEqual(true, route.TreatRecipientAsLocalDomain); CustomAssert.AreEqual(true, route.TreatSecurityAsLocalDomain); CustomAssert.AreEqual(2, route.Addresses.Count); var addresses = new List <string>(); addresses.Add(route.Addresses[0].Address); addresses.Add(route.Addresses[1].Address); CustomAssert.IsTrue(addresses.Contains("*****@*****.**")); CustomAssert.IsTrue(addresses.Contains("*****@*****.**")); }
public void BothBanksRegister_SetWithinMask() { // arrange Memory[0x200] = (0x0800 | 0x0002).ToOnesCompliment(); // insert instructions Memory.LoadFixedRom(new ushort[] { 0x06000 | 0x200, // add to the accumulator 0x05800 | 0x06 // transfer to storage, the BB register }); // act - run the instructions CPU.Execute(); CPU.Execute(); // assert // check BB register CustomAssert.AreEqual(0x0800 | 0x0002, Memory[0x6]); // check EB register CustomAssert.AreEqual(0x0200, Memory[0x3]); // check FB register CustomAssert.AreEqual(0x0800, Memory[0x4]); }
private void ConfirmAliasObject() { Alias alias = _application.Domains[0].Aliases[0]; CustomAssert.AreEqual("*****@*****.**", alias.Name); CustomAssert.AreEqual("*****@*****.**", alias.Value); }
public void TestDeliverToServerNotSupportingEHLO() { CustomAssert.AreEqual(0, _status.UndeliveredMessages.Length); var deliveryResults = new Dictionary <string, int>() { { "*****@*****.**", 250 } }; int smtpServerPort = TestSetup.GetNextFreePort(); using (var server = new SMTPServerSimulator(1, smtpServerPort)) { server.ServerSupportsEhlo = false; server.AddRecipientResult(deliveryResults); server.StartListen(); // Add a route so we can conenct to localhost. SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSNone); // Send message to this route. if (!SMTPClientSimulator.StaticSend("*****@*****.**", "*****@*****.**", "Test", "Test message")) { CustomAssert.Fail("Delivery failed"); } // Wait for the client to disconnect. server.WaitForCompletion(); TestSetup.AssertRecipientsInDeliveryQueue(0, false); CustomAssert.IsTrue(server.MessageData.Contains("Test message")); } }
public void TestNormalUserAccessOtherAccount() { Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); account.AdminLevel = eAdminLevel.hAdminLevelNormal; account.Save(); Account secondAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); secondAccount.AdminLevel = eAdminLevel.hAdminLevelNormal; secondAccount.Save(); var newApplication = new Application(); newApplication.Authenticate("*****@*****.**", "test"); CustomAssert.AreEqual(1, newApplication.Domains.Count); CustomAssert.AreEqual(1, newApplication.Domains[0].Accounts.Count); Account myAccount = newApplication.Domains[0].Accounts.get_ItemByAddress("*****@*****.**"); try { Account otherAccount = newApplication.Domains[0].Accounts.get_ItemByAddress("*****@*****.**"); CustomAssert.Fail(); } catch (COMException ex) { CustomAssert.IsTrue(ex.Message.Contains("Invalid index.")); } Domains domains = SingletonProvider <TestSetup> .Instance.GetApp().Domains; CustomAssert.AreEqual(2, domains[0].Accounts.Count); }
public void TestDeliverySuccessSingleRecipientMissingQuitResponse() { CustomAssert.AreEqual(0, _status.UndeliveredMessages.Length); // No valid recipients... var deliveryResults = new Dictionary <string, int>(); deliveryResults["*****@*****.**"] = 250; int smtpServerPort = TestSetup.GetNextFreePort(); using (var server = new SMTPServerSimulator(1, smtpServerPort)) { server.AddRecipientResult(deliveryResults); server.StartListen(); server.SimulatedError = SimulatedErrorType.DisconnectWithoutReplyOnQuit; // Add a route so we can connect to localhost. AddRoutePointingAtLocalhost(5, smtpServerPort, false); // Send message to this route. var smtp = new SMTPClientSimulator(); var recipients = new List <string>(); recipients.Add("*****@*****.**"); CustomAssert.IsTrue(smtp.Send("*****@*****.**", recipients, "Test", "DeliverySuccessNoQuitResponse")); // Wait for the client to disconnect. server.WaitForCompletion(); TestSetup.AssertRecipientsInDeliveryQueue(0, false); CustomAssert.IsTrue(server.MessageData.Contains("DeliverySuccessNoQuitResponse")); } }
public void TestDomainAdminAccessOtherDomain() { Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); account.AdminLevel = eAdminLevel.hAdminLevelDomainAdmin; account.Save(); SingletonProvider <TestSetup> .Instance.AddDomain("example.com"); var newApplication = new Application(); newApplication.Authenticate("*****@*****.**", "test"); CustomAssert.AreEqual(1, newApplication.Domains.Count); Domains domains = SingletonProvider <TestSetup> .Instance.GetApp().Domains; CustomAssert.AreEqual(2, domains.Count); try { Domain secondDomain = newApplication.Domains.get_ItemByName("example.com"); CustomAssert.Fail("Was able to access other domain."); } catch (COMException ex) { CustomAssert.IsTrue(ex.Message.Contains("Invalid index.")); } }
public void TestImportOfMessageInSubdirectory() { string @messageText = "From: [email protected]\r\n" + "\r\n" + "Test\r\n"; Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); string domainPath = Path.Combine(_application.Settings.Directories.DataDirectory, "test.com"); string accountPath = Path.Combine(domainPath, "test"); Directory.CreateDirectory(accountPath); string guid = Guid.NewGuid().ToString(); string guidPath = Path.Combine(accountPath, guid.Substring(1, 2)); Directory.CreateDirectory(guidPath); string fileName = Path.Combine(guidPath, guid + ".eml"); File.WriteAllText(fileName, messageText); CustomAssert.IsTrue(_application.Utilities.ImportMessageFromFile(fileName, account.ID)); hMailServer.Message message = _domain.Accounts[0].IMAPFolders.get_ItemByName("Inbox").Messages[0]; CustomAssert.AreEqual(fileName, message.Filename); }
public void TestIMAPFolderPermissionAccessGroup() { Application application = SingletonProvider <TestSetup> .Instance.GetApp(); Account account1 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test"); Group group = SingletonProvider <TestSetup> .Instance.AddGroup("TestGroup"); IMAPFolders publicFolders = _settings.PublicFolders; IMAPFolder folder = publicFolders.Add("Share1"); folder.Save(); IMAPFolderPermission permission = folder.Permissions.Add(); permission.PermissionGroupID = group.ID; permission.PermissionType = eACLPermissionType.ePermissionTypeGroup; permission.Save(); CustomAssert.AreEqual(permission.Group.Name, group.Name); permission = folder.Permissions.Add(); permission.PermissionAccountID = account1.ID; permission.PermissionType = eACLPermissionType.ePermissionTypeUser; permission.Save(); CustomAssert.AreEqual(permission.Account.Address, account1.Address); }
public void TestMetaDataSortCC() { Application application = SingletonProvider <TestSetup> .Instance.GetApp(); Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "meta'*****@*****.**", "test"); // disable... SendMessage("Test C", "Body", "", "ÄÄÄ"); IMAPClientSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1); SendMessage("Test B", "Body", "", "ÖÖÖ"); IMAPClientSimulator.AssertMessageCount(account.Address, "test", "Inbox", 2); SendMessage("Test A", "Body", "", "ÅÅÅ"); IMAPClientSimulator.AssertMessageCount(account.Address, "test", "Inbox", 3); AssertAllMessagesIndexed(); var sim = new IMAPClientSimulator(account.Address, "test", "Inbox"); string result = sim.Sort("(CC) UTF-8 ALL"); CustomAssert.AreEqual("3 1 2", result); // Disable the indexing functionality _indexing.Enabled = false; _indexing.Clear(); // Make sure the sort order is the same. string resultAfter = sim.Sort("(CC) UTF-8 ALL"); CustomAssert.AreEqual(result, resultAfter); }
public void TestIncomingRelays() { IncomingRelays incomingRelays = _application.Settings.IncomingRelays; CustomAssert.AreEqual(0, incomingRelays.Count); IncomingRelay incomingRelay = incomingRelays.Add(); incomingRelay.Name = "TestRelay"; incomingRelay.LowerIP = "1.2.1.1"; incomingRelay.UpperIP = "2.1.2.1"; incomingRelay.Save(); // Check that it was saved. CustomAssert.AreNotEqual(0, incomingRelay.ID); // Confirm that settings were saved properly. incomingRelays.Refresh(); IncomingRelay incomingRelay2 = incomingRelays.get_ItemByDBID(incomingRelay.ID); CustomAssert.AreEqual(incomingRelay.ID, incomingRelay2.ID); CustomAssert.AreEqual(incomingRelay.Name, incomingRelay2.Name); CustomAssert.AreEqual(incomingRelay.LowerIP, incomingRelay2.LowerIP); CustomAssert.AreEqual(incomingRelay.UpperIP, incomingRelay2.UpperIP); // Delete it again. incomingRelays.Delete(0); CustomAssert.AreEqual(0, incomingRelays.Count); }