Exemplo n.º 1
0
        public void ConfirmFileAddedToCorrectAccountFolder()
        {
            Utilities utilities = SingletonProvider <Utilities> .Instance;

            hMailServer.Account oAccount   = utilities.AddAccount(_domain, "*****@*****.**", "test");
            IMAPSimulator       oSimulator = new IMAPSimulator();

            // Confirm that the public folder is empty before we start our test.
            string publicDir = utilities.GetPublicDirectory();

            utilities.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.
            Assert.AreEqual(1, oSimulator.GetMessageCount("INBOX"));
            oSimulator.Disconnect();

            // The public directory should still be empty - the message was added to the user account.
            utilities.AssertFilesInDirectory(publicDir, 0);

            // There should be a single file in the users directory.
            utilities.AssertFilesInUserDirectory(oAccount, 1);
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
        public void FolderMarkedAsReadOnlyWhenUserHasReadOnlyRights()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

             hMailServer.IMAPFolders publicFolders = _settings.PublicFolders;
             hMailServer.IMAPFolder folder = publicFolders.Add("Share1");
             folder.Save();

             hMailServer.IMAPFolderPermission permission = folder.Permissions.Add();
             permission.PermissionAccountID = account1.ID;
             permission.PermissionType = hMailServer.eACLPermissionType.ePermissionTypeUser;
             permission.set_Permission(hMailServer.eACLPermission.ePermissionLookup, true);
             permission.set_Permission(hMailServer.eACLPermission.ePermissionRead, true);
             permission.Save();

             string selectResult = string.Empty;

             IMAPSimulator oSimulator1 = new IMAPSimulator();
             oSimulator1.Connect();
             oSimulator1.LogonWithLiteral(account1.Address, "test");
             oSimulator1.SelectFolder("#Public.Share1", out selectResult);
             oSimulator1.Disconnect();

             Assert.IsTrue(selectResult.Contains("[READ-ONLY]"), selectResult);
             Assert.IsFalse(selectResult.Contains("[READ-WRITE]"), selectResult);
        }
Exemplo n.º 5
0
        public void ExamineFolderRequiresReadPermission()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

             hMailServer.IMAPFolders publicFolders = _settings.PublicFolders;
             hMailServer.IMAPFolder folder = publicFolders.Add("Share1");
             folder.Save();

             hMailServer.IMAPFolderPermission permission = folder.Permissions.Add();
             permission.PermissionAccountID = account1.ID;
             permission.PermissionType = hMailServer.eACLPermissionType.ePermissionTypeUser;
             permission.set_Permission(hMailServer.eACLPermission.ePermissionLookup, true);
             permission.Save();

             string selectResult = string.Empty;

             IMAPSimulator oSimulator1 = new IMAPSimulator();
             oSimulator1.Connect();
             oSimulator1.LogonWithLiteral(account1.Address, "test");
             string examineResult = oSimulator1.ExamineFolder("#Public.Share1");
             oSimulator1.Disconnect();

             Assert.IsTrue(examineResult.Contains("ACL: Read permission denied (Required for EXAMINE command)."), examineResult);
        }
Exemplo n.º 6
0
        public void ConfirmFileAddedToCorrectAccountFolder()
        {
            Utilities utilities = SingletonProvider<Utilities>.Instance;
            hMailServer.Account oAccount = utilities.AddAccount(_domain, "*****@*****.**", "test");
            IMAPSimulator oSimulator = new IMAPSimulator();

            // Confirm that the public folder is empty before we start our test.
            string publicDir = utilities.GetPublicDirectory();
            utilities.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.
            Assert.AreEqual(1, oSimulator.GetMessageCount("INBOX"));
            oSimulator.Disconnect();

            // The public directory should still be empty - the message was added to the user account.
            utilities.AssertFilesInDirectory(publicDir, 0);

            // There should be a single file in the users directory.
            utilities.AssertFilesInUserDirectory(oAccount, 1);
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
0
        public void TestAppendBadLiteral()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.LogonWithLiteral("*****@*****.**", "test");
             oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX {TEST}", "ABCD");
             Assert.AreEqual(0, oSimulator.GetMessageCount("INBOX"));
             oSimulator.Disconnect();
        }
Exemplo n.º 10
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();
        }
Exemplo n.º 11
0
        public void TestAppend()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.LogonWithLiteral("*****@*****.**", "test");
            oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX {4}", "ABCD");
            Assert.AreEqual(1, oSimulator.GetMessageCount("INBOX"));
            oSimulator.Disconnect();
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
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();
        }
