]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add more tests for milter_headers 5083/head
authorAndrew Lewis <nerf@judo.za.org>
Tue, 30 Jul 2024 14:16:28 +0000 (16:16 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Tue, 30 Jul 2024 14:16:28 +0000 (16:16 +0200)
test/functional/cases/550_milter_headers.robot
test/functional/configs/milter_headers.conf
test/functional/lib/rspamd.robot

index 737d0b42d0a4225e8275e2ac9a7c90ed4034aca9..80471b83c44e9b9e5ea6140da994ccdbfcf486c9 100644 (file)
@@ -11,10 +11,29 @@ ${MESSAGE}               ${RSPAMD_TESTDIR}/messages/zip.eml
 ${RSPAMD_SCOPE}          Suite
 ${RSPAMD_URL_TLD}        ${RSPAMD_TESTDIR}/../lua/unit/test_tld.dat
 ${SETTINGS_NOSYMBOLS}    {symbols_enabled = []}
-${SETTINGS_TEST}         {symbols_enabled = [SIMPLE_TEST]}
+${SETTINGS_TEST}         {SIMPLE_TEST = 2.0, symbols_enabled = [SIMPLE_TEST]}
 
 *** Test Cases ***
 CHECK HEADERS WITH TEST SYMBOL
   Scan File  ${MESSAGE}  Settings=${SETTINGS_TEST}
+  # Check X-Virus header
   Expect Removed Header  X-Virus
   Expect Added Header  X-Virus  Fires always
+  # Check My-Spamd-Bar header
+  Expect Added Header  My-Spamd-Bar  ++
+  Do Not Expect Removed Header  My-Spamd-Bar
+  # Check X-Spam-Level header
+  Expect Added Header  X-Spam-Level  **
+  Expect Removed Header  X-Spam-Level
+
+CHECK HEADERS WITHOUT TEST SYMBOL
+  Scan File  ${MESSAGE}  Settings=${SETTINGS_NOSYMBOLS}
+  # Check X-Virus header
+  Expect Removed Header  X-Virus
+  Do Not Expect Added Header  X-Virus
+  # Check My-Spamd-Bar header
+  Expect Added Header  My-Spamd-Bar  /
+  Do Not Expect Removed Header  My-Spamd-Bar
+  # Check X-Spam-Level header
+  Do Not Expect Added Header  X-Spam-Level
+  Expect Removed Header  X-Spam-Level
index 0787e9463d1fcde2088509c2006e4bf004da62f3..947bc28ddb844fa8d0d08973191f50ec99b7ce92 100644 (file)
@@ -4,9 +4,18 @@ lua = "{= env.TESTDIR =}/lua/simple.lua"
 
 milter_headers {
 
-  use = ["x-virus"];
+  use = ["remove-headers", "x-spam-level", "x-spamd-bar", "x-virus"];
 
   routines {
+    remove-headers {
+      headers {
+        "X-Spam-Level" = 0,
+      }
+    }
+    x-spamd-bar {
+      header = "My-Spamd-Bar";
+      remove = null;
+    }
     x-virus {
       symbols = ["SIMPLE_TEST"];
     }
index 917b012982d5f5ef850240d9941a6fcffac8b1c2..c45a19908b18eda4b61880f9169f22b4ee36d3fa 100644 (file)
@@ -60,6 +60,28 @@ Check Rspamc Match String
     Should Not Contain  ${subject}  ${str}
   END
 
+Do Not Expect Added Header
+  [Arguments]  ${header_name}
+  IF  'milter' not in ${SCAN_RESULT}
+    RETURN
+  END
+  IF  'add_headers' not in ${SCAN_RESULT}[milter]
+    RETURN
+  END
+  Dictionary Should Not Contain Key  ${SCAN_RESULT}[milter][add_headers]  ${header_name}
+  ...  msg=${header_name} was added
+
+Do Not Expect Removed Header
+  [Arguments]  ${header_name}
+  IF  'milter' not in ${SCAN_RESULT}
+    RETURN
+  END
+  IF  'remove_headers' not in ${SCAN_RESULT}[milter]
+    RETURN
+  END
+  Dictionary Should Not Contain Key  ${SCAN_RESULT}[milter][remove_headers]  ${header_name}
+  ...  msg=${header_name} was removed
+
 Do Not Expect Symbol
   [Arguments]  ${symbol}
   Dictionary Should Not Contain Key  ${SCAN_RESULT}[symbols]  ${symbol}