public void TestBatchOfCommands()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(account.Address, "test");

             string commandSequence = "";
             for (int i = 0; i < 200; i++)
             {
            commandSequence += "A" + i.ToString() + " SELECT INBOX\r\n";
             }
             commandSequence = commandSequence.TrimEnd("\r\n".ToCharArray());

             string result = oSimulator.Send(commandSequence);
             CustomAssert.IsFalse(result.StartsWith("* BYE"));

             oSimulator.Disconnect();

             sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(account.Address, "test");
             commandSequence = "";
             for (int i = 0; i < 500; i++)
             {
            commandSequence += "A" + i.ToString() + " SELECT INBOX\r\n";
             }
             commandSequence = commandSequence.TrimEnd("\r\n".ToCharArray());

             result = oSimulator.Send(commandSequence);
             CustomAssert.IsFalse(result.StartsWith("* BYE Excessive number of buffered commands"));
             oSimulator.Disconnect();
        }
Esempio n. 2
0
        public void TestNestedOrSearch()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Search test", "This is a test of IMAP Search");

             IMAPClientSimulator.AssertMessageCount(oAccount.Address, "test", "Inbox", 1);

             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             oSimulator.SelectFolder("INBOX");

             string result =
            oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SINCE 28-May-2008 SINCE 28-May-2008 SINCE 28-May-2008");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH 1"), result);

             result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR SMALLER 1 LARGER 10000");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH\r\n"), result);

             result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SMALLER 1 LARGER 10000 SMALLER 10000");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH 1\r\n"), result);
        }
Esempio n. 3
0
        public void IfStlsRequiredLogonShouldFailIfNoStls()
        {
            var imapSimulator = new IMAPClientSimulator(false, 14303);
             imapSimulator.Connect();

             string errorMessage;
             CustomAssert.IsFalse(imapSimulator.Logon(_account.Address, "test", out errorMessage));

             CustomAssert.IsTrue(errorMessage.Contains("A01 BAD STARTTLS is required."));
        }
Esempio n. 4
0
        public void IfStlsRequiredLogonShouldSucceedIfStls()
        {
            var imapSimulator = new IMAPClientSimulator(false, 14303);
             imapSimulator.Connect();
             imapSimulator.SendSingleCommand("A01 STARTTLS");
             imapSimulator.Handshake();

             // command is sent over TLS.
             imapSimulator.GetCapabilities();

             CustomAssert.IsTrue(imapSimulator.Logon(_account.Address, "test"));
        }
Esempio n. 5
0
        public void TestCreateFolderWithHash()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var oSimulator = new IMAPClientSimulator();

             oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             CustomAssert.IsFalse(oSimulator.CreateFolder("#Test"));
             CustomAssert.IsTrue(oSimulator.CreateFolder("Test.#Testar"));
             oSimulator.Disconnect();
        }
Esempio n. 6
0
        public void IfStlsOptionalButSslRequiredByIpRangeForAuthThenAuthShouldFail()
        {
            var range = SingletonProvider<TestSetup>.Instance.GetApp().Settings.SecurityRanges.get_ItemByName("My computer");
             range.RequireSSLTLSForAuth = true;
             range.Save();

             var imapSimulator = new IMAPClientSimulator(false, 14302);
             imapSimulator.Connect();

             string errorMessage;
             CustomAssert.IsFalse(imapSimulator.Logon(_account.Address, "test", out errorMessage));
             CustomAssert.IsTrue(errorMessage.Contains("A01 BAD A SSL/TLS-connection is required for authentication."));
        }
Esempio n. 7
0
        public void TestCreateFolderWithSlash()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             const string folderName = "ABC\\123";

             var oSimulator = new IMAPClientSimulator();
             oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             CustomAssert.IsTrue(oSimulator.CreateFolder(folderName));
             CustomAssert.IsTrue(oSimulator.List().Contains(folderName));
             CustomAssert.IsTrue(oSimulator.SelectFolder(folderName));
             oSimulator.Disconnect();
        }
