]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Fix and extend whitelist tests
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 1 Oct 2018 17:17:07 +0000 (18:17 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 1 Oct 2018 17:17:07 +0000 (18:17 +0100)
test/functional/cases/123_whitelist.robot
test/functional/configs/maps/domains.list
test/functional/configs/whitelist.conf

index 9ca57b9ecf20b5e7ba29e6104db015504840aa4d..570c43bf86d9f6f0d84fc3d4f1daae71c34756f8 100644 (file)
@@ -9,6 +9,10 @@ Variables       ${TESTDIR}/lib/vars.py
 ${CONFIG}       ${TESTDIR}/configs/plugins.conf
 ${M_DMARC_OK}   ${TESTDIR}/messages/dmarc/pass_none.eml
 ${M_DMARC_BAD}  ${TESTDIR}/messages/dmarc/fail_none.eml
+
+${M_DKIM_RSPAMD_OK}   ${TESTDIR}/messages/dmarc/good_dkim_rspamd.eml
+${M_DKIM_RSPAMD_BAD}  ${TESTDIR}/messages/dmarc/bad_dkim_rspamd.eml
+
 ${UTF_MESSAGE}  ${TESTDIR}/messages/utf.eml
 ${RSPAMD_SCOPE}  Suite
 ${URL_TLD}      ${TESTDIR}/../lua/unit/test_tld.dat
@@ -16,12 +20,12 @@ ${URL_TLD}      ${TESTDIR}/../lua/unit/test_tld.dat
 *** Test Cases ***
 WHITELISTS
   ${result} =  Scan Message With Rspamc  ${M_DMARC_OK}  -i  8.8.4.4  -F  foo@spf.cacophony.za.org
-  Check Rspamc  ${result}  WHITELIST_DKIM (-1
-  Should Contain  ${result.stdout}  STRICT_DMARC (-3
-  Should Contain  ${result.stdout}  WHITELIST_DDS (-3
-  Should Contain  ${result.stdout}  WHITELIST_DMARC (-2
-  Should Contain  ${result.stdout}  WHITELIST_DMARC_DKIM (-2
-  Should Contain  ${result.stdout}  WHITELIST_SPF (-1
+  Check Rspamc  ${result}  WHITELIST_DKIM (-
+  Should Contain  ${result.stdout}  STRICT_DMARC (-
+  Should Contain  ${result.stdout}  WHITELIST_DDS (-
+  Should Contain  ${result.stdout}  WHITELIST_DMARC (-
+  Should Contain  ${result.stdout}  WHITELIST_DMARC_DKIM (-
+  Should Contain  ${result.stdout}  WHITELIST_SPF (-
   Should Not Contain  ${result.stdout}  BLACKLIST_SPF (
   Should Not Contain  ${result.stdout}  BLACKLIST_DKIM (
   Should Not Contain  ${result.stdout}  BLACKLIST_DMARC (
@@ -38,13 +42,24 @@ BLACKLISTS
   Should Contain  ${result.stdout}  BLACKLIST_SPF (3
   Should Contain  ${result.stdout}  STRICT_DMARC (3
   Should Contain  ${result.stdout}  BLACKLIST_DDS (3
-  Should Contain  ${result.stdout}  BLACKLIST_DMARC (3
+  Should Contain  ${result.stdout}  BLACKLIST_DMARC (2
   Should Not Contain  ${result.stdout}  WHITELIST_DDS (
   Should Not Contain  ${result.stdout}  WHITELIST_SPF (
-  Should Not Contain  ${result.stdout}  WHITEIST_DKIM (
+  Should Not Contain  ${result.stdout}  WHITELIST_DKIM (
   Should Not Contain  ${result.stdout}  WHITELIST_DMARC (
   Should Not Contain  ${result.stdout}  WHITELIST_DMARC_DKIM (
 
+WHITELIST_WL_ONLY
+  ${result} =  Scan Message With Rspamc  ${M_DKIM_RSPAMD_OK}
+  Check Rspamc  ${result}  WHITELIST_DKIM (-2
+  Should Not Contain  ${result.stdout}  BLACKLIST_DKIM (
+
+BLACKLISTS_WL_ONLY
+  ${result} =  Scan Message With Rspamc  ${M_DKIM_RSPAMD_BAD}
+  Check Rspamc  ${result}  DKIM_REJECT (
+  Should Not Contain  ${result.stdout}  WHITELIST_DKIM (
+  Should Not Contain  ${result.stdout}  BLACKLIST_DKIM (
+
 *** Keywords ***
 Whitelist Setup
   ${PLUGIN_CONFIG} =  Get File  ${TESTDIR}/configs/whitelist.conf
index f0b6358527b94764f65989e90a2d42743b3dc0ba..04b0a9b12b400b221875f2f749160087b45beeda 100644 (file)
@@ -1,3 +1,5 @@
 example.com
-cacophony.za.org
-#other.com
+cacophony.za.org both:1.0
+highsecure.ru bl:1.0
+rspamd.com wl:2.0
+#other.com
\ No newline at end of file
index 9b8c3af63ab23e8a24cd2854013f2858a9b67963..7769f5cd42cd8779bfe3b4507c73c87f4de2d2e6 100644 (file)
@@ -3,16 +3,6 @@ dmarc {}
 whitelist {
 
   rules {
-        "BLACKLIST_DDS" = {
-            blacklist = true;
-            valid_dkim = true;
-            valid_dmarc = true;
-            valid_spf = true;
-            domains = [
-                "${TESTDIR}/configs/maps/domains.list",
-            ];
-            score = 3.0
-        }
 
         "WHITELIST_DDS" = {
             valid_dkim = true;
@@ -21,7 +11,8 @@ whitelist {
             domains = [
                 "${TESTDIR}/configs/maps/domains.list",
             ];
-            score = -3.0
+            score = -3.0;
+            inverse_symbol = "BLACKLIST_DDS";
         }
 
         "WHITELIST_DKIM" = {
@@ -30,16 +21,8 @@ whitelist {
                 "${TESTDIR}/configs/maps/domains.list",
             ];
             description = "Mail comes from the whitelisted domain and has a valid DKIM signature";
-            score = -1.0
-        }
-
-        "BLACKLIST_DKIM" = {
-            blacklist = true;
-            valid_dkim = true;
-            domains = [
-                "${TESTDIR}/configs/maps/domains.list",
-            ];
-            score = 3.0
+            score = -1.0;
+            inverse_symbol = "BLACKLIST_DKIM";
         }
 
         "WHITELIST_SPF" = {
@@ -48,16 +31,9 @@ whitelist {
                 "${TESTDIR}/configs/maps/domains.list",
             ];
             score = -1.0
+            inverse_multiplier = 3.0
             description = "Mail comes from the whitelisted domain and has a valid SPF policy";
-        }
-
-        "BLACKLIST_SPF" = {
-            blacklist = true;
-            valid_spf = true;
-            domains = [
-                "${TESTDIR}/configs/maps/domains.list",
-            ];
-            score = 3.0
+            inverse_symbol = "BLACKLIST_SPF";
         }
 
         "WHITELIST_DMARC_DKIM" = {
@@ -68,6 +44,7 @@ whitelist {
             ];
             score = -2.0;
             description = "Mail comes from the whitelisted domain and has valid DMARC and DKIM policies";
+            inverse_symbol = "BLACKLIST_DMARC_DKIM";
         }
 
         "WHITELIST_DMARC" = {
@@ -77,15 +54,7 @@ whitelist {
             ];
             score = -2.0;
             description = "Mail comes from the whitelisted domain and has valid DMARC policy";
-        }
-
-        "BLACKLIST_DMARC" = {
-            blacklist = true;
-            valid_dmarc = true;
-            domains = [
-                "${TESTDIR}/configs/maps/domains.list",
-            ];
-            score = 3.0;
+            inverse_symbol = "BLACKLIST_DMARC";
         }
 
         "STRICT_DMARC" = {