Ejemplo n.º 1
0
        public void TestDateSortOrderNonexistantDate()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");
             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.LogonWithLiteral("*****@*****.**", "test");
             Assert.IsTrue(oSimulator.SelectFolder("Inbox"));

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

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

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

             response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"23-Feb-2008 01:30:23 +0200\" {4}", "ABCD");
             Assert.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");

             Assert.IsTrue(sortArivalDateResponse.Contains(" 3 2 1 4"));
             Assert.AreEqual(sortDateResponse, sortArivalDateResponse);
             oSimulator.Disconnect();
        }
Ejemplo n.º 2
0
        public void TestNestedOrSearch()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

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

            // Send a message to this account.
            SMTPClientSimulator oSMTP = new SMTPClientSimulator();

            oSMTP.Send("*****@*****.**", "*****@*****.**", "Search test", "This is a test of IMAP Search");

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

            IMAPSimulator oSimulator      = new IMAPSimulator();
            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");

            Assert.IsTrue(result.StartsWith("* SEARCH 1"), result);

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

            result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SMALLER 1 LARGER 10000 SMALLER 10000");
            Assert.IsTrue(result.StartsWith("* SEARCH 1\r\n"), result);
        }
Ejemplo n.º 3
0
        public void TestNestedOrSearch()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

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

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

              IMAPSimulator oSimulator = new IMAPSimulator();
              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");
              Assert.IsTrue(result.StartsWith("* SEARCH 1"), result);

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

              result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SMALLER 1 LARGER 10000 SMALLER 10000");
              Assert.IsTrue(result.StartsWith("* SEARCH 1\r\n"), result);
        }
Ejemplo n.º 4
0
        public void SendExploitFile(string file, bool sendAllAtOnce)
        {
            IMAPSimulator sim = ConnectAndLogon();

            string contents = File.ReadAllText(file);

            if (sendAllAtOnce)
            {
                sim.Send(contents);
            }
            else
            {
                string[] commands = Microsoft.VisualBasic.Strings.Split(contents, Environment.NewLine, 1000000, Microsoft.VisualBasic.CompareMethod.Text);
                foreach (string command in commands)
                {
                    try
                    {
                        sim.SendSingleCommand(command);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        sim = ConnectAndLogon();
                    }
                }
            }

            sim.Disconnect();
        }
Ejemplo n.º 5
0
        public void TestDateSortOrder()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.LogonWithLiteral("*****@*****.**", "test");
            Assert.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");

            Assert.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");
            Assert.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");
            Assert.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");
            Assert.IsTrue(response.Contains("* 4 EXISTS"), response);

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

            Assert.IsTrue(sortDateResponse.Contains(" 4 3 1 2"));
            oSimulator.Disconnect();
        }
Ejemplo n.º 6
0
        public void TestDateSortOrder()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");
             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.LogonWithLiteral("*****@*****.**", "test");
             Assert.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");
             Assert.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");
             Assert.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");
             Assert.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");
             Assert.IsTrue(response.Contains("* 4 EXISTS"), response);

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

             Assert.IsTrue(sortDateResponse.Contains(" 4 3 1 2"));
             oSimulator.Disconnect();
        }
Ejemplo n.º 7
0
        public void Test()
        {
            IMAPSimulator sim = new IMAPSimulator();

            sim.ConnectAndLogon("*****@*****.**", "test");
            sim.SelectFolder("Inbox");

            Stopwatch watch = new Stopwatch();

            watch.Start();
            string result = sim.SendSingleCommand("A282 SORT (SIZE) UTF-8");

            watch.Stop();

            long sortSizeTime = watch.ElapsedMilliseconds;

            watch.Reset();

            watch.Start();
            result = sim.SendSingleCommand("A282 SORT (FROM) UTF-8");
            watch.Stop();

            long sortFromTime = watch.ElapsedMilliseconds;

            watch.Reset();

            watch.Start();
            result = sim.SendSingleCommand("A282 SORT (FROM) UTF-8 1:15");
            watch.Stop();

            long sortFromTimeLimit15 = watch.ElapsedMilliseconds;

            watch.Reset();

            watch.Start();
            result = sim.SendSingleCommand("A282 SORT (DATE) UTF-8");
            watch.Stop();

            long sortDateTime = watch.ElapsedMilliseconds;

            watch.Reset();

            System.Threading.Thread.Sleep(1);
        }