Esempio n. 8
0
        public void TestAppendDeletedMessage()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX (\\Deleted) {4}", "ABCD");
             CustomAssert.AreEqual(1, oSimulator.GetMessageCount("INBOX"));

             CustomAssert.AreEqual("1", oSimulator.Search("DELETED"));

             oSimulator.Disconnect();
        }
        public void TestLongCommand()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(account.Address, "test");

             var sb = new StringBuilder();

             for (int i = 0; i < 240000; i++)
             {
            sb.Append("A");
             }

             string result = oSimulator.Send("A01 " + sb);
             CustomAssert.IsTrue(result.Length == 0 || result.StartsWith("A01"));
        }
        public void TestHierarchyDelimiterListResponse()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();
             Settings settings = _settings;
             settings.IMAPHierarchyDelimiter = "\\";

             Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             string folderName = "Test\\Test";

             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(account.Address, "test");
             CustomAssert.IsTrue(oSimulator.CreateFolder(folderName));
             string listResponse = oSimulator.List();
             CustomAssert.IsTrue(listResponse.Contains("\"Test\\Test\""));
             CustomAssert.IsTrue(listResponse.Contains("\"Test\""));
             oSimulator.Disconnect();
        }
Esempio n. 11
0
        public void TestAppendFolderNameInOctet()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             oSimulator.SelectFolder("INBOX");
             oSimulator.CreateFolder("MONK");
             oSimulator.SendRaw("A01 APPEND {4}\r\n");
             string result = oSimulator.Receive();
             CustomAssert.IsTrue(result.StartsWith("+ Ready for additional command text."));

             oSimulator.SendRaw("MONK (\\Seen) \"20-Jan-2009 12:59:50 +0100\" {5}\r\n");
             result = oSimulator.Receive();
             CustomAssert.IsTrue(result.StartsWith("+ Ready for literal data"));

             oSimulator.SendRaw("WOOOT\r\n");
             result = oSimulator.Receive();

             CustomAssert.AreEqual("A01 OK APPEND completed\r\n", result);
        }
Esempio n. 12
0
        public void TestFolderLSUBUnsubscribedFolder()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             const string folderName = "ABC.def.GHI";

             var oSimulator = new IMAPClientSimulator();
             oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             CustomAssert.IsTrue(oSimulator.CreateFolder(folderName));
             CustomAssert.IsFalse(oSimulator.LSUB().Contains("\r\n\r\n"));
             oSimulator.Disconnect();
        }
Esempio n. 13
0
        public void TestFolderCaseInLSUB()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             string folderName = "ABC.def.GHI";

             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             CustomAssert.IsTrue(oSimulator.CreateFolder(folderName));
             CustomAssert.IsTrue(oSimulator.Subscribe(folderName));
             CustomAssert.IsFalse(oSimulator.LSUB("ABC.DEF.*").Contains("ABC.def.GHI"));
             CustomAssert.IsTrue(oSimulator.LSUB("ABC.DEF.*").Contains("ABC.DEF.GHI"));
             CustomAssert.IsFalse(oSimulator.LSUB("ABC.def.*").Contains("ABC.DEF"));
             CustomAssert.IsTrue(oSimulator.LSUB("ABC.def.*").Contains("ABC.def.GHI"));
             CustomAssert.IsTrue(oSimulator.SelectFolder(folderName));
             oSimulator.Disconnect();
        }
