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

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

            POP3Simulator sim = new POP3Simulator();

            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 = Utilities.ReadCurrentDefaultLog();

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

            POP3Simulator oSimulator = new POP3Simulator();

            string sWelcomeMessage = oSimulator.GetWelcomeMessage();

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

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

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

            POP3Simulator sim = new POP3Simulator();

            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);
        }