Ejemplo n.º 1
0
        public void TestIMAPServer()
        {
            Utilities.DeleteCurrentDefaultLog();

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

            for (int i = 0; i < 30; i++)
            {
                try
                {
                    IMAPSimulator imapSim = new IMAPSimulator(true, 14300);
                    imapSim.ConnectAndLogon(account.Address, "test");
                    Assert.IsTrue(imapSim.SelectFolder("Inbox"), "SelectInbox");
                    imapSim.CreateFolder("Test");
                    Assert.IsTrue(imapSim.SelectFolder("Test"), "SelectTest");
                    Assert.IsTrue(imapSim.Logout(), "Logout");

                    imapSim.Disconnect();
                    break;
                }
                catch (Exception)
                {
                    if (i == 29)
                    {
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void TestParseMultipartNoBody()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string body = Utilities.GetResource("Messages.MultipartMessageWithNoMainBodyText.txt");

            SMTPClientSimulator.StaticSendRaw(account.Address, account.Address, body);

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

            var imapSim = new IMAPSimulator("*****@*****.**", "test", "INBOX");
            var result  = imapSim.Fetch("1 (BODY.PEEK[HEADER] BODY.PEEK[TEXT])");

            imapSim.Logout();
        }
Ejemplo n.º 3
0
        public void TestGlobalMaxMessageSizeLimitDisabled()
        {
            var account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test", 0);

            var message = new StringBuilder();

            // ~2 kb string
            for (int i = 0; i < 25; i++)
            {
                message.AppendLine("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
            }

            _settings.MaxMessageSize = 0;

            var    imapSim = new IMAPSimulator("*****@*****.**", "test", "INBOX");
            string result  = imapSim.SendSingleCommandWithLiteral("A01 APPEND INBOX {" + message.Length + "}", message.ToString());

            imapSim.Logout();

            Assert.IsFalse(result.StartsWith("A01 NO Message size exceeds fixed maximum message size."));
        }
Ejemplo n.º 4
0
        public void TestDomainMaxMessageSizeLimitDisabled()
        {
            var account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test", 0);
               var message = new StringBuilder();

               // ~2 kb string
               for (int i = 0; i < 25; i++)
              message.AppendLine("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");

               _domain.MaxMessageSize = 0; // 1 kb
               _domain.Save();

               var imapSim = new IMAPSimulator("*****@*****.**", "test", "INBOX");
               string result = imapSim.SendSingleCommandWithLiteral("A01 APPEND INBOX {" + message.Length + "}", message.ToString());
               imapSim.Logout();

               Assert.IsFalse(result.StartsWith("A01 NO Message size exceeds fixed maximum message size."));
        }
Ejemplo n.º 5
0
        public void TestConnectionObjectRelease()
        {
            Utilities.DeleteCurrentDefaultLog();

              _settings.IMAPIdleEnabled = true;

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

              IMAPSimulator simulator = new IMAPSimulator();

              string data;

              string sWelcomeMessage = simulator.Connect();
              simulator.Logon(account.Address, "test");
              Assert.IsTrue(simulator.SelectFolder("INBOX"));
              Assert.IsTrue(simulator.StartIdle());
              Assert.IsTrue(simulator.EndIdle(true, out data));
              Assert.IsTrue(simulator.Logout());

              string logData = Utilities.ReadCurrentDefaultLog();

              Assert.IsTrue(Utilities.DefaultLogContains("Ending session"));
        }
Ejemplo n.º 6
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());
        }