예제 #1
0
        public void TestPOP3TransactionSafety()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Assert.IsTrue(SMTPClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestBody"));
            POP3Simulator.AssertMessageCount(account.Address, "test", 1);

            POP3Simulator sim = new POP3Simulator();

            sim.ConnectAndLogon(account.Address, "test");

            // Now delete the message using an IMAP client.
            IMAPSimulator imapSimulator = new IMAPSimulator();

            Assert.IsTrue(imapSimulator.ConnectAndLogon(account.Address, "test"));
            Assert.IsTrue(imapSimulator.SelectFolder("INBOX"));
            Assert.IsTrue(imapSimulator.SetDeletedFlag(1));
            Assert.IsTrue(imapSimulator.Expunge());
            Assert.AreEqual(0, imapSimulator.GetMessageCount("Inbox"));

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

            // This deletion should not have any effect, since the POP3 connection is referencing an old message.
            sim.DELE(1);
            sim.QUIT();

            Assert.AreEqual(1, imapSimulator.GetMessageCount("Inbox"));
        }
예제 #2
0
        public void TestExpunge()
        {
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Assert.IsTrue(SMTPClientSimulator.StaticSend("*****@*****.**", oAccount.Address, "Test", "test"));
            POP3Simulator.AssertMessageCount(oAccount.Address, "test", 1);

            IMAPSimulator simulator = new IMAPSimulator();

            simulator.ConnectAndLogon(oAccount.Address, "test");
            simulator.SelectFolder("Inbox");
            Assert.IsTrue(simulator.SetFlagOnMessage(1, true, @"\Deleted"));

            IMAPSimulator secondSimulator = new IMAPSimulator();

            secondSimulator.ConnectAndLogon(oAccount.Address, "test");
            string result = secondSimulator.ExamineFolder("INBOX");

            Assert.IsTrue(result.Contains("1 EXISTS"), result);
            Assert.IsFalse(secondSimulator.Expunge());

            simulator.SelectFolder("INBOX");
            Assert.IsTrue(simulator.Expunge());

            simulator.Close();
            secondSimulator.Close();
        }
예제 #3
0
        public void TestFolderExpungeNotification()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

              SMTPClientSimulator.StaticSend(account.Address, account.Address, "TestSubject", "TestBody");
              IMAPSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);

              IMAPSimulator simulator1 = new IMAPSimulator();
              IMAPSimulator simulator2 = new IMAPSimulator();

              simulator1.ConnectAndLogon(account.Address, "test");
              simulator2.ConnectAndLogon(account.Address, "test");

              simulator1.SelectFolder("Inbox");
              simulator2.SelectFolder("Inbox");

              string result = simulator2.NOOP();
              Assert.IsFalse(result.Contains("Deleted"));
              Assert.IsFalse(result.Contains("Seen"));

              simulator1.SetDeletedFlag(1);
              simulator1.Expunge();

              // the result may (should) come after the first NOOP response stream so do noop twice.
              result = simulator2.NOOP() + simulator2.NOOP();
              Assert.IsTrue(result.Contains("* 1 EXPUNGE"));

              simulator1.Disconnect();
              simulator2.Disconnect();
        }
예제 #4
0
        public void TestExpungeNotification()
        {
            _settings.IMAPIdleEnabled = true;

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

              for (int i = 0; i < 5; i++ )
              SMTPClientSimulator.StaticSend("*****@*****.**", oAccount.Address, "Test", "test");

              POP3Simulator.AssertMessageCount(oAccount.Address, "test", 5);

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

              oSimulator1.SelectFolder("Inbox");
              oSimulator2.SelectFolder("Inbox");

              for (int i = 1; i <= 5; i++)
              {
             Assert.IsTrue(oSimulator1.SetFlagOnMessage(i, true, @"\Deleted"));
              }

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

              Assert.IsTrue(noopResponse.Contains(@"* 1 FETCH (FLAGS (\Deleted)") &&
                        noopResponse.Contains(@"* 1 FETCH (FLAGS (\Deleted)") &&
                        noopResponse.Contains(@"* 1 FETCH (FLAGS (\Deleted)") &&
                        noopResponse.Contains(@"* 1 FETCH (FLAGS (\Deleted)") &&
                        noopResponse.Contains(@"* 1 FETCH (FLAGS (\Deleted)"), noopResponse);

              bool result = oSimulator1.Expunge();

              string expungeResult = oSimulator2.NOOP() + oSimulator2.NOOP();

              Assert.IsTrue(expungeResult.Contains("* 1 EXPUNGE\r\n* 1 EXPUNGE\r\n* 1 EXPUNGE\r\n* 1 EXPUNGE\r\n* 1 EXPUNGE"), expungeResult);
        }
예제 #5
0
        public void TestExpunge()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             for (int i = 0; i < 3; i++ )
            SMTPClientSimulator.StaticSend("*****@*****.**", account.Address, "Test", "test");

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

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

             Assert.IsTrue(simulator.SetFlagOnMessage(1, true, @"\Deleted"));
             Assert.IsTrue(simulator.SetFlagOnMessage(3, true, @"\Deleted"));

             string result;
             Assert.IsTrue(simulator.Expunge(out result));

             // Messages 1 and 2 should be deleted. 2, because when the first message
             // is deleted, the index of the message which was originally 3, is now 2.
             Assert.IsTrue(result.Contains("* 1 EXPUNGE\r\n* 2 EXPUNGE"));
        }
예제 #6
0
        public void TestExpunge()
        {
            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.ePermissionInsert, true);
             permission.set_Permission(hMailServer.eACLPermission.ePermissionRead, true);
             permission.set_Permission(hMailServer.eACLPermission.ePermissionWriteDeleted, true);
             permission.Save();

             string folderName = "#Public.Share1";
             SMTPClientSimulator.StaticSend("*****@*****.**", account1.Address, "TestMessage", "Body");
             Utilities.AssertMessageExistsInFolder(account1.IMAPFolders.get_ItemByName("INBOX"), 1);
             Utilities.AssertMessageExistsInFolder(folder, 0);

             IMAPSimulator oSimulator1 = new IMAPSimulator();
             oSimulator1.Connect();
             oSimulator1.Logon(account1.Address, "test");
             oSimulator1.SelectFolder("INBOX");
             Assert.IsTrue(oSimulator1.Copy(1, folderName));
             Assert.IsTrue(oSimulator1.SelectFolder(folderName));
             Assert.IsTrue(oSimulator1.SetDeletedFlag(1));

             Assert.IsFalse(oSimulator1.Expunge());

             permission.set_Permission(hMailServer.eACLPermission.ePermissionExpunge, true);
             permission.Save();
             Assert.IsTrue(oSimulator1.Expunge());

             oSimulator1.Disconnect();
        }