Esempio n. 14
0
        public void TestSearch()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "se'*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send(oAccount.Address, oAccount.Address, "Search test", "This is a test of IMAP Search");

             IMAPClientSimulator.AssertMessageCount(oAccount.Address, "test", "INBOX", 1);

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             oSimulator.SetFlagOnFirstMessage(true, "\\ANSWERED");
             if (oSimulator.Search("ANSWERED") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\ANSWERED");
             if (oSimulator.Search("ANSWERED") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\DELETED");
             if (oSimulator.Search("DELETED") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\DELETED");
             if (oSimulator.Search("DELETED") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\DRAFT");
             if (oSimulator.Search("DRAFT") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\DRAFT");
             if (oSimulator.Search("DRAFT") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\FLAGGED");
             if (oSimulator.Search("FLAGGED  ") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\FLAGGED");
             if (oSimulator.Search("FLAGGED") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\SEEN");
             if (oSimulator.Search("SEEN") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\SEEN");
             if (oSimulator.Search("SEEN") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\ANSWERED");
             if (oSimulator.Search("UNANSWERED") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\ANSWERED");
             if (oSimulator.Search("UNANSWERED") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\DELETED");
             if (oSimulator.Search("UNDELETED") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\DELETED");
             if (oSimulator.Search("UNDELETED") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\DRAFT");
             if (oSimulator.Search("UNDRAFT") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\DRAFT");
             if (oSimulator.Search("UNDRAFT") != "1")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(true, "\\FLAGGED");
             if (oSimulator.Search("UNFLAGGED") != "")
            throw new Exception("ERROR - Search or flag failed");

             oSimulator.SetFlagOnFirstMessage(false, "\\FLAGGED");
             if (oSimulator.Search("UNFLAGGED") != "1")
            throw new Exception("ERROR - Search or flag failed");

             // SEARCH using LARGER & SMALLER
             if (oSimulator.Search("SMALLER 10") != "")
            throw new Exception("ERROR - Search or flag failed");

             if (oSimulator.Search("SMALLER 10000") != "1")
            throw new Exception("ERROR - Search or flag failed");

             if (oSimulator.Search("LARGER 10") != "1")
            throw new Exception("ERROR - Search or flag failed");

             if (oSimulator.Search("LARGER 10000") != "")
            throw new Exception("ERROR - Search or flag failed");
        }
Esempio n. 15
0
        public void TestSearchWithLiterals()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Test2", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");

             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string result = oSimulator.SendSingleCommandWithLiteral("A01 SEARCH HEADER SUBJECT {5}", "Test1");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH 1\r\n"));

             result = oSimulator.SendSingleCommandWithLiteral("A01 SEARCH HEADER SUBJECT {5}", "Test2");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH 2\r\n"));
        }
Esempio n. 16
0
        public void TestSortDeletedOrAnswered()
        {
            Domain oDomain = _application.Domains[0];
             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "aa", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
             oSMTP.Send("*****@*****.**", "*****@*****.**", "bb", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             CustomAssert.AreEqual("", oSimulator.Sort("(DATE) UTF-8 ALL OR ANSWERED DELETED"));
        }
Esempio n. 17
0
        public void TestSortReverseSize()
        {
            Domain oDomain = _application.Domains[0];
             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var longBodyString = new StringBuilder();
             longBodyString.Append('A', 10000);

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", longBodyString.ToString());
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);

             oSMTP.Send("*****@*****.**", "*****@*****.**", "Test2", "Test body");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             CustomAssert.AreEqual("2 1", oSimulator.Sort("(SIZE) UTF-8 ALL"));
             CustomAssert.AreEqual("1 2", oSimulator.Sort("(REVERSE SIZE) UTF-8 ALL"));
        }
Esempio n. 18
0
        public void TestSearchSpecficUID()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             for (int i = 0; i < 5; i++)
            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");

             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 5);

             Messages messages = oAccount.IMAPFolders.get_ItemByName("Inbox").Messages;

             int second = messages[1].UID;
             int third = messages[2].UID;
             int fourth = messages[3].UID;

             var oSimulator = new IMAPClientSimulator();
             oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string result = oSimulator.SendSingleCommand(string.Format("a01 SORT (REVERSE DATE) UTF-8 ALL UID {0},{1}", second, third));
             AssertSortResultContains(result, 2, 3);

             result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0},{1}", third, second));
             AssertSortResultContains(result, 2, 3);

             result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0}:{1}", second, fourth));
             AssertSortResultContains(result, 2, 3, 4);

             result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0}:*", second));
             AssertSortResultContains(result, 2, 3, 4, 5);
        }
Esempio n. 19
0
        public void TestSearchORWithParenthesisSubjectNested()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Test2", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             if (oSimulator.Search("ALL (OR (HEADER SUBJECT \"Test1\") (HEADER SUBJECT \"Test2\"))") != "1 2")
             {
            throw new Exception("ERROR - Search or flag failed");
             }
        }
Esempio n. 20
0
        public void TestSearchOR()
        {
            SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Search test", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             CustomAssert.AreEqual("1", oSimulator.Search("OR SINCE 28-May-2001 ON 28-May-2001 ALL"));
             CustomAssert.IsNullOrEmpty(oSimulator.Search("OR SINCE 28-May-2020 ON 28-May-2012 ALL"));

             string formattedToday = DateTime.Now.ToString("dd-MMM-yyyy", CultureInfo.InvariantCulture).ToUpper();
             CustomAssert.AreEqual("1", oSimulator.Search("OR SINCE 28-May-2017 ON " + formattedToday + " ALL"));

             string formatted2001 = new DateTime(2001, 01, 01).ToString("dd-MMM-yyyy").ToUpper();
             CustomAssert.AreEqual("1", oSimulator.Search("OR SINCE 28-May-2008 ON " + formatted2001 + " ALL"));
        }
Esempio n. 21
0
        public void TestSearchON()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Search test", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string formattedTomorrow =
            (DateTime.Now + new TimeSpan(1, 0, 0, 0)).ToString("dd-MMM-yyyy", CultureInfo.InvariantCulture).ToUpper();
             string formattedToday = DateTime.Now.ToString("dd-MMM-yyyy", CultureInfo.InvariantCulture).ToUpper();

             if (oSimulator.Search("ON " + formattedTomorrow) != "")
             {
            throw new Exception("ERROR - Search or flag failed");
             }

             if (oSimulator.Search("ON " + formattedToday) != "1")
             {
            throw new Exception("ERROR - Search or flag failed");
             }
        }
Esempio n. 22
0
        public void TestSortReverseArrival()
        {
            Domain oDomain = _application.Domains[0];
             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);

             // The two messages needs to be sent a second apart, so we actually need to pause a bit here.

             Thread.Sleep(1000);
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Test2", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             CustomAssert.AreEqual("1 2", oSimulator.Sort("(ARRIVAL) UTF-8 ALL"));
             CustomAssert.AreEqual("2 1", oSimulator.Sort("(REVERSE ARRIVAL) UTF-8 ALL"));
        }
Esempio n. 23
0
        public void TestExamine()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             CustomAssert.IsTrue(oSimulator.CreateFolder("TestFolder"));
             string result = oSimulator.ExamineFolder("TestFolder");

             CustomAssert.IsTrue(result.Contains("[PERMANENTFLAGS ()]"), result);
             CustomAssert.IsTrue(result.Contains("[READ-ONLY]"), result);
        }
Esempio n. 24
0
        public void StlsCommandShouldSwithToTls()
        {
            var imapSimulator = new IMAPClientSimulator(false, 14302);
             imapSimulator.Connect();
             var data = imapSimulator.GetCapabilities();
             imapSimulator.SendSingleCommand("A01 STARTTLS");
             imapSimulator.Handshake();

             // command is sent over TLS.
             imapSimulator.GetCapabilities();

             imapSimulator.Logon(_account.Address, "test");
        }
Esempio n. 25
0
        public void TestListSpecial()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             string response = oSimulator.List("");
             CustomAssert.IsTrue(response.StartsWith("* LIST (\\Noselect) \".\" \"\""));
             oSimulator.Disconnect();

             _settings.IMAPHierarchyDelimiter = "/";

             oSimulator = new IMAPClientSimulator();
             sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             response = oSimulator.List("");
             CustomAssert.IsTrue(response.StartsWith("* LIST (\\Noselect) \"/\" \"\""));
             oSimulator.Disconnect();

             _settings.IMAPHierarchyDelimiter = "\\";

             oSimulator = new IMAPClientSimulator();
             sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             response = oSimulator.List("", false);
             string expectedResponse = "* LIST (\\Noselect) \"\\\\\" \"\"";
             CustomAssert.IsTrue(response.StartsWith(expectedResponse));
             oSimulator.Disconnect();
        }
Esempio n. 26
0
        public void TestSubjectSearchValueWithParanthesis()
        {
            Domain oDomain = _application.Domains[0];
             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Te(st1", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
             oSMTP.Send("*****@*****.**", "*****@*****.**", "Te)st2", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             CustomAssert.AreEqual("1", oSimulator.Sort("(SUBJECT) UTF-8 ALL HEADER SUBJECT \"Te(st1\""));
             CustomAssert.AreEqual("2", oSimulator.Sort("(SUBJECT) UTF-8 ALL HEADER SUBJECT \"Te)st2\""));
        }
Esempio n. 27
0
        public void TestLsubInclusion()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             string folderName = "Folder1";

             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(oAccount.Address, "test");
             CustomAssert.IsTrue(oSimulator.CreateFolder(folderName));
             CustomAssert.IsFalse(oSimulator.LSUB().Contains(folderName));
             CustomAssert.IsTrue(oSimulator.Subscribe(folderName));
             CustomAssert.IsTrue(oSimulator.LSUB().Contains(folderName));

             oSimulator.Disconnect();
        }
Esempio n. 28
0
        public void TestSearchUID()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

             Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             for (int i = 0; i < 3; i++)
            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");

             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 3);

             // There should be 3 UID's, 1,2,3 or similar. No skips in the middle fo them.
             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string result = oSimulator.SendSingleCommand("* UID SEARCH UID 1:*");

             // Potentially, the response is multiline. (UID RESPONSE and an OK line). We only want the first line...
             result = result.Substring(0, result.IndexOf("\r\n"));

             string[] tokens = Strings.Split(result, " ", -1, CompareMethod.Text);

             var uids = new List<int>();
             foreach (string token in tokens)
             {
            int temp;
            if (Int32.TryParse(token, out temp))
            {
               uids.Add(temp);
            }
             }

             CustomAssert.AreEqual(3, uids.Count, result);

             CustomAssert.AreEqual(1, uids[0]);
             CustomAssert.AreEqual(2, uids[1]);
             CustomAssert.AreEqual(3, uids[2]);
        }
Esempio n. 29
0
        public void TestSearchRange()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             for (int i = 0; i < 5; i++)
            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");

             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 5);

             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string result = oSimulator.SendSingleCommand("a01 search 2:4");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH 2 3 4"));

             result = oSimulator.SendSingleCommand("a01 search 3,2");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH 2 3"));

             result = oSimulator.SendSingleCommand("a01 search 3:*");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH 3 4 5"));

             result = oSimulator.SendSingleCommand("a01 search 3,1,3");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH 1 3"));

             result = oSimulator.SendSingleCommand("a01 search 1:*");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH 1 2 3 4 5"));
        }
Esempio n. 30
0
        public void TestSortSubjectSearch()
        {
            Domain oDomain = _application.Domains[0];
             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send("*****@*****.**", "*****@*****.**", "aa", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
             oSMTP.Send("*****@*****.**", "*****@*****.**", "bb", "This is a test of IMAP Search");
             IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

             CustomAssert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT aa HEADER SUBJECT bb"));
             CustomAssert.AreEqual("1 2",
                         oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT aa) (HEADER SUBJECT bb)"));
             CustomAssert.AreEqual("1 2",
                         oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT aa HEADER SUBJECT bb)"));

             CustomAssert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT aa HEADER SUBJECT cc"));
             CustomAssert.AreEqual("1",
                         oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT aa) (HEADER SUBJECT cc)"));
             CustomAssert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT aa HEADER SUBJECT cc)"));

             CustomAssert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT bb HEADER SUBJECT cc"));
             CustomAssert.AreEqual("2",
                         oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT bb) (HEADER SUBJECT cc)"));
             CustomAssert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT bb HEADER SUBJECT cc)"));
        }