Beispiel #1
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 #2
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 #3
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 #4
0
        public void TestDateSortOrderNonexistantDate()
        {
            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\" {4}", "ABCD");

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

            response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 21:00:00 +0200\" {4}",
                                                               "ABCD");
            CustomAssert.IsTrue(response.Contains("* 2 EXISTS"), response);

            response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 20:00:00 +0200\" {4}",
                                                               "ABCD");
            CustomAssert.IsTrue(response.Contains("* 3 EXISTS"), response);

            response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"23-Feb-2008 01:30:23 +0200\" {4}",
                                                               "ABCD");
            CustomAssert.IsTrue(response.Contains("* 4 EXISTS"), response);

            /*
             * RFC 5256 "2.2. Sent Date" chapter. If the sent date cannot be determined (a Date: header is missing or cannot be parsed),
             * the INTERNALDATE for that message is used as the sent date.
             */

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

            CustomAssert.IsTrue(sortArivalDateResponse.Contains(" 3 2 1 4"));
            CustomAssert.AreEqual(sortDateResponse, sortArivalDateResponse);
            oSimulator.Disconnect();
        }
Beispiel #5
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 #6
0
        public void ConfirmFileAddedToCorrectPublicFolder()
        {
            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);

            IMAPFolders folders = _application.Settings.PublicFolders;
            IMAPFolder  folder  = folders.Add("Share");

            folder.Save();

            // Give everyone access to the folder.
            IMAPFolderPermission permission = folder.Permissions.Add();

            permission.PermissionType = eACLPermissionType.ePermissionTypeAnyone;
            permission.set_Permission(eACLPermission.ePermissionLookup, true);
            permission.set_Permission(eACLPermission.ePermissionRead, true);
            permission.set_Permission(eACLPermission.ePermissionInsert, true);
            permission.Save();

            // Add the message to the public folder.
            oSimulator.Connect();
            oSimulator.LogonWithLiteral("*****@*****.**", "test");
            oSimulator.SendSingleCommandWithLiteral("A01 APPEND #Public.Share {4}", "ABCD");

            // Confirm that the message exists in the public folder and not in the inbox.
            CustomAssert.AreEqual(1, oSimulator.GetMessageCount("#Public.Share"));
            CustomAssert.AreEqual(0, oSimulator.GetMessageCount("INBOX"));
            oSimulator.Disconnect();


            // The public directory should now contain the message.
            testSetup.AssertFilesInDirectory(publicDir, 1);

            // There users directory should still be empty.
            testSetup.AssertFilesInUserDirectory(oAccount, 0);
        }
Beispiel #7
0
        public void TestGlobalMaxMessageSizeLimitEnabled()
        {
            Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test", 0);

            var message = new StringBuilder();

            // ~2 kb string
            for (int i = 0; i < 25; i++)
            {
                message.AppendLine(
                    "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
            }

            _settings.MaxMessageSize = 1;

            var    imapSim = new IMAPClientSimulator("*****@*****.**", "test", "INBOX");
            string result  = imapSim.SendSingleCommandWithLiteral("A01 APPEND INBOX {" + message.Length + "}",
                                                                  message.ToString());

            imapSim.Logout();

            CustomAssert.IsTrue(result.StartsWith("A01 NO Message size exceeds fixed maximum message size."));
        }