]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Rudimentary tests for known_senders plugin 4612/head
authorAndrew Lewis <nerf@judo.za.org>
Mon, 25 Sep 2023 13:35:40 +0000 (15:35 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Mon, 25 Sep 2023 14:34:36 +0000 (16:34 +0200)
test/functional/cases/400_known_senders.robot [new file with mode: 0644]
test/functional/configs/known_senders-local.conf [new file with mode: 0644]
test/functional/configs/known_senders.conf [new file with mode: 0644]
test/functional/configs/maps/known_senders_domains.map [new file with mode: 0644]
test/functional/lib/vars.py

diff --git a/test/functional/cases/400_known_senders.robot b/test/functional/cases/400_known_senders.robot
new file mode 100644 (file)
index 0000000..f258113
--- /dev/null
@@ -0,0 +1,36 @@
+*** Settings ***
+Suite Setup     Rspamd Redis Setup
+Suite Teardown  Rspamd Redis Teardown
+Library         ${RSPAMD_TESTDIR}/lib/rspamd.py
+Resource        ${RSPAMD_TESTDIR}/lib/rspamd.robot
+Variables       ${RSPAMD_TESTDIR}/lib/vars.py
+
+*** Variables ***
+${CONFIG}                         ${RSPAMD_TESTDIR}/configs/known_senders.conf
+${REDIS_SCOPE}                    Suite
+${RSPAMD_SCOPE}                   Suite
+
+*** Test Cases ***
+UNKNOWN SENDER
+  Scan File  ${RSPAMD_TESTDIR}/messages/spam_message.eml
+  ...  Settings={symbols_enabled [KNOWN_SENDER]}
+  Do Not Expect Symbol  KNOWN_SENDER
+  Expect Symbol  UNKNOWN_SENDER
+
+UNKNOWN SENDER BECOMES KNOWN
+  Scan File  ${RSPAMD_TESTDIR}/messages/spam_message.eml
+  ...  Settings={symbols_enabled [KNOWN_SENDER]}
+  Expect Symbol  KNOWN_SENDER
+  Do Not Expect Symbol  UNKNOWN_SENDER
+
+UNKNOWN SENDER WRONG DOMAIN
+  Scan File  ${RSPAMD_TESTDIR}/messages/empty_part.eml
+  ...  Settings={symbols_enabled [KNOWN_SENDER]}
+  Do Not Expect Symbol  KNOWN_SENDER
+  Do Not Expect Symbol  UNKNOWN_SENDER
+
+UNKNOWN SENDER WRONG DOMAIN RESCAN
+  Scan File  ${RSPAMD_TESTDIR}/messages/empty_part.eml
+  ...  Settings={symbols_enabled [KNOWN_SENDER]}
+  Do Not Expect Symbol  KNOWN_SENDER
+  Do Not Expect Symbol  UNKNOWN_SENDER
diff --git a/test/functional/configs/known_senders-local.conf b/test/functional/configs/known_senders-local.conf
new file mode 100644 (file)
index 0000000..40522ae
--- /dev/null
@@ -0,0 +1,4 @@
+known_senders {
+  enabled = true;
+  domains = "{= env.TESTDIR =}/configs/maps/known_senders_domains.map";
+}
diff --git a/test/functional/configs/known_senders.conf b/test/functional/configs/known_senders.conf
new file mode 100644 (file)
index 0000000..0880cea
--- /dev/null
@@ -0,0 +1,7 @@
+.include "{= env.TESTDIR =}/../../conf/rspamd.conf"
+
+lua = "{= env.TESTDIR =}/lua/test_coverage.lua"
+
+.include(priority=1,duplicate=merge) "{= env.TESTDIR =}/configs/known_senders-local.conf"
+.include(priority=1,duplicate=merge) "{= env.TESTDIR =}/configs/merged-local.conf"
+.include(priority=2,duplicate=replace) "{= env.TESTDIR =}/configs/merged-override.conf"
diff --git a/test/functional/configs/maps/known_senders_domains.map b/test/functional/configs/maps/known_senders_domains.map
new file mode 100644 (file)
index 0000000..8ddda0f
--- /dev/null
@@ -0,0 +1,2 @@
+outlook.com
+example.com
index 7d57f9f8f847427e028bf6478124baeea78b604e..898d21286ff556abdb2f2c6e2efd25bdebab1ea3 100644 (file)
@@ -1,6 +1,7 @@
 import socket
 
 CONTROLLER_ERRORS = True
+RSPAMD_EXTERNAL_RELAY_ENABLED = False
 RSPAMD_KEY_PVT1 = 'ekd3x36tfa5gd76t6pa8hqif3ott7n1siuux68exbkk7ukscte9y'
 RSPAMD_KEY_PUB1 = 'm8kneubpcjsb8sbsoj7jy7azj9fdd3xmj63txni86a8ye9ncomny'
 RSPAMD_LOCAL_ADDR = '127.0.0.1'