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(); CustomAssert.IsTrue(sim.ConnectAndLogon(account.Address, "test")); sim.Disconnect(); // confirm that we can retrieve welcome message. CustomAssert.IsTrue(sim.GetWelcomeMessage().StartsWith("+OK")); string errorMessage; // fail to log on 3 times. for (int i = 0; i < 5; i++) { CustomAssert.IsFalse(sim.ConnectAndLogon(account.Address, "testA", out errorMessage)); sim.Disconnect(); } CustomAssert.IsTrue(sim.GetWelcomeMessage().StartsWith("+OK")); string logText = TestSetup.ReadCurrentDefaultLog(); CustomAssert.IsFalse(logText.Contains("Blocked either by IP range or by connection limit."), logText); }
public void TestIPRangeName() { _settings.AutoBanOnLogonFailure = true; _settings.MaxInvalidLogonAttempts = 3; _settings.MaxInvalidLogonAttemptsWithin = 5; _settings.AutoBanMinutes = 3; CustomAssert.AreEqual(2, _settings.SecurityRanges.Count); Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test"); var sim = new POP3ClientSimulator(); CustomAssert.IsTrue(sim.ConnectAndLogon(account.Address, "test")); sim.Disconnect(); // confirm that we can retrieve welcome message. CustomAssert.IsTrue(sim.GetWelcomeMessage().StartsWith("+OK")); string errorMessage; // fail to log on 3 times. for (int i = 0; i < 3; i++) { CustomAssert.IsFalse(sim.ConnectAndLogon(account.Address, "testA", out errorMessage)); sim.Disconnect(); if (i == 2) { CustomAssert.IsTrue(errorMessage.Contains("Too many invalid logon attempts.")); } } CustomAssert.IsTrue(sim.GetWelcomeMessage().Length == 0); CustomAssert.AreEqual(3, _settings.SecurityRanges.Count); CustomAssert.AreEqual("Auto-ban: [email protected]", _settings.SecurityRanges[2].Name); }
public void WelcomeMessage() { SingletonProvider<TestSetup>.Instance.GetApp().Settings.WelcomePOP3 = "HOWDYHO POP3"; var oSimulator = new POP3ClientSimulator(); string sWelcomeMessage = oSimulator.GetWelcomeMessage(); if (sWelcomeMessage != "+OK HOWDYHO POP3\r\n") throw new Exception("ERROR - Wrong welcome message."); }