Beispiel #1
0
        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"));
        }
Beispiel #2
0
        public void TestFetchHeaderFieldsNot()
        {
            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: Something" + 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.NOT (Subject From)]");

            oSimulator.Disconnect();


            CustomAssert.IsTrue(result.Contains("Received:"), result);
            CustomAssert.IsFalse(result.Contains("Subject:"), result);
            CustomAssert.IsFalse(result.Contains("From:"), result);
            // The feedback should end with an empty header line.
            CustomAssert.IsTrue(result.Contains("\r\n\r\n)"), result);
        }
Beispiel #3
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();
        }
Beispiel #4
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"));
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public void TestSubjectSearchMultipleMatches()
        {
            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);
            oSMTP.Send("*****@*****.**", "*****@*****.**", "TestA", "This is a test of IMAP Search");
            IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);
            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            IMAPClientSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 3);

            var oSimulator = new IMAPClientSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon("*****@*****.**", "test");
            CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

            CustomAssert.AreEqual("1 3", oSimulator.Sort("(SUBJECT) UTF-8 ALL HEADER SUBJECT \"Test1\""));
            CustomAssert.AreEqual("2", oSimulator.Sort("(SUBJECT) UTF-8 ALL HEADER SUBJECT \"TestA\""));
            CustomAssert.AreEqual("3 1", oSimulator.Sort("(REVERSE SUBJECT) UTF-8 ALL HEADER SUBJECT \"Test1\""));
            CustomAssert.AreEqual("2", oSimulator.Sort("(REVERSE SUBJECT) UTF-8 ALL HEADER SUBJECT \"TestA\""));
            CustomAssert.AreEqual("3 1", oSimulator.Sort("(REVERSE SUBJECT) UTF-8 ALL (HEADER SUBJECT) \"Test1\""));
            CustomAssert.AreEqual("2", oSimulator.Sort("(REVERSE SUBJECT) UTF-8 ALL (HEADER SUBJECT) \"TestA\""));
        }
Beispiel #7
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");
            }
        }
Beispiel #8
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)"));
        }
Beispiel #9
0
        public void TestDateSortOrder()
        {
            Account oAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            var oSimulator = new IMAPClientSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.LogonWithLiteral("*****@*****.**", "test");
            CustomAssert.IsTrue(oSimulator.SelectFolder("Inbox"));

            string response =
                oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 22:00:00 +0200\" {37}",
                                                        "Date: Wed, 15 Dec 2010 13:00:00 +0000");

            CustomAssert.IsTrue(response.Contains("* 1 EXISTS"), response);

            response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 21:00:00 +0200\" {37}",
                                                               "Date: Wed, 15 Dec 2010 14:00:00 +0000");
            CustomAssert.IsTrue(response.Contains("* 2 EXISTS"), response);

            response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 20:00:00 +0200\" {37}",
                                                               "Date: Wed, 15 Dec 2010 12:00:00 +0000");
            CustomAssert.IsTrue(response.Contains("* 3 EXISTS"), response);

            response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"23-Feb-2008 01:30:23 +0200\" {37}",
                                                               "Date: Wed, 15 Dec 2010 11:00:00 +0000");
            CustomAssert.IsTrue(response.Contains("* 4 EXISTS"), response);

            string sortDateResponse = oSimulator.SendSingleCommand("A10 SORT (DATE) US-ASCII ALL");

            CustomAssert.IsTrue(sortDateResponse.Contains(" 4 3 1 2"));
            oSimulator.Disconnect();
        }
Beispiel #10
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"));
        }
Beispiel #11
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"));
        }
Beispiel #12
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");
            }
        }
Beispiel #13
0
        public void TestTryCreateInvalidStructure()
        {
            Account oAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            var oSimulator = new IMAPClientSimulator();

            oSimulator.Connect();
            oSimulator.LogonWithLiteral(oAccount.Address, "test");
            CustomAssert.IsTrue(oSimulator.CreateFolder("1.2.3"));
            CustomAssert.IsTrue(oSimulator.CreateFolder("1.2.3.4"));

            // Should fail because name taken.
            CustomAssert.IsFalse(oSimulator.RenameFolder("1.2.3.4", "1.2.3"));
            CustomAssert.IsFalse(oSimulator.RenameFolder("1.2.3.4", "1.2"));
            CustomAssert.IsFalse(oSimulator.RenameFolder("1.2.3.4", "1"));

            // Should fail because invalid destination name.
            CustomAssert.IsFalse(oSimulator.RenameFolder("1.2.3.4", ""));

            // Should fail because destination name taken.
            CustomAssert.IsFalse(oSimulator.RenameFolder("1.2.3", "1.2.3.4"));
            CustomAssert.IsFalse(oSimulator.RenameFolder("1.2", "1.2.3.4"));
            CustomAssert.IsFalse(oSimulator.RenameFolder("1", "1.2.3.4"));

            CustomAssert.IsFalse(oSimulator.RenameFolder("1.2.3", "1.2"));
            CustomAssert.IsFalse(oSimulator.RenameFolder("1.2.3", "1"));

            CustomAssert.IsTrue(oSimulator.RenameFolder("1.2.3", "A"));

            oSimulator.Disconnect();
        }
