Exemplo 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void TestImproperDisconnect()
        {
            CustomAsserts.AssertSessionCount(eSessionType.eSTPOP3, 0);

            var application = SingletonProvider <TestSetup> .Instance.GetApp();

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

            int iCount = application.Status.get_SessionCount(eSessionType.eSTPOP3);

            var pop3ClientSimulator = new Pop3ClientSimulator();

            pop3ClientSimulator.ConnectAndLogon(account.Address, "test");
            CustomAsserts.AssertSessionCount(eSessionType.eSTPOP3, iCount + 1);
            pop3ClientSimulator.Disconnect(); // Disconnect without sending quit

            CustomAsserts.AssertSessionCount(eSessionType.eSTPOP3, iCount);
        }