aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudiu Dragalina-Paraipan <dr.clau@gmail.com>2025-06-05 21:40:07 +0300
committerClaudiu Dragalina-Paraipan <dr.clau@gmail.com>2025-06-05 21:40:07 +0300
commitfdad8e3d0ed36c2adfc7b18e4f150ecdd584e9a1 (patch)
treef17182f66c10eed61119fd49c27a2eca0486cd57
parentf60cd32049ceb6bfd9786a09b6fb839c0f28bc27 (diff)
downloadrspamd-fdad8e3d0ed36c2adfc7b18e4f150ecdd584e9a1.tar.gz
rspamd-fdad8e3d0ed36c2adfc7b18e4f150ecdd584e9a1.zip
[Fix] correct logic error in milter_headers.lua: skip_wanted()
- fix logic error in skip_wanted() - add new functional test for this scenario - add override settings in milter_headers.conf to support the testing - add supporting functionality in rspamd.robot
-rw-r--r--src/plugins/lua/milter_headers.lua2
-rw-r--r--test/functional/cases/550_milter_headers.robot11
-rw-r--r--test/functional/configs/milter_headers.conf12
-rw-r--r--test/functional/lib/rspamd.robot9
4 files changed, 33 insertions, 1 deletions
diff --git a/src/plugins/lua/milter_headers.lua b/src/plugins/lua/milter_headers.lua
index 2daeeed78..17fc90562 100644
--- a/src/plugins/lua/milter_headers.lua
+++ b/src/plugins/lua/milter_headers.lua
@@ -138,7 +138,7 @@ local function milter_headers(task)
local function skip_wanted(hdr)
if settings_override then
- return true
+ return false
end
-- Normal checks
local function match_extended_headers_rcpt()
diff --git a/test/functional/cases/550_milter_headers.robot b/test/functional/cases/550_milter_headers.robot
index 80471b83c..c09659714 100644
--- a/test/functional/cases/550_milter_headers.robot
+++ b/test/functional/cases/550_milter_headers.robot
@@ -37,3 +37,14 @@ CHECK HEADERS WITHOUT TEST SYMBOL
# Check X-Spam-Level header
Do Not Expect Added Header X-Spam-Level
Expect Removed Header X-Spam-Level
+
+CHECK HEADERS WITH OVERRIDE SETTINGS
+ # id_milter_headers_override setting enables only authentication-results and x-spam-level routines
+ Scan File ${MESSAGE} Settings-Id=id_milter_headers_override
+ # Test the milter_headers override behavior
+ # Check that Authentication-Results and X-Spam-Level headers are present (exact values are not important)
+ Expect Header Is Present Authentication-Results
+ Expect Header Is Present X-Spam-Level
+ # Verify other headers are not added since only authentication-results and x-spam-level routines run
+ Do Not Expect Added Header X-Virus
+ Do Not Expect Added Header My-Spamd-Bar
diff --git a/test/functional/configs/milter_headers.conf b/test/functional/configs/milter_headers.conf
index 947bc28dd..502747605 100644
--- a/test/functional/configs/milter_headers.conf
+++ b/test/functional/configs/milter_headers.conf
@@ -22,3 +22,15 @@ milter_headers {
}
}
+
+settings {
+ id_milter_headers_override {
+ apply {
+ plugins {
+ milter_headers {
+ routines = [ authentication-results, x-spam-level ];
+ }
+ }
+ }
+ }
+}
diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot
index 9c30a97db..5d23e3ceb 100644
--- a/test/functional/lib/rspamd.robot
+++ b/test/functional/lib/rspamd.robot
@@ -120,6 +120,15 @@ Expect Added Header
Should Be Equal ${SCAN_RESULT}[milter][add_headers][${header_name}][value] ${header_value}
Should Be Equal as Numbers ${SCAN_RESULT}[milter][add_headers][${header_name}][order] ${pos}
+Expect Header Is Present
+ [Arguments] ${header_name}
+ Dictionary Should Contain Key ${SCAN_RESULT} milter
+ ... msg=milter block was not present in protocol response
+ Dictionary Should Contain Key ${SCAN_RESULT}[milter] add_headers
+ ... msg=add_headers block was not present in protocol response
+ Dictionary Should Contain Key ${SCAN_RESULT}[milter][add_headers] ${header_name}
+ ... msg=${header_name} was not added
+
Expect Email
[Arguments] ${email}
List Should Contain Value ${SCAN_RESULT}[emails] ${email}