Ejemplo n.º 8
0
        public void TestSearchSpecficUID()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

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

            // Send a message to this account.
            SMTPClientSimulator oSMTP = new SMTPClientSimulator();

            for (int i = 0; i < 5; i++)
            {
                oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            }

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

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

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


            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

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

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

            Assert.IsTrue(result.StartsWith("* SORT 3 2"));

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

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

            result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0}:*", second));
            Assert.IsTrue(result.StartsWith("* SORT 2 3 4 5"));
        }
Ejemplo n.º 9
0
        public void TestSearchRange()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

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

            // Send a message to this account.
            SMTPClientSimulator oSMTP = new SMTPClientSimulator();

            for (int i = 0; i < 5; i++)
            {
                oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            }

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

            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

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

            string result = oSimulator.SendSingleCommand("a01 search 2:4");

            Assert.IsTrue(result.StartsWith("* SEARCH 2 3 4"));

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

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

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

            result = oSimulator.SendSingleCommand("a01 search 1:*");
            Assert.IsTrue(result.StartsWith("* SEARCH 1 2 3 4 5"));
        }
Ejemplo n.º 10
0
        public void TestDateSortOrderNonexistantDate()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

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

            string response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 22:00:00 +0200\" {4}", "ABCD");

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

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

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

            response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"23-Feb-2008 01:30:23 +0200\" {4}", "ABCD");
            Assert.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");

            Assert.IsTrue(sortArivalDateResponse.Contains(" 3 2 1 4"));
            Assert.AreEqual(sortDateResponse, sortArivalDateResponse);
            oSimulator.Disconnect();
        }
Ejemplo n.º 11
0
        public void TestSearchUID()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

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

            // Send a message to this account.
            SMTPClientSimulator oSMTP = new SMTPClientSimulator();

            for (int i = 0; i < 3; i++)
            {
                oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            }

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

            // There should be 3 UID's, 1,2,3 or similar. No skips in the middle fo them.
            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon("*****@*****.**", "test");
            Assert.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 = Microsoft.VisualBasic.Strings.Split(result, " ", -1, Microsoft.VisualBasic.CompareMethod.Text);

            List <int> uids = new List <int>();

            foreach (string token in tokens)
            {
                int temp;
                if (Int32.TryParse(token, out temp))
                {
                    uids.Add(temp);
                }
            }

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

            Assert.AreEqual(1, uids[0]);
            Assert.AreEqual(2, uids[1]);
            Assert.AreEqual(3, uids[2]);
        }
Ejemplo n.º 12
0
        public void TestSearchInvalidCharset()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            SMTPClientSimulator.StaticSend(account.Address, account.Address, "MySubject", "MyBody");

            POP3Simulator.AssertMessageCount(account.Address, "test", 1);

            IMAPSimulator oSimulator = new IMAPSimulator();

            Assert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
            Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

            string result = oSimulator.SendSingleCommand("A01 SEARCH CHARSET NONEXISTANT ALL SUBJECT MySubject");

            Assert.AreEqual("A01 NO [BADCHARSET]\r\n", result);
        }
Ejemplo n.º 13
0
        public void TestAuthenticate()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

              IMAPSimulator oSimulator = new IMAPSimulator();

              string sWelcomeMessage = oSimulator.Connect();
              string result = oSimulator.SendSingleCommand("A01 AUTHENTICATE");
              Assert.IsTrue(result.Contains("NO Unsupported authentication mechanism."));
              oSimulator.Disconnect();
        }
Ejemplo n.º 14
0
        public void TestSearchSpecficUID()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

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

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

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

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

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

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

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

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

             result = oSimulator.SendSingleCommand(string.Format("a01 SORT (DATE) UTF-8 ALL UID {0}:*", second));
             Assert.IsTrue(result.StartsWith("* SORT 2 3 4 5"));
        }
