Пример #1
0
        public void TestInsertionOfTooLongString()
        {
            var watch = new Stopwatch();

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

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

            var sb = new StringBuilder();

            for (int i = 0; i < 1000; i++)
            {
                sb.Append("abcdefgh");
            }

            account.PersonFirstName = sb.ToString();

            try
            {
                watch.Start();
                account.Save();
            }
            catch (Exception)
            {
            }

            watch.Stop();
            CustomAssert.Greater(10000, watch.ElapsedMilliseconds);

            // an error log file may have been created. if we're using MySQL,
            // the value may have been silently truncated.
            TestSetup.AssertDeleteFile(TestSetup.GetErrorLogFileName());
        }
Пример #2
0
        public void TestSPFWithDebugLogging()
        {
            Application application = SingletonProvider <TestSetup> .Instance.GetApp();

            string debugLog = _settings.Logging.CurrentDefaultLog;

            TestSetup.AssertDeleteFile(debugLog);

            // Create a test account
            // Fetch the default domain

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

            // Disallow incorrect line endings.
            _antiSpam.SpamMarkThreshold   = 1;
            _antiSpam.SpamDeleteThreshold = 100;
            _antiSpam.AddHeaderReason     = true;
            _antiSpam.AddHeaderSpam       = true;
            _antiSpam.PrependSubject      = true;
            _antiSpam.PrependSubjectText  = "ThisIsSpam";

            // Enable SPF
            _antiSpam.UseSPF      = true;
            _antiSpam.UseSPFScore = 12;

            // Send a messages to this account.
            var oSMTP = new SMTPClientSimulator();

            oSMTP.Send("*****@*****.**", oAccount1.Address, "SPF test", "This is a test message.");

            string sMessageContents = POP3ClientSimulator.AssertGetFirstMessageText(oAccount1.Address, "test");

            if (!sMessageContents.Contains("X-hMailServer-Spam"))
            {
                throw new Exception("Spam message not detected as spam");
            }

            // Check that it has been logged.
            string contents = TestSetup.ReadExistingTextFile(debugLog);

            CustomAssert.IsTrue(contents.Contains("Total spam score: 12"));
            CustomAssert.IsTrue(contents.Contains("Spam test: SpamTestSPF, Score: 12"));

            TestSetup.AssertDeleteFile(debugLog);
        }
Пример #3
0
        internal bool Execute()
        {
            TestSetup.AssertDeleteFile(_application.Settings.Backup.LogFile);

            SetupEnvironment();
            if (!BackupEnvironment())
            {
                return(false);
            }

            DeleteEnvironment();
            RestoreEnvironment();
            ConfirmRestore();

            Directory.Delete(_backupDir, true);

            return(true);
        }
Пример #4
0
        public void TestAwstatsLog()
        {
            Settings settings = SingletonProvider <TestSetup> .Instance.GetApp().Settings;

            Logging logging = settings.Logging;

            logging.AWStatsEnabled = true;
            logging.Enabled        = true;

            if (File.Exists(logging.CurrentAwstatsLog))
            {
                File.Delete(logging.CurrentAwstatsLog);
            }

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

            IPAddress localAddress = TestSetup.GetLocalIpAddress();
            var       oSMTP        = new SMTPClientSimulator(false, 25, localAddress);

            // Delivery from external to local.
            CustomAssert.IsTrue(oSMTP.Send("*****@*****.**", "*****@*****.**", "Mail 1", "Mail 1"));
            POP3ClientSimulator.AssertMessageCount("*****@*****.**", "test", 1);
            string contents = TestSetup.ReadExistingTextFile(logging.CurrentAwstatsLog);

            TestSetup.AssertDeleteFile(logging.CurrentAwstatsLog);
            string expectedString = string.Format("\[email protected]\[email protected]\t{0}\t127.0.0.1\tSMTP\t?\t250\t",
                                                  localAddress);

            CustomAssert.IsTrue(contents.Contains(expectedString), contents);

            // Failed delivery from local to local.
            CustomAssert.IsFalse(oSMTP.Send("*****@*****.**", "*****@*****.**", "Mail 1", "Mail 1"));
            contents = TestSetup.ReadExistingTextFile(logging.CurrentAwstatsLog);
            TestSetup.AssertDeleteFile(logging.CurrentAwstatsLog);
            expectedString = string.Format("\[email protected]\[email protected]\t{0}\t127.0.0.1\tSMTP\t?\t530\t",
                                           localAddress);
            CustomAssert.IsTrue(contents.Contains(expectedString), contents);
        }