コード例 #1
0
ファイル: Basics.cs プロジェクト: digitalsoft/hmailserver
        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
ファイル: AutoBan.cs プロジェクト: digitalsoft/hmailserver
        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);
        }