Beispiel #1
0
        public void TestIncomingRelays()
        {
            IncomingRelays incomingRelays = _application.Settings.IncomingRelays;

            Assert.AreEqual(0, incomingRelays.Count);

            IncomingRelay incomingRelay = incomingRelays.Add();

            incomingRelay.Name    = "TestRelay";
            incomingRelay.LowerIP = "1.2.1.1";
            incomingRelay.UpperIP = "2.1.2.1";
            incomingRelay.Save();

            // Check that it was saved.
            Assert.AreNotEqual(0, incomingRelay.ID);

            // Confirm that settings were saved properly.
            incomingRelays.Refresh();
            IncomingRelay incomingRelay2 = incomingRelays.get_ItemByDBID(incomingRelay.ID);

            Assert.AreEqual(incomingRelay.ID, incomingRelay2.ID);
            Assert.AreEqual(incomingRelay.Name, incomingRelay2.Name);
            Assert.AreEqual(incomingRelay.LowerIP, incomingRelay2.LowerIP);
            Assert.AreEqual(incomingRelay.UpperIP, incomingRelay2.UpperIP);

            // Delete it again.
            incomingRelays.Delete(0);

            Assert.AreEqual(0, incomingRelays.Count);
        }
Beispiel #2
0
        private void SetupIncomingRelay()
        {
            IncomingRelay relay = _application.Settings.IncomingRelays.Add();

            relay.Name    = "Test";
            relay.LowerIP = "1.2.3.4";
            relay.UpperIP = "4.3.2.1";
            relay.Save();
        }
Beispiel #3
0
        private void ConfirmIncomingRelay()
        {
            IncomingRelays relays = _application.Settings.IncomingRelays;

            Assert.AreEqual(1, relays.Count);

            IncomingRelay relay = relays[0];

            Assert.AreEqual("Test", relay.Name);
            Assert.AreEqual("1.2.3.4", relay.LowerIP);
            Assert.AreEqual("4.3.2.1", relay.UpperIP);
        }
Beispiel #4
0
        public void TestSpamProtectionPreTransmissionHELOPassFirst()
        {
            _application.Settings.AntiSpam.SpamMarkThreshold   = 1;
            _application.Settings.AntiSpam.SpamDeleteThreshold = 100;
            _application.Settings.AntiSpam.AddHeaderReason     = true;
            _application.Settings.AntiSpam.AddHeaderSpam       = true;
            _application.Settings.AntiSpam.PrependSubject      = true;
            _application.Settings.AntiSpam.PrependSubjectText  = "ThisIsSpam";

            _application.Settings.AntiSpam.CheckHostInHelo      = true;
            _application.Settings.AntiSpam.CheckHostInHeloScore = 105;

            IncomingRelay incomingRelay = _application.Settings.IncomingRelays.Add();

            incomingRelay.LowerIP = "1.2.1.2";
            incomingRelay.UpperIP = "1.2.1.3";
            incomingRelay.Name    = "Test";
            incomingRelay.Save();

            var messages = new List <string>();

            string message = "Received: from example.com (example.com [1.2.1.2]) by mail.host.edu\r\n" +
                             "Received: from mail.hmailserver.com (mail.hmailserver.com [" +
                             TestSetup.GethMailServerCOMIPaddress() + "]) by mail.host.edu\r\n" +
                             "From: [email protected]\r\n" +
                             "To: [email protected]\r\n" +
                             "Subject: Test\r\n" +
                             "\r\n" +
                             "Should be blocked by SPF.";

            messages.Add(message);

            int port = TestSetup.GetNextFreePort();

            using (var pop3Server = new Pop3ServerSimulator(1, port, messages))
            {
                pop3Server.StartListen();

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

                FetchAccount fa = account.FetchAccounts.Add();

                fa.Enabled             = true;
                fa.MinutesBetweenFetch = 10;
                fa.Name                  = "Test";
                fa.Username              = "******";
                fa.Password              = "******";
                fa.UseSSL                = false;
                fa.ServerAddress         = "localhost";
                fa.Port                  = port;
                fa.ProcessMIMERecipients = false;
                fa.DaysToKeepMessages    = 0;
                fa.UseAntiSpam           = true;
                fa.Save();

                fa.DownloadNow();

                pop3Server.WaitForCompletion();

                fa.Delete();

                Pop3ClientSimulator.AssertMessageCount(account.Address, "test", 1);
            }
        }