Exemple #1
0
        public void TestTryCreateInvalidStructure()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var oSimulator = new IMAPClientSimulator();

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

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

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

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

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

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

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

             var oSimulator = new IMAPClientSimulator();

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

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

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

             var oSimulator = new IMAPClientSimulator();

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

             oSimulator.Disconnect();
        }
Exemple #4
0
        public void TestRenameSubFolderToMatchingName()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var oSimulator = new IMAPClientSimulator();
             CustomAssert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
             CustomAssert.IsTrue(oSimulator.CreateFolder("Folder1"));
             CustomAssert.IsTrue(oSimulator.SelectFolder("Folder1"));

             string result = string.Empty;
             CustomAssert.IsFalse(oSimulator.RenameFolder("Folder1", "Folder1.Sub1", out result));
             CustomAssert.IsTrue(result.Contains("A folder cannot be moved into one of its subfolders."));
             CustomAssert.IsTrue(oSimulator.SelectFolder("Folder1"));

             result = string.Empty;
             CustomAssert.IsTrue(oSimulator.RenameFolder("Folder1", "Folder1Test", out result));
             CustomAssert.IsTrue(oSimulator.SelectFolder("Folder1Test"));

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

             var oSimulator = new IMAPClientSimulator();

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

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

             var oSimulator = new IMAPClientSimulator();

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

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

             oSimulator.Disconnect();
        }
Exemple #7
0
        public void TestRenameRootPublicFolder()
        {
            IMAPFolders folders = _application.Settings.PublicFolders;
             IMAPFolder folder = folders.Add("ShareA");
             folder.Save();

             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.ePermissionDeleteMailbox, true);
             permission.Save();

             IMAPFolder folder2 = folders.Add("ShareB");
             folder2.Save();

             IMAPFolderPermission permission2 = folder2.Permissions.Add();
             permission2.PermissionType = eACLPermissionType.ePermissionTypeAnyone;
             permission2.set_Permission(eACLPermission.ePermissionLookup, true);
             permission2.set_Permission(eACLPermission.ePermissionRead, true);
             permission2.set_Permission(eACLPermission.ePermissionDeleteMailbox, true);
             permission2.Save();

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

             var simulator1 = new IMAPClientSimulator();
             simulator1.ConnectAndLogon(account.Address, "test");
             CustomAssert.IsTrue(simulator1.SelectFolder("#Public.ShareA"));
             CustomAssert.IsTrue(simulator1.SelectFolder("#Public.ShareB"));
             CustomAssert.IsTrue(simulator1.RenameFolder("#Public.ShareA", "#Public.ShareB.ShareA"));
             CustomAssert.IsFalse(simulator1.SelectFolder("#Public.ShareA"));
             CustomAssert.IsTrue(simulator1.SelectFolder("#Public.ShareB"));
             CustomAssert.IsTrue(simulator1.SelectFolder("#Public.ShareB.ShareA"));
        }
Exemple #8
0
        public void TestRenameFolderToAndFromPublic()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

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

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

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

             string oldFolderName = "#Public.Share1";
             string newFolderName = "AccountLevelFolder";

             // Test renaming from local folder name to shared folder.
             var oSimulator1 = new IMAPClientSimulator();
             oSimulator1.Connect();
             oSimulator1.Logon(account1.Address, "test");
             CustomAssert.IsFalse(oSimulator1.RenameFolder(oldFolderName, newFolderName));
             oSimulator1.Disconnect();

             // Test renaming from local folder name to shared folder.
             oldFolderName = "LocalFolder";
             newFolderName = "#Public.Share1";

             oSimulator1 = new IMAPClientSimulator();
             oSimulator1.Connect();
             oSimulator1.Logon(account1.Address, "test");
             oSimulator1.CreateFolder(oldFolderName);
             CustomAssert.IsFalse(oSimulator1.RenameFolder(oldFolderName, newFolderName));
             oSimulator1.Disconnect();
        }
        public void TestHierarchyDelimiterRename()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();
             Settings settings = _settings;
             settings.IMAPHierarchyDelimiter = "/";

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

             string folderName = "Test/Test";
             string newFolderName = "Apa/Test";

             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon(account.Address, "test");
             CustomAssert.IsTrue(oSimulator.CreateFolder(folderName));
             string listResponse = oSimulator.List();
             CustomAssert.IsTrue(listResponse.Contains("\"" + folderName + "\""));
             CustomAssert.IsTrue(listResponse.Contains("\"Test\""));
             CustomAssert.IsTrue(oSimulator.RenameFolder("Test", "Apa"));
             listResponse = oSimulator.List();
             CustomAssert.IsTrue(listResponse.Contains("\"" + newFolderName + "\""));
             CustomAssert.IsTrue(listResponse.Contains("\"Apa\""));
             oSimulator.Disconnect();
        }
Exemple #10
0
        public void TestRenamePublicFolderToRootPublicFolder()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

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

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

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

             string oldFolderName = "#Public.Share1.MySub1";
             string newFolderName = "#Public.Share2";

             var oSimulator1 = new IMAPClientSimulator();
             oSimulator1.Connect();
             oSimulator1.Logon(account1.Address, "test");
             CustomAssert.IsTrue(oSimulator1.CreateFolder(oldFolderName));
             CustomAssert.IsFalse(oSimulator1.RenameFolder(oldFolderName, newFolderName));

             CustomAssert.IsTrue(oSimulator1.List().Contains(oldFolderName));
             CustomAssert.IsFalse(oSimulator1.List().Contains(newFolderName));

             oSimulator1.Disconnect();
        }
Exemple #11
0
        public void TestBeforeLogon()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();

             CustomAssert.IsTrue(oSimulator.ExamineFolder("NonexistantFolder").Contains("NO Authenticate first"));
             CustomAssert.IsFalse(oSimulator.SelectFolder("NonexistantFolder"));
             CustomAssert.IsFalse(oSimulator.Copy(1, "SomeFolder"));
             CustomAssert.IsFalse(oSimulator.CheckFolder("SomeFolder"));
             CustomAssert.IsTrue(oSimulator.Fetch("123 a").Contains("NO Authenticate first"));
             CustomAssert.IsTrue(oSimulator.List().Contains("NO Authenticate first"));
             CustomAssert.IsTrue(oSimulator.LSUB().Contains("NO Authenticate first"));
             CustomAssert.IsTrue(oSimulator.GetMyRights("APA").Contains("NO Authenticate first"));
             CustomAssert.IsFalse(oSimulator.RenameFolder("A", "B"));
             CustomAssert.IsFalse(oSimulator.Status("SomeFolder", "MESSAGES").Contains("A01 OK"));
        }
Exemple #12
0
        public void TestRenameIMAPFolderNotifications()
        {
            _settings.IMAPIdleEnabled = true;

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

             var oSimulator1 = new IMAPClientSimulator();
             var oSimulator2 = new IMAPClientSimulator();
             oSimulator1.ConnectAndLogon(oAccount.Address, "test");
             oSimulator2.ConnectAndLogon(oAccount.Address, "test");

             oSimulator1.SelectFolder("Inbox");
             oSimulator2.CreateFolder("Mailbox");
             oSimulator2.RenameFolder("Mailbox", "Mailbox2");

             SMTPClientSimulator.StaticSend("*****@*****.**", oAccount.Address, "Test", "test");

             POP3ClientSimulator.AssertMessageCount(oAccount.Address, "test", 1);

             string noopResponse = oSimulator1.NOOP() + oSimulator1.NOOP();

             // confirm that the client is notified about this message even though another
             // folder has been dropped by another client.
             CustomAssert.IsTrue(noopResponse.Contains(@"* 1 EXISTS"), noopResponse);
        }
Exemple #13
0
        public void TestRenameAndList5()
        {
            Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             var oSimulator = new IMAPClientSimulator();

             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("*****@*****.**", "test");
             oSimulator.CreateFolder("Root1");
             oSimulator.CreateFolder("Root2.Root3");

             oSimulator.RenameFolder("Root2.Root3", "Root2.Root4");
             oSimulator.RenameFolder("Root1", "Root2.Root4.Root1");

             string result = oSimulator.List();

             CustomAssert.IsFalse(result.Contains(" Root1\r\n"));
             CustomAssert.IsTrue(result.Contains("Root2.Root4.Root1\"\r\n"));

             CustomAssert.IsFalse(oSimulator.SelectFolder("Root1"));
             CustomAssert.IsTrue(oSimulator.SelectFolder("Root2.Root4.Root1"));

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

             var oSimulator = new IMAPClientSimulator();

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

             CustomAssert.IsTrue(oSimulator.CreateFolder("Root1"));
             CustomAssert.IsTrue(oSimulator.CreateFolder("Root1.Sub1"));
             CustomAssert.IsTrue(oSimulator.CreateFolder("Root1.Sub2"));
             CustomAssert.IsTrue(oSimulator.CreateFolder("Root1.Sub3"));
             CustomAssert.IsTrue(oSimulator.SelectFolder("Root1"));
             CustomAssert.IsTrue(oSimulator.SelectFolder("Root1.Sub1"));
             CustomAssert.IsTrue(oSimulator.SelectFolder("Root1.Sub2"));
             CustomAssert.IsTrue(oSimulator.SelectFolder("Root1.Sub3"));
             CustomAssert.IsTrue(oSimulator.RenameFolder("Root1", "Root2"));
             CustomAssert.IsTrue(oSimulator.SelectFolder("Root2"));
             CustomAssert.IsTrue(oSimulator.SelectFolder("Root2.Sub1"));
             CustomAssert.IsTrue(oSimulator.SelectFolder("Root2.Sub2"));
             CustomAssert.IsTrue(oSimulator.SelectFolder("Root2.Sub3"));
             oSimulator.Disconnect();
        }