Ejemplo n.º 15
0
        public void TestSearchUID()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

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

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

             // There should be 3 UID's, 1,2,3 or similar. No skips in the middle fo them.
             IMAPSimulator oSimulator = new IMAPSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             Assert.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 = Microsoft.VisualBasic.Strings.Split(result, " ", -1, Microsoft.VisualBasic.CompareMethod.Text);

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

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

             Assert.AreEqual(1, uids[0]);
             Assert.AreEqual(2, uids[1]);
             Assert.AreEqual(3, uids[2]);
        }
Ejemplo n.º 16
0
        public void TestUnseenResponseInSelect()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             SMTPClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestMessage");

             IMAPSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);

             IMAPSimulator sim = new IMAPSimulator();
             Assert.IsTrue(sim.ConnectAndLogon(account.Address, "test"));
             Assert.IsTrue(sim.SelectFolder("Inbox"));
             Assert.IsTrue(sim.CreateFolder("Dummy"));
             Assert.IsTrue(sim.Copy(1, "Dummy"));

             string result = sim.SendSingleCommand("a01 select Dummy");
             Assert.IsTrue(result.Contains("* 1 EXISTS\r\n* 1 RECENT"), result);

             string searchResponse = sim.SendSingleCommand("srch1 SEARCH ALL UNSEEN");

             // We should have at least one message here.
             Assert.IsTrue(searchResponse.Contains("* SEARCH 1\r\n"), searchResponse);

             // Now fetch the body.
             string bodyText = sim.Fetch("1 BODY[TEXT]");

             // Now the message is no longer unseen. Confirm this.
             searchResponse = sim.SendSingleCommand("srch1 SEARCH ALL UNSEEN");
             Assert.IsTrue(searchResponse.Contains("* SEARCH\r\n"), searchResponse);

             // Close the messages to mark them as no longer recent.
             Assert.IsTrue(sim.Close());

             result = sim.SendSingleCommand("a01 select Dummy");
             Assert.IsTrue(result.Contains("* 1 EXISTS\r\n* 0 RECENT"), result);
        }
Ejemplo n.º 17
0
        public void TestSearchRange()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

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

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

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

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

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

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

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

              result = oSimulator.SendSingleCommand("a01 search 1:*");
              Assert.IsTrue(result.StartsWith("* SEARCH 1 2 3 4 5"));
        }
Ejemplo n.º 18
0
        public void TestSearchInvalidCharset()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             SMTPClientSimulator.StaticSend(account.Address, account.Address, "MySubject", "MyBody");

             POP3Simulator.AssertMessageCount(account.Address, "test", 1);

             IMAPSimulator oSimulator = new IMAPSimulator();
             Assert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
             Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

             string result = oSimulator.SendSingleCommand("A01 SEARCH CHARSET NONEXISTANT ALL SUBJECT MySubject");
             Assert.AreEqual("A01 NO [BADCHARSET]\r\n", result);
        }
Ejemplo n.º 19
0
        public void TestRecentRemovedOnMailboxClose()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             SMTPClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestMessage");
             IMAPSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);

             IMAPSimulator sim = new IMAPSimulator();
             Assert.IsTrue(sim.ConnectAndLogon(account.Address, "test"));
             Assert.IsTrue(sim.SelectFolder("Inbox"));
             Assert.IsTrue(sim.CreateFolder("Dummy"));
             Assert.IsTrue(sim.Copy(1, "Dummy"));
             string result = sim.SendSingleCommand("a01 select Dummy");
             Assert.IsTrue(result.Contains("* 1 EXISTS\r\n* 1 RECENT"), result);
             Assert.IsTrue(sim.Logout());

             sim = new IMAPSimulator();
             Assert.IsTrue(sim.ConnectAndLogon(account.Address, "test"));
             result = sim.SendSingleCommand("a01 select Dummy");
             Assert.IsFalse(result.Contains("* 1 EXISTS\r\n* 1 RECENT"), result);
             Assert.IsTrue(sim.Logout());
        }