From: Andrew Lewis Date: Mon, 25 Sep 2023 13:35:40 +0000 (+0200) Subject: [Test] Rudimentary tests for known_senders plugin X-Git-Tag: 3.7.1~11^2^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0059d2e216e8a43036aa1e19c6cfeff02ff8abcb;p=rspamd.git [Test] Rudimentary tests for known_senders plugin --- 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'