commit 2cb5d3d: [Test] Test multimap regexp_multi map

Andrew Lewis nerf at judo.za.org
Mon Jul 29 17:57:26 UTC 2024


Author: Andrew Lewis
Date: 2024-05-27 13:06:25 +0200
URL: https://github.com/rspamd/rspamd/commit/2cb5d3d1fe84ff5e1aace47cbd776369ff9258d4 (refs/pull/4988/head)

[Test] Test multimap regexp_multi map

---
 test/functional/cases/001_merged/102_multimap.robot | 7 +++++++
 test/functional/configs/maps/words.list             | 4 ++++
 test/functional/configs/merged-override.conf        | 6 ++++++
 test/functional/lib/rspamd.robot                    | 1 +
 test/functional/messages/words.eml                  | 3 +++
 5 files changed, 21 insertions(+)

diff --git a/test/functional/cases/001_merged/102_multimap.robot b/test/functional/cases/001_merged/102_multimap.robot
index 8e9d83d42..50d1af6b6 100644
--- a/test/functional/cases/001_merged/102_multimap.robot
+++ b/test/functional/cases/001_merged/102_multimap.robot
@@ -17,6 +17,7 @@ ${URL4}            ${RSPAMD_TESTDIR}/messages/url4.eml
 ${URL5}            ${RSPAMD_TESTDIR}/messages/url5.eml
 ${URL_ICS}         ${RSPAMD_TESTDIR}/messages/ics.eml
 ${UTF_MESSAGE}     ${RSPAMD_TESTDIR}/messages/utf.eml
+${WORDS_MESSAGE}   ${RSPAMD_TESTDIR}/messages/words.eml
 
 *** Test Cases ***
 URL_ICS
@@ -434,3 +435,9 @@ MAP - DYNAMIC SYMBOLS - MISS
   ...   Settings={symbols_enabled = [DYN_TEST1,DYN_TEST2,DYN_MULTIMAP]}
   Do Not Expect Symbol  DYN_TEST2
   Do Not Expect Symbol  DYN_TEST1
+
+REGEXP MULTI SCORES - ISSUE 4981
+  Scan File  ${WORDS_MESSAGE}
+  ...   Settings={symbols_enabled = [WORDTEST4981]}
+  Expect Symbol With Score  WORDTEST4981  4
+  Expect Score  4
diff --git a/test/functional/configs/maps/words.list b/test/functional/configs/maps/words.list
new file mode 100644
index 000000000..4d28612e8
--- /dev/null
+++ b/test/functional/configs/maps/words.list
@@ -0,0 +1,4 @@
+/\bfoo\b/
+/\bbar\b/
+/\bbaz\b/
+/\bqux\b/
diff --git a/test/functional/configs/merged-override.conf b/test/functional/configs/merged-override.conf
index 35f22630f..5a1570767 100644
--- a/test/functional/configs/merged-override.conf
+++ b/test/functional/configs/merged-override.conf
@@ -38,6 +38,12 @@ antivirus {
 }
 
 multimap {
+  WORDTEST4981 {
+    type = "content";
+    filter = "text";
+    map = "regexp_multi;{= env.TESTDIR =}/configs/maps/words.list";
+    score = 1.0;
+  }
   DNSBL_MAP {
     type = "dnsbl";
     map = "rspamd.com";
diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot
index f9614c6fa..254a6f3ca 100644
--- a/test/functional/lib/rspamd.robot
+++ b/test/functional/lib/rspamd.robot
@@ -90,6 +90,7 @@ Expect Required Score To Be Null
 Expect Score
   [Arguments]  ${score}
   Should Be Equal As Numbers  ${SCAN_RESULT}[score]  ${score}
+  ...  msg="Expected message score of ${score} but got ${SCAN_RESULT}[score]"
 
 Expect Symbol
   [Arguments]  ${symbol}
diff --git a/test/functional/messages/words.eml b/test/functional/messages/words.eml
new file mode 100644
index 000000000..d54d19321
--- /dev/null
+++ b/test/functional/messages/words.eml
@@ -0,0 +1,3 @@
+Content-type: text/plain
+
+lo foo bar baz qux bye


More information about the Commits mailing list