Beispiel #14
0
        public void TestCreateLongFolder()
        {
            Account oAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            var oSimulator = new IMAPClientSimulator();

            oSimulator.Connect();
            oSimulator.LogonWithLiteral(oAccount.Address, "test");

            string folderName = "";

            for (int i = 0; i < 255; i++)
            {
                folderName = folderName + "A";
            }

            string result = oSimulator.Send("A01 CREATE " + folderName);

            CustomAssert.IsTrue(result.Contains("A01 OK"));
            CustomAssert.IsTrue(oSimulator.SelectFolder(folderName));

            folderName = "";
            for (int i = 0; i < 256; i++)
            {
                folderName = folderName + "A";
            }

            result = oSimulator.Send("A01 CREATE " + folderName);
            CustomAssert.IsTrue(result.Contains("A01 NO"));
            CustomAssert.IsFalse(oSimulator.SelectFolder(folderName));

            oSimulator.Disconnect();
        }
        public void TestHierarchyDelimiterLsubResponse()
        {
            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));
            CustomAssert.IsTrue(oSimulator.Subscribe("Test"));
            CustomAssert.IsTrue(oSimulator.Subscribe("Test/Test"));
            string lsubResponse = oSimulator.LSUB();

            CustomAssert.IsTrue(lsubResponse.Contains("\"Test/Test\""));
            CustomAssert.IsTrue(lsubResponse.Contains("\"Test\""));
            oSimulator.Disconnect();
        }
Beispiel #16
0
        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);
        }
Beispiel #17
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"));
        }
Beispiel #18
0
        public void TestFetchEnvelopeWithDateContainingQuote()
        {
            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: Something" + Environment.NewLine +
                             Environment.NewLine +
                             "Hello" + Environment.NewLine;

            var smtpSimulator = new SMTPClientSimulator();

            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 ENVELOPE");

            oSimulator.Disconnect();

            CustomAssert.IsTrue(result.Contains("Wed, 22 Apr 2009 11:05:09 GMT"));
        }
Beispiel #19
0
        public void IfInReplyToFieldContainsQuoteThenFetchHeadersShouldEncodeIt()
        {
            Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string message = "From: Someone <*****@*****.**>" + Environment.NewLine +
                             "To: Someoen <*****@*****.**>" + Environment.NewLine +
                             "In-Reply-To: ShouldBeEncodedDueToQuote\"" + Environment.NewLine +
                             "Subject: Something" + Environment.NewLine +
                             Environment.NewLine +
                             "Hello" + Environment.NewLine;

            var smtpSimulator = new SMTPClientSimulator();

            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 ENVELOPE");

            oSimulator.Disconnect();

            CustomAssert.IsFalse(result.Contains("ShouldBeEncodedDueToQuote"));
        }
Beispiel #20
0
        public void TestIMAPServerLiteral()
        {
            var sim = new IMAPClientSimulator();

            sim.Connect();
            CustomAssert.IsTrue(sim.Send("a01 login " + GetUsername() + " {4}").StartsWith("+"));
            sim.Send(GetPassword());
            EnsureNoPassword();
        }
Beispiel #21
0
        public void IfStartTlsIsEnabledStartTlsShouldBeShownInEhloResponse()
        {
            var imapSimulator = new IMAPClientSimulator(false, 14302);

            imapSimulator.Connect();
            var data = imapSimulator.GetCapabilities();

            CustomAssert.IsTrue(data.Contains("STARTTLS"));
        }
Beispiel #22
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();
        }
Beispiel #23
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."));
        }
Beispiel #24
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"));
        }
Beispiel #25
0
        public void TestAppend()
        {
            Account oAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            var oSimulator = new IMAPClientSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.LogonWithLiteral("*****@*****.**", "test");
            oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX {4}", "ABCD");
            CustomAssert.AreEqual(1, oSimulator.GetMessageCount("INBOX"));
            oSimulator.Disconnect();
        }
Beispiel #26
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();
        }
Beispiel #27
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();
        }
Beispiel #28
0
        public void TestCreateDeepFolder()
        {
            Account oAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            var oSimulator = new IMAPClientSimulator();

            oSimulator.Connect();
            oSimulator.LogonWithLiteral(oAccount.Address, "test");
            string result =
                oSimulator.Send("A01 CREATE 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26");

            CustomAssert.IsTrue(result.Contains("A01 NO"));

            oSimulator.Disconnect();
        }
Beispiel #29
0
        public void TestRenameToAndFromINBOX()
        {
            Account oAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            var oSimulator = new IMAPClientSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.LogonWithLiteral(oAccount.Address, "test");
            oSimulator.Send("A01 CREATE A\r\n");
            CustomAssert.IsFalse(oSimulator.RenameFolder("A", "INBOX"));
            CustomAssert.IsFalse(oSimulator.RenameFolder("INBOX", "B"));

            oSimulator.Disconnect();
        }
Beispiel #30
0
        public void TestFolderQuote()
        {
            Account oAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            const string folderName = "Test*";

            var    oSimulator      = new IMAPClientSimulator();
            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon(oAccount.Address, "test");
            CustomAssert.IsTrue(oSimulator.CreateFolder(folderName));
            CustomAssert.IsTrue(oSimulator.Subscribe(folderName));
            CustomAssert.IsTrue(oSimulator.LSUB().Contains("\"" + folderName + "\""));
            oSimulator.Disconnect();
        }