Exemplo n.º 15
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();
        }
Exemplo n.º 16
0
        public void TestRenameLongFolder()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.LogonWithLiteral(oAccount.Address, "test");
            Assert.IsTrue(oSimulator.CreateFolder("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"));
            Assert.IsTrue(oSimulator.CreateFolder("A"));

            Assert.IsFalse(oSimulator.RenameFolder("1", "A.1"));
            Assert.IsTrue(oSimulator.RenameFolder("1.2.3", "A.1"));
            Assert.IsTrue(oSimulator.SelectFolder("A.1.4"));


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

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.LogonWithLiteral(oAccount.Address, "test");
            Assert.IsTrue(oSimulator.CreateFolder("Main.Sub"));
            Assert.IsTrue(oSimulator.RenameFolder("Main.Sub", "Second.Sub"));

            string listResponse = oSimulator.List();

            Assert.IsFalse(listResponse.Contains("Main.Sub"));
            Assert.IsTrue(listResponse.Contains("Second.Sub"));


            oSimulator.Disconnect();
        }
Exemplo n.º 18
0
        public void ConfirmFileAddedToCorrectPublicFolder()
        {
            Utilities utilities = SingletonProvider <Utilities> .Instance;

            hMailServer.Account oAccount   = utilities.AddAccount(_domain, "*****@*****.**", "test");
            IMAPSimulator       oSimulator = new IMAPSimulator();

            // Confirm that the public folder is empty before we start our test.
            string publicDir = utilities.GetPublicDirectory();

            utilities.AssertFilesInDirectory(publicDir, 0);

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

            // Give everyone access to the folder.
            hMailServer.IMAPFolderPermission permission = folder.Permissions.Add();
            permission.PermissionType = hMailServer.eACLPermissionType.ePermissionTypeAnyone;
            permission.set_Permission(hMailServer.eACLPermission.ePermissionLookup, true);
            permission.set_Permission(hMailServer.eACLPermission.ePermissionRead, true);
            permission.set_Permission(hMailServer.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.
            Assert.AreEqual(1, oSimulator.GetMessageCount("#Public.Share"));
            Assert.AreEqual(0, oSimulator.GetMessageCount("INBOX"));
            oSimulator.Disconnect();


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

            // There users directory should still be empty.
            utilities.AssertFilesInUserDirectory(oAccount, 0);
        }
Exemplo n.º 19
0
        public void TestRenameToSubFolder()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.LogonWithLiteral(oAccount.Address, "test");
            Assert.IsTrue(oSimulator.CreateFolder("1.2.3.4.5"));
            Assert.IsTrue(oSimulator.CreateFolder("A"));
            Assert.IsTrue(oSimulator.RenameFolder("1", "A.1"));
            Assert.IsTrue(oSimulator.SelectFolder("A.1"));
            Assert.IsTrue(oSimulator.SelectFolder("A.1.2.3.4.5"));
            Assert.IsTrue(oSimulator.RenameFolder("A.1", "1"));
            Assert.IsFalse(oSimulator.SelectFolder("A.1"));
            Assert.IsFalse(oSimulator.SelectFolder("A.1.2.3.4.5"));
            Assert.IsTrue(oSimulator.SelectFolder("1"));
            Assert.IsTrue(oSimulator.SelectFolder("1.2.3.4.5"));

            oSimulator.Disconnect();
        }
Exemplo n.º 20
0
        public void ConfirmFileAddedToCorrectPublicFolder()
        {
            Utilities utilities = SingletonProvider<Utilities>.Instance;
            hMailServer.Account oAccount = utilities.AddAccount(_domain, "*****@*****.**", "test");
            IMAPSimulator oSimulator = new IMAPSimulator();

            // Confirm that the public folder is empty before we start our test.
            string publicDir = utilities.GetPublicDirectory();
            utilities.AssertFilesInDirectory(publicDir, 0);

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

            // Give everyone access to the folder.
            hMailServer.IMAPFolderPermission permission = folder.Permissions.Add();
            permission.PermissionType = hMailServer.eACLPermissionType.ePermissionTypeAnyone;
            permission.set_Permission(hMailServer.eACLPermission.ePermissionLookup, true);
            permission.set_Permission(hMailServer.eACLPermission.ePermissionRead, true);
            permission.set_Permission(hMailServer.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.
            Assert.AreEqual(1, oSimulator.GetMessageCount("#Public.Share"));
            Assert.AreEqual(0, oSimulator.GetMessageCount("INBOX"));
            oSimulator.Disconnect();

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

            // There users directory should still be empty.
            utilities.AssertFilesInUserDirectory(oAccount, 0);
        }
Exemplo n.º 21
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();
        }
