commit 0059d2e: [Test] Rudimentary tests for known_senders plugin

Andrew Lewis nerf at judo.za.org
Wed Sep 27 13:14:03 UTC 2023


Author: Andrew Lewis
Date: 2023-09-25 15:35:40 +0200
URL: https://github.com/rspamd/rspamd/commit/0059d2e216e8a43036aa1e19c6cfeff02ff8abcb (refs/pull/4612/head)

[Test] Rudimentary tests for known_senders plugin

---
 test/functional/cases/400_known_senders.robot      | 36 ++++++++++++++++++++++
 test/functional/configs/known_senders-local.conf   |  4 +++
 test/functional/configs/known_senders.conf         |  7 +++++
 .../configs/maps/known_senders_domains.map         |  2 ++
 test/functional/lib/vars.py                        |  1 +
 5 files changed, 50 insertions(+)

diff --git a/test/functional/cases/400_known_senders.robot b/test/functional/cases/400_known_senders.robot
new file mode 100644
index 000000000..f258113da
--- /dev/null
+++ b/test/functional/cases/400_known_senders.robot
@@ -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
index 000000000..40522ae47
--- /dev/null
+++ b/test/functional/configs/known_senders-local.conf
@@ -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
index 000000000..0880ceaf7
--- /dev/null
+++ b/test/functional/configs/known_senders.conf
@@ -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
index 000000000..8ddda0fd4
--- /dev/null
+++ b/test/functional/configs/maps/known_senders_domains.map
@@ -0,0 +1,2 @@
+outlook.com
+example.com
diff --git a/test/functional/lib/vars.py b/test/functional/lib/vars.py
index 7d57f9f8f..898d21286 100644
--- a/test/functional/lib/vars.py
+++ b/test/functional/lib/vars.py
@@ -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'


More information about the Commits mailing list