Beispiel #1
0
        public void TestCreateLongFolder()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = 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);

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

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

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

            oSimulator.Disconnect();
        }
Beispiel #2
0
        public void TestSearchORWithLiterals3()
        {
            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("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test2", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon("*****@*****.**", "test");

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

            string result = oSimulator.Send("A01 SEARCH ALL OR (HEADER SUBJECT {5}");

            result = oSimulator.Send("Test5) (HEADER SUBJECT {5}");
            result = oSimulator.Send("Test2)");
            Assert.IsTrue(result.StartsWith("* SEARCH 2"));
        }
 public void TestIMAPServerLiteral()
 {
     IMAPSimulator sim = new IMAPSimulator();
     sim.Connect();
     Assert.IsTrue(sim.Send("a01 login " + GetUsername() + " {4}").StartsWith("+"));
     sim.Send(GetPassword());
     EnsureNoPassword();
 }
        public void TestIMAPServerLiteral()
        {
            IMAPSimulator sim = new IMAPSimulator();

            sim.Connect();
            Assert.IsTrue(sim.Send("a01 login " + GetUsername() + " {4}").StartsWith("+"));
            sim.Send(GetPassword());
            EnsureNoPassword();
        }
Beispiel #5
0
        public void TestRenameIncorrectParameters()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

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

            result = oSimulator.Send("A02 RENAME A B C");
            Assert.IsTrue(result.Contains("A02 BAD"));

            oSimulator.Disconnect();
        }
Beispiel #6
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();
        }
Beispiel #7
0
        public void TestCreateParallelFolder()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

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

            Assert.IsTrue(result.Contains("A01 OK"));
            result = oSimulator.Send("A01 CREATE 1.2.4");
            Assert.IsTrue(result.Contains("A01 OK"));

            oSimulator.Disconnect();
        }
Beispiel #8
0
        public void TestCreateDeepFolder()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = 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");
             Assert.IsTrue(result.Contains("A01 NO"));

             oSimulator.Disconnect();
        }
Beispiel #9
0
        public void TestCreateDeepFolder()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = 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");

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

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

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

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

            oSimulator.Disconnect();
        }
Beispiel #11
0
        public void TestHierarchyDelimiterNamespaceResponse()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

            hMailServer.Settings settings = _settings;
            settings.IMAPHierarchyDelimiter = "\\";
            string publicFolderName = _settings.IMAPPublicFolderName;

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

            IMAPSimulator oSimulator = new IMAPSimulator();

            oSimulator.ConnectAndLogon(account.Address, "test");
            string result = oSimulator.Send("A01 NAMESPACE");
            string correctNamespaceSetting = "* NAMESPACE ((\"\" \"\\\\\")) NIL ((\"" + publicFolderName + "\" \"\\\\\"))";

            Assert.IsTrue(result.Contains(correctNamespaceSetting), result);
            oSimulator.Disconnect();

            settings.IMAPHierarchyDelimiter = ".";

            oSimulator = new IMAPSimulator();
            oSimulator.ConnectAndLogon(account.Address, "test");

            result = oSimulator.Send("A01 NAMESPACE");
            correctNamespaceSetting = "* NAMESPACE ((\"\" \".\")) NIL ((\"" + publicFolderName + "\" \".\"))";
            Assert.IsTrue(result.Contains(correctNamespaceSetting), result);
            oSimulator.Disconnect();

            settings.IMAPHierarchyDelimiter = "/";

            oSimulator = new IMAPSimulator();
            oSimulator.ConnectAndLogon(account.Address, "test");

            result = oSimulator.Send("A01 NAMESPACE");
            correctNamespaceSetting = "* NAMESPACE ((\"\" \"/\")) NIL ((\"" + publicFolderName + "\" \"/\"))";
            Assert.IsTrue(result.Contains(correctNamespaceSetting), result);
            oSimulator.Disconnect();
        }
Beispiel #12
0
        public void TestLongIMAPCommand()
        {
            IMAPSimulator sim = ConnectAndLogon();

            // build a large string.
            StringBuilder sb = new StringBuilder();

            sb.Append("A01");
            for (int i = 0; i < 1000000; i++)
            {
                sb.Append("01234567890");
            }
            int length = sb.Length;

            sb.Append(Environment.NewLine);

            string result = sim.Send(sb.ToString());

            Assert.IsTrue(result.StartsWith("* BYE Excessive amount of data sent to server."));

            sim.Disconnect();
        }
Beispiel #13
0
        public void TestFolderNamesWithUnicodeChars()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.LogonWithLiteral("*****@*****.**", "test");
             oSimulator.Send("A01 CREATE &AMQAxADEAMQAxADEAMQAxADEAMQAxADEAMQ-\r\n");
             oSimulator.Disconnect();

             string s = oAccount.IMAPFolders[1].Name;
             Assert.AreEqual("ÄÄÄÄÄÄÄÄÄÄÄÄÄ", s);
        }
Beispiel #14
0
        public void TestCreateLongFolder()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = 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);
             Assert.IsTrue(result.Contains("A01 OK"));
             Assert.IsTrue(oSimulator.SelectFolder(folderName));

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

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

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

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.LogonWithLiteral(oAccount.Address, "test");
             oSimulator.Send("A01 CREATE A\r\n");
             Assert.IsFalse(oSimulator.RenameFolder("A", "INBOX"));
             Assert.IsFalse(oSimulator.RenameFolder("INBOX", "B"));

             oSimulator.Disconnect();
        }
Beispiel #16
0
        public void TestRenameIncorrectParameters()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

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

             result = oSimulator.Send("A02 RENAME A B C");
             Assert.IsTrue(result.Contains("A02 BAD"));

             oSimulator.Disconnect();
        }
Beispiel #17
0
        public void TestCreateUnnamedSubFolder()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.LogonWithLiteral(oAccount.Address, "test");
             string result = oSimulator.Send("A01 CREATE 1..3");
             Assert.IsTrue(result.Contains("A01 NO"));
             result = oSimulator.Send("A01 CREATE 1....3");
             Assert.IsTrue(result.Contains("A01 NO"));
             result = oSimulator.Send("A01 CREATE 1.......3");
             Assert.IsTrue(result.Contains("A01 NO"));

             oSimulator.Disconnect();
        }
Beispiel #18
0
        public void TestLiterals()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             string result = oSimulator.Send("A01 CREATE {4}");
             result = oSimulator.Send("HEJS");

             oSimulator.Disconnect();
        }
Beispiel #19
0
        public void TestOutOfBounds()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

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

             string s = oSimulator.Send("A01 RENAME TEST");
             if (s.StartsWith("A01 BAD") == false)
            throw new Exception("ERROR - Out of bounds test failed");
        }
        public void TestHierarchyDelimiterNamespaceResponse()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();
            hMailServer.Settings settings = _settings;
            settings.IMAPHierarchyDelimiter = "\\";
            string publicFolderName = _settings.IMAPPublicFolderName;

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

            IMAPSimulator oSimulator = new IMAPSimulator();
            oSimulator.ConnectAndLogon(account.Address, "test");
            string result = oSimulator.Send("A01 NAMESPACE");
            string correctNamespaceSetting = "* NAMESPACE ((\"\" \"\\\\\")) NIL ((\"" + publicFolderName + "\" \"\\\\\"))";
            Assert.IsTrue(result.Contains(correctNamespaceSetting), result);
            oSimulator.Disconnect();

            settings.IMAPHierarchyDelimiter = ".";

            oSimulator = new IMAPSimulator();
            oSimulator.ConnectAndLogon(account.Address, "test");

            result = oSimulator.Send("A01 NAMESPACE");
            correctNamespaceSetting = "* NAMESPACE ((\"\" \".\")) NIL ((\"" + publicFolderName + "\" \".\"))";
            Assert.IsTrue(result.Contains(correctNamespaceSetting), result);
            oSimulator.Disconnect();

            settings.IMAPHierarchyDelimiter = "/";

            oSimulator = new IMAPSimulator();
            oSimulator.ConnectAndLogon(account.Address, "test");

            result = oSimulator.Send("A01 NAMESPACE");
            correctNamespaceSetting = "* NAMESPACE ((\"\" \"/\")) NIL ((\"" + publicFolderName + "\" \"/\"))";
            Assert.IsTrue(result.Contains(correctNamespaceSetting), result);
            oSimulator.Disconnect();
        }
Beispiel #21
0
        public void TestList()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             string result = oSimulator.Send("A01 LIST \"\" \"*\"\r\n").Substring(0, 1);
             Assert.AreEqual("*", result);
        }
Beispiel #22
0
        public void TestNamespace()
        {
            string imapFolderName = _settings.IMAPPublicFolderName;

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

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             string result = oSimulator.Send("A01 NAMESPACE");

             string correctNamespaceSetting = "* NAMESPACE ((\"\" \".\")) NIL ((\"" + imapFolderName + "\" \".\"))";

             if (!result.Contains(correctNamespaceSetting))
             {
            Assert.Fail("Namespace failed");
             }
        }
Beispiel #23
0
        public void TestSearchORWithLiterals3()
        {
            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("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
              IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
              oSMTP.Send("*****@*****.**", "*****@*****.**", "Test2", "This is a test of IMAP Search");
              IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

              IMAPSimulator oSimulator = new IMAPSimulator();

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

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

              string result = oSimulator.Send("A01 SEARCH ALL OR (HEADER SUBJECT {5}");
              result = oSimulator.Send("Test5) (HEADER SUBJECT {5}");
              result = oSimulator.Send("Test2)");
              Assert.IsTrue(result.StartsWith("* SEARCH 2"));
        }