Exemplo n.º 22
0
        public void TestRenameToSubFolder()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.LogonWithLiteral(oAccount.Address, "test");
             Assert.IsTrue(oSimulator.CreateFolder("1.2.3.4.5"));
             Assert.IsTrue(oSimulator.CreateFolder("A"));
             Assert.IsTrue(oSimulator.RenameFolder("1", "A.1"));
             Assert.IsTrue(oSimulator.SelectFolder("A.1"));
             Assert.IsTrue(oSimulator.SelectFolder("A.1.2.3.4.5"));
             Assert.IsTrue(oSimulator.RenameFolder("A.1", "1"));
             Assert.IsFalse(oSimulator.SelectFolder("A.1"));
             Assert.IsFalse(oSimulator.SelectFolder("A.1.2.3.4.5"));
             Assert.IsTrue(oSimulator.SelectFolder("1"));
             Assert.IsTrue(oSimulator.SelectFolder("1.2.3.4.5"));

             oSimulator.Disconnect();
        }
Exemplo n.º 23
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();
        }
Exemplo n.º 24
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();
        }
Exemplo n.º 25
0
        public void TestRenameToParallelFolder()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

              IMAPSimulator oSimulator = new IMAPSimulator();

              string sWelcomeMessage = oSimulator.Connect();
              oSimulator.LogonWithLiteral(oAccount.Address, "test");
              Assert.IsTrue(oSimulator.CreateFolder("Main.Sub"));
              Assert.IsTrue(oSimulator.RenameFolder("Main.Sub", "Second.Sub"));

              string listResponse = oSimulator.List();
              Assert.IsFalse(listResponse.Contains("Main.Sub"));
              Assert.IsTrue(listResponse.Contains("Second.Sub"));

              oSimulator.Disconnect();
        }
Exemplo n.º 26
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();
        }
Exemplo n.º 27
0
        public void TestRenameLongFolder()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.LogonWithLiteral(oAccount.Address, "test");
             Assert.IsTrue(oSimulator.CreateFolder("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"));
             Assert.IsTrue(oSimulator.CreateFolder("A"));

             Assert.IsFalse(oSimulator.RenameFolder("1", "A.1"));
             Assert.IsTrue(oSimulator.RenameFolder("1.2.3", "A.1"));
             Assert.IsTrue(oSimulator.SelectFolder("A.1.4"));

             oSimulator.Disconnect();
        }
Exemplo n.º 28
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();
        }
Exemplo n.º 29
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);
        }
Exemplo n.º 30
0
        public void TestMyRights()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

             hMailServer.IMAPFolders publicFolders = _settings.PublicFolders;
             hMailServer.IMAPFolder folder = publicFolders.Add("Share1");
             folder.Save();

             hMailServer.IMAPFolderPermission permission = folder.Permissions.Add();
             permission.PermissionAccountID = account1.ID;
             permission.PermissionType = hMailServer.eACLPermissionType.ePermissionTypeUser;
             permission.set_Permission(hMailServer.eACLPermission.ePermissionCreate, true);
             permission.set_Permission(hMailServer.eACLPermission.ePermissionAdminister, true);
             permission.set_Permission(hMailServer.eACLPermission.ePermissionExpunge, true);
             permission.set_Permission(hMailServer.eACLPermission.ePermissionDeleteMailbox, true);
             permission.set_Permission(hMailServer.eACLPermission.ePermissionRead, true);
             permission.Save();

             IMAPSimulator oSimulator1 = new IMAPSimulator();
             oSimulator1.Connect();
             oSimulator1.LogonWithLiteral(account1.Address, "test");
             string folderName = "#Public.Share1";
             string result = oSimulator1.GetMyRights(folderName);
             Assert.IsTrue(result.StartsWith("* MYRIGHTS \"" + folderName + "\" rkxea"));

             oSimulator1.Disconnect();
        }
Exemplo n.º 31
0
        public void TestListPublicFolder()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

              hMailServer.IMAPFolders publicFolders = _settings.PublicFolders;
              hMailServer.IMAPFolder folder = publicFolders.Add("Share1");
              folder.Save();

              hMailServer.IMAPFolderPermission permission = folder.Permissions.Add();
              permission.PermissionAccountID = account1.ID;
              permission.PermissionType = hMailServer.eACLPermissionType.ePermissionTypeUser;
              permission.set_Permission(hMailServer.eACLPermission.ePermissionLookup, true);
              permission.Save();

              IMAPSimulator oSimulator1 = new IMAPSimulator();
              oSimulator1.Connect();
              oSimulator1.LogonWithLiteral(account1.Address, "test");

              string result = oSimulator1.List();

              Assert.IsTrue(result.Contains(folder.Name));

              oSimulator1.Disconnect();
        }
Exemplo n.º 32
0
        public void TestLiteralSupport()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.LogonWithLiteral("*****@*****.**", "test");
             oSimulator.Disconnect();
        }
Exemplo n.º 33
0
        public void TestLSUB()
        {
            hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             IMAPSimulator oSimulator = new IMAPSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.LogonWithLiteral("*****@*****.**", "test");
             string result = oSimulator.List().Substring(0, 1);
             Assert.AreEqual("*", result);
        }
Exemplo n.º 34
0
        public void TestAppendResponseContainsExists()
        {
            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 response1 = oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX {4}", "ABCD");
             Assert.IsTrue(response1.Contains("* 1 EXISTS"), response1);
             Assert.IsTrue(response1.Contains("* 1 RECENT"), response1);
             Assert.AreEqual(1, oSimulator.GetMessageCount("INBOX"));
             oSimulator.Disconnect();
        }
Exemplo n.º 35
0
        public void TestSetAclOnPublicFolderNormalUser()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

             hMailServer.IMAPFolders publicFolders  = _settings.PublicFolders;
             hMailServer.IMAPFolder folder = publicFolders.Add("Share1");
             folder.Save();

             IMAPSimulator oSimulator1 = new IMAPSimulator();
             oSimulator1.Connect();
             oSimulator1.LogonWithLiteral(account1.Address, "test");
             Assert.IsFalse(oSimulator1.CreateFolder("#Public.Share1.MySub1"));
             oSimulator1.Disconnect();
        }
Exemplo n.º 36
0
        public void TestSetAclOnPublicFolderNormalUserWithPrivilegies()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

             hMailServer.IMAPFolders publicFolders = _settings.PublicFolders;
             hMailServer.IMAPFolder folder = publicFolders.Add("Share1");
             folder.Save();

             hMailServer.IMAPFolderPermission permission = folder.Permissions.Add();
             permission.PermissionAccountID = account1.ID;
             permission.PermissionType = hMailServer.eACLPermissionType.ePermissionTypeUser;
             permission.set_Permission(hMailServer.eACLPermission.ePermissionCreate, true);
             permission.Save();

             IMAPSimulator oSimulator1 = new IMAPSimulator();
             oSimulator1.Connect();
             oSimulator1.LogonWithLiteral(account1.Address, "test");
             Assert.IsTrue(oSimulator1.CreateFolder("#Public.Share1.MySub1"));
             oSimulator1.Disconnect();
        }
Exemplo n.º 37
0
        public void TestAppendToPublicFolder()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

              hMailServer.IMAPFolders publicFolders = _settings.PublicFolders;
              hMailServer.IMAPFolder folder = publicFolders.Add("Share1");
              folder.Save();

              hMailServer.IMAPFolderPermission permission = folder.Permissions.Add();
              permission.PermissionAccountID = account.ID;
              permission.PermissionType = hMailServer.eACLPermissionType.ePermissionTypeUser;
              permission.set_Permission(hMailServer.eACLPermission.ePermissionLookup, true);
              permission.set_Permission(hMailServer.eACLPermission.ePermissionRead, true);
              permission.set_Permission(hMailServer.eACLPermission.ePermissionInsert, true);
              permission.set_Permission(hMailServer.eACLPermission.ePermissionPost, true);
              permission.Save();

              IMAPSimulator oSimulator = new IMAPSimulator();

              string sWelcomeMessage = oSimulator.Connect();
              oSimulator.LogonWithLiteral(account.Address, "test");
              oSimulator.SendSingleCommandWithLiteral("A01 APPEND #Public.Share1 {4}", "ABCD");
              Assert.AreEqual(1, oSimulator.GetMessageCount("#Public.Share1"));
              oSimulator.Disconnect();
        }
Exemplo n.º 38
0
        public void TestSetACLOnAccountFolder()
        {
            hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();

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

             IMAPSimulator oSimulator1 = new IMAPSimulator();
             oSimulator1.Connect();
             oSimulator1.LogonWithLiteral(account1.Address, "test");
             Assert.IsTrue(oSimulator1.CreateFolder("SharedFolder"));
             Assert.IsFalse(oSimulator1.SetACL("SharedFolder", account2.Address, "lrswipkxtea"));
             oSimulator1.Disconnect();
        }