Пример #1
0
        public void TestWelcomeMessage()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();
             _settings.WelcomeSMTP = "HOWDYHO";

             var oSimulator = new SMTPClientSimulator();

             string sWelcomeMessage = oSimulator.GetWelcomeMessage();

             if (sWelcomeMessage != "220 HOWDYHO\r\n")
            throw new Exception("ERROR - Wrong welcome message.");
        }
Пример #2
0
        public void TestSMTPLogonFailure()
        {
            _settings.AutoBanOnLogonFailure = true;
             _settings.MaxInvalidLogonAttempts = 2;
             _settings.MaxInvalidLogonAttemptsWithin = 5;
             _settings.AutoBanMinutes = 3;

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

             var sim = new SMTPClientSimulator();

             //[email protected] / test
             string errorMessage;
             CustomAssert.IsTrue(sim.ConnectAndLogon("dGVzdEB0ZXN0LmNvbQ==", "dGVzdA==", out errorMessage));
             sim.Disconnect();

             // confirm that we can retrieve welcome message.
             CustomAssert.IsTrue(sim.GetWelcomeMessage().StartsWith("220"));

             // fail to log on 3 times.
             for (int i = 0; i < 2; i++)
             {
            CustomAssert.IsFalse(sim.ConnectAndLogon("dGVzdEB0ZXN0LmNvbQ==", "Vaffe==", out errorMessage));
            sim.Disconnect();

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

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

             string logText = TestSetup.ReadCurrentDefaultLog();
             CustomAssert.IsTrue(logText.Contains("Blocked either by IP range or by connection limit."), logText);
        }