commit 7048dc0: [Test] Rbl: Add some tests for RBL module

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Dec 27 18:28:09 UTC 2018


Author: Vsevolod Stakhov
Date: 2018-12-15 20:18:55 +0000
URL: https://github.com/rspamd/rspamd/commit/7048dc0475ca9e689fe38c9688774b33c1c9ecee

[Test] Rbl: Add some tests for RBL module

---
 test/functional/cases/300_rbl.robot  | 39 ++++++++++++++++++++++++++++++++++++
 test/functional/configs/plugins.conf | 33 +++++++++++++++++++++++++++++-
 test/functional/configs/rbl.conf     | 16 +++++++++++++++
 3 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/test/functional/cases/300_rbl.robot b/test/functional/cases/300_rbl.robot
new file mode 100644
index 000000000..36d13c045
--- /dev/null
+++ b/test/functional/cases/300_rbl.robot
@@ -0,0 +1,39 @@
+*** Settings ***
+Suite Setup     Rbl Setup
+Suite Teardown  Rbl Teardown
+Library         ${TESTDIR}/lib/rspamd.py
+Resource        ${TESTDIR}/lib/rspamd.robot
+Variables       ${TESTDIR}/lib/vars.py
+
+*** Variables ***
+${CONFIG}       ${TESTDIR}/configs/plugins.conf
+${MESSAGE}      ${TESTDIR}/messages/spam_message.eml
+${RSPAMD_SCOPE}  Suite
+${URL_TLD}      ${TESTDIR}/../lua/unit/test_tld.dat
+
+*** Test Cases ***
+RBL FROM MISS
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  -i  1.2.3.4
+  Check Rspamc  ${result}  FAKE_RBL_CODE_2  inverse=True
+
+RBL FROM HIT
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  -i  4.3.2.1
+  Check Rspamc  ${result}  FAKE_RBL_CODE_2
+
+RBL FROM MULTIPLE HIT
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  -i  4.3.2.3
+  Check Rspamc  ${result}  FAKE_RBL_CODE_2  FAKE_RBL_CODE_3
+
+RBL FROM UNKNOWN HIT
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  -i  4.3.2.2
+  Check Rspamc  ${result}  FAKE_RBL_UNKNOWN
+
+*** Keywords ***
+Rbl Setup
+  ${PLUGIN_CONFIG} =  Get File  ${TESTDIR}/configs/rbl.conf
+  Set Suite Variable  ${PLUGIN_CONFIG}
+  Generic Setup  PLUGIN_CONFIG
+
+Rbl 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 b34f66208..c881e972e 100644
--- a/test/functional/configs/plugins.conf
+++ b/test/functional/configs/plugins.conf
@@ -481,7 +481,38 @@ options = {
           name = "fail8.org.org.za",
           type = "txt";
           replies = ["v=spf1 ip4:8.8.8.8 a:www.dnssec-failed.org -all"];
-        }];
+        },
+        {
+          name = "1.2.3.4.fake.rbl";
+          type = "a";
+          replies = ["127.0.0.2"];
+        },
+        {
+          name = "2.2.3.4.fake.rbl";
+          type = "a";
+          replies = ["127.0.0.10"];
+        },
+        {
+          name = "3.2.3.4.fake.rbl";
+          type = "a";
+          replies = ["127.0.0.2", "127.0.0.3"];
+        },
+        {
+          name = "4.3.2.1.fake.rbl";
+          type = "a";
+          rcode = 'nxdomain';
+        },
+        {
+          name = "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.fake.rbl";
+          type = "a";
+          replies = ["127.0.0.2"];
+        },
+        {
+          name = "131.193.18.151.fake.rbl";
+          type = "a";
+          replies = ["127.0.0.3"];
+        }
+        ];
   }
 }
 logging = {
diff --git a/test/functional/configs/rbl.conf b/test/functional/configs/rbl.conf
new file mode 100644
index 000000000..15106548b
--- /dev/null
+++ b/test/functional/configs/rbl.conf
@@ -0,0 +1,16 @@
+rbl {
+  rbls {
+    fake {
+      from = true;
+      ipv4 = true;
+      ipv6 = true;
+      rbl = "fake.rbl";
+      symbol = "FAKE_RBL_UNKNOWN";
+      unknown = true;
+      returncodes = {
+        "FAKE_RBL_CODE_2" = "127.0.0.2";
+        "FAKE_RBL_CODE_3" = "127.0.0.3";
+      }
+    }
+  }
+}
\ No newline at end of file


More information about the Commits mailing list