commit 91443f3: [Test] Add SURBL tests

Vsevolod Stakhov vsevolod at highsecure.ru
Sat Aug 24 18:28:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-08-24 19:08:30 +0100
URL: https://github.com/rspamd/rspamd/commit/91443f3b8aba3abe7d0a5cef117c236a2aa8f4da

[Test] Add SURBL tests

---
 test/functional/cases/340_surbl.robot | 52 +++++++++++++++++++++++++++++++++++
 test/functional/configs/plugins.conf  | 35 +++++++++++++++++++++--
 test/functional/configs/surbl.conf    | 42 ++++++++++++++++++++++++++++
 test/functional/messages/url6.eml     |  3 ++
 test/functional/messages/url7.eml     |  3 ++
 5 files changed, 133 insertions(+), 2 deletions(-)

diff --git a/test/functional/cases/340_surbl.robot b/test/functional/cases/340_surbl.robot
new file mode 100644
index 000000000..40ef9855c
--- /dev/null
+++ b/test/functional/cases/340_surbl.robot
@@ -0,0 +1,52 @@
+*** Settings ***
+Suite Setup     Surbl Setup
+Suite Teardown  Surbl Teardown
+Library         ${TESTDIR}/lib/rspamd.py
+Resource        ${TESTDIR}/lib/rspamd.robot
+Variables       ${TESTDIR}/lib/vars.py
+
+*** Variables ***
+${CONFIG}       ${TESTDIR}/configs/plugins.conf
+${RSPAMD_SCOPE}  Suite
+${URL_TLD}      ${TESTDIR}/../lua/unit/test_tld.dat
+
+*** Test Cases ***
+SURBL Example.com domain
+  ${result} =  Scan Message With Rspamc  ${TESTDIR}/messages/url4.eml
+  Should Contain  ${result.stdout}  RSPAMD_URIBL
+  Should Contain  ${result.stdout}  DBL_SPAM
+  Should Not Contain  ${result.stdout}  DBL_PHISH
+  Should Not Contain  ${result.stdout}  URIBL_BLACK
+
+SURBL Example.net domain
+  ${result} =  Scan Message With Rspamc  ${TESTDIR}/messages/url5.eml
+  Should Contain  ${result.stdout}  DBL_PHISH
+  Should Not Contain  ${result.stdout}  DBL_SPAM
+  Should Not Contain  ${result.stdout}  RSPAMD_URIBL
+  Should Not Contain  ${result.stdout}  URIBL_BLACK
+
+SURBL Example.org domain
+  ${result} =  Scan Message With Rspamc  ${TESTDIR}/messages/url6.eml
+  Should Contain  ${result.stdout}  URIBL_BLACK
+  Should Not Contain  ${result.stdout}  DBL_SPAM
+  Should Not Contain  ${result.stdout}  RSPAMD_URIBL
+  Should Not Contain  ${result.stdout}  DBL_PHISH
+
+SURBL Example.ru domain
+  ${result} =  Scan Message With Rspamc  ${TESTDIR}/messages/url7.eml
+  Should Contain  ${result.stdout}  URIBL_GREY
+  Should Contain  ${result.stdout}  URIBL_RED
+  Should Not Contain  ${result.stdout}  DBL_SPAM
+  Should Not Contain  ${result.stdout}  RSPAMD_URIBL
+  Should Not Contain  ${result.stdout}  DBL_PHISH
+  Should Not Contain  ${result.stdout}  URIBL_BLACK
+
+*** Keywords ***
+Surbl Setup
+  ${PLUGIN_CONFIG} =  Get File  ${TESTDIR}/configs/surbl.conf
+  Set Suite Variable  ${PLUGIN_CONFIG}
+  Generic Setup  PLUGIN_CONFIG
+
+Surbl Teardown
+  Normal Teardown
+  Terminate All Processes    kill=True
\ No newline at end of file
diff --git a/test/functional/configs/plugins.conf b/test/functional/configs/plugins.conf
index bc8fb01ba..05ff16a1e 100644
--- a/test/functional/configs/plugins.conf
+++ b/test/functional/configs/plugins.conf
@@ -1,5 +1,5 @@
 options = {
-  filters = ["spf", "dkim", "regexp"]
+  filters = ["spf", "dkim", "regexp", "surbl"]
   url_tld = "${URL_TLD}"
   pidfile = "${TMPDIR}/rspamd.pid"
   lua_path = "${INSTALLROOT}/share/rspamd/lib/?.lua"
@@ -532,7 +532,38 @@ options = {
           name = "131.193.18.151.fake.rbl";
           type = "a";
           replies = ["127.0.0.3"];
-        }
+        },
+        # SURBL tests
+        {
+          name = "rciuosbadgpq6b5wt436nhgnwzmfh9w9.test.uribl";
+          type = a;
+          replies = ["127.0.0.2"];
+        },
+        {
+          name = "example.com.test2.uribl";
+          type = a;
+          replies = ["127.0.1.2"];
+        },
+        {
+          name = "example.net.test2.uribl";
+          type = a;
+          replies = ["127.0.1.4"];
+        },
+        {
+          name = "rspamd.tk.test2.uribl";
+          type = a;
+          replies = ["127.0.1.4"];
+        },
+        {
+          name = "example.org.test3.uribl";
+          type = a;
+          replies = ["127.0.0.2"];
+        },
+        {
+          name = "example.ru.test3.uribl";
+          type = a;
+          replies = ["127.0.0.12"];
+        },
         ];
   }
 }
diff --git a/test/functional/configs/surbl.conf b/test/functional/configs/surbl.conf
new file mode 100644
index 000000000..944ee747f
--- /dev/null
+++ b/test/functional/configs/surbl.conf
@@ -0,0 +1,42 @@
+
+surbl {
+  rules {
+    "RSPAMD_URIBL" {
+      suffix = "test.uribl";
+      check_dkim = true;
+      check_emails = true;
+      process_script =<<EOD
+function(url, suffix)
+  local cr = require "rspamd_cryptobox_hash"
+  local h = cr.create(url):base32():sub(1, 32)
+  return string.format("%s.%s", h, suffix)
+end
+EOD;
+    }
+    "DBL" {
+      suffix = "test2.uribl";
+      no_ip = true;
+      check_emails = true;
+      check_dkim = true;
+
+      ips = {
+        # spam domain
+        DBL_SPAM = "127.0.1.2";
+        # phish domain
+        DBL_PHISH = "127.0.1.4";
+      }
+    }
+
+    "URIBL_MULTI" {
+      suffix = "test3.uribl";
+      check_dkim = true;
+      check_emails = true;
+      bits {
+        URIBL_BLOCKED = 1;
+        URIBL_BLACK = 2;
+        URIBL_GREY = 4;
+        URIBL_RED = 8;
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/test/functional/messages/url6.eml b/test/functional/messages/url6.eml
new file mode 100644
index 000000000..7bc0b5b61
--- /dev/null
+++ b/test/functional/messages/url6.eml
@@ -0,0 +1,3 @@
+Content-Type: text/html
+
+hello <a href = "https://www.example.org/?">hello</a>
diff --git a/test/functional/messages/url7.eml b/test/functional/messages/url7.eml
new file mode 100644
index 000000000..63d1c53c1
--- /dev/null
+++ b/test/functional/messages/url7.eml
@@ -0,0 +1,3 @@
+Content-Type: text/html
+
+hello <a href = "https://example.ru/?">hello</a>


More information about the Commits mailing list