Esempio n. 1
0
        public void TestDisabled()
        {
            _settings.AutoBanOnLogonFailure         = false;
            _settings.MaxInvalidLogonAttempts       = 3;
            _settings.MaxInvalidLogonAttemptsWithin = 5;
            _settings.AutoBanMinutes = 3;

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

            var sim = new Pop3ClientSimulator();

            Assert.IsTrue(sim.ConnectAndLogon(account.Address, "test"));
            sim.Disconnect();

            // confirm that we can retrieve welcome message.
            Assert.IsTrue(sim.GetWelcomeMessage().StartsWith("+OK"));

            string errorMessage;

            // fail to log on 3 times.
            for (int i = 0; i < 5; i++)
            {
                Assert.IsFalse(sim.ConnectAndLogon(account.Address, "testA", out errorMessage));
                sim.Disconnect();
            }

            Assert.IsTrue(sim.GetWelcomeMessage().StartsWith("+OK"));

            string logText = LogHandler.ReadCurrentDefaultLog();

            Assert.IsFalse(logText.Contains("Blocked either by IP range or by connection limit."), logText);
        }
Esempio n. 2
0
        public void WelcomeMessage()
        {
            SingletonProvider <TestSetup> .Instance.GetApp().Settings.WelcomePOP3 = "HOWDYHO POP3";

            var simulator = new Pop3ClientSimulator();

            string sWelcomeMessage = simulator.GetWelcomeMessage();

            if (sWelcomeMessage != "+OK HOWDYHO POP3\r\n")
            {
                throw new Exception("ERROR - Wrong welcome message.");
            }
        }
Esempio n. 3
0
        public void TestIPRangeName()
        {
            _settings.AutoBanOnLogonFailure         = true;
            _settings.MaxInvalidLogonAttempts       = 3;
            _settings.MaxInvalidLogonAttemptsWithin = 5;
            _settings.AutoBanMinutes = 3;

            Assert.AreEqual(2, _settings.SecurityRanges.Count);

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

            var sim = new Pop3ClientSimulator();

            Assert.IsTrue(sim.ConnectAndLogon(account.Address, "test"));
            sim.Disconnect();

            // confirm that we can retrieve welcome message.
            Assert.IsTrue(sim.GetWelcomeMessage().StartsWith("+OK"));

            string errorMessage;

            // fail to log on 3 times.
            for (int i = 0; i < 3; i++)
            {
                Assert.IsFalse(sim.ConnectAndLogon(account.Address, "testA", out errorMessage));
                sim.Disconnect();

                if (i == 2)
                {
                    Assert.IsTrue(errorMessage.Contains("Too many invalid logon attempts."));
                }
            }

            Assert.IsTrue(sim.GetWelcomeMessage().Length == 0);

            Assert.AreEqual(3, _settings.SecurityRanges.Count);
            Assert.AreEqual("Auto-ban: [email protected]", _settings.SecurityRanges[2].Name);
        }