From f13fc5a747acc490f8ed99f1b15677b29cbf93f6 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 25 Jun 2019 18:37:21 +0100 Subject: [Test] Add moar tests for settings --- test/functional/cases/108_settings.robot | 67 +++++++++++++++++++++++++++ test/functional/configs/settings.conf | 14 ++++++ test/functional/messages/empty-plain-text.eml | 1 + 3 files changed, 82 insertions(+) (limited to 'test/functional') diff --git a/test/functional/cases/108_settings.robot b/test/functional/cases/108_settings.robot index 2fc27ea70..9de9a48a6 100644 --- a/test/functional/cases/108_settings.robot +++ b/test/functional/cases/108_settings.robot @@ -9,6 +9,9 @@ Variables ${TESTDIR}/lib/vars.py ${CONFIG} ${TESTDIR}/configs/plugins.conf ${LUA_SCRIPT} ${TESTDIR}/lua/settings.lua ${MESSAGE} ${TESTDIR}/messages/spam_message.eml +${MESSAGE_7BIT} ${TESTDIR}/messages/utf.eml +${MESSAGE_CUSTOM_HDR} ${TESTDIR}/messages/empty-plain-text.eml +${MESSAGE_ABSENT_MIME} ${TESTDIR}/messages/ed25519.eml ${SPAM_MESSAGE} ${TESTDIR}/messages/spam.eml ${HAM_MESSAGE} ${TESTDIR}/messages/ham.eml ${RSPAMD_SCOPE} Suite @@ -113,6 +116,70 @@ SETTINGS ID - VIRTUAL GROUP Should Not Contain ${result.stdout} SIMPLE_POST Should Not Contain ${result.stdout} SIMPLE_PRE +SETTINGS ID - VIRTUAL FROM + ${result} = Scan Message With Rspamc ${MESSAGE} --from test2@example.com + Check Rspamc ${result} SIMPLE_VIRTUAL (10 + Should Not Contain ${result.stdout} SIMPLE_TEST + Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} SIMPLE_POST + Should Not Contain ${result.stdout} SIMPLE_PRE + +SETTINGS ID - VIRTUAL USER + ${result} = Scan Message With Rspamc ${MESSAGE} --user test@example.com + Check Rspamc ${result} SIMPLE_VIRTUAL (10 + Should Not Contain ${result.stdout} SIMPLE_TEST + Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} SIMPLE_POST + Should Not Contain ${result.stdout} SIMPLE_PRE + +SETTINGS ID - VIRTUAL HOSTNAME + ${result} = Scan Message With Rspamc ${MESSAGE} --hostname example.com + Check Rspamc ${result} SIMPLE_VIRTUAL (10 + Should Not Contain ${result.stdout} SIMPLE_TEST + Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} SIMPLE_POST + Should Not Contain ${result.stdout} SIMPLE_PRE + +SETTINGS ID - VIRTUAL SELECTOR + ${result} = Scan Message With Rspamc ${MESSAGE} --rcpt user3@example.com + Check Rspamc ${result} SIMPLE_VIRTUAL (10 + Should Not Contain ${result.stdout} SIMPLE_TEST + Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} SIMPLE_POST + Should Not Contain ${result.stdout} SIMPLE_PRE + +SETTINGS ID - VIRTUAL HEADER MATCH + ${result} = Scan Message With Rspamc ${MESSAGE_7BIT} + Check Rspamc ${result} SIMPLE_VIRTUAL (10 + Should Not Contain ${result.stdout} SIMPLE_TEST + Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} SIMPLE_POST + Should Not Contain ${result.stdout} SIMPLE_PRE + +SETTINGS ID - VIRTUAL HEADER EXISTS + ${result} = Scan Message With Rspamc ${MESSAGE_CUSTOM_HDR} + Check Rspamc ${result} SIMPLE_VIRTUAL (10 + Should Not Contain ${result.stdout} SIMPLE_TEST + Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} SIMPLE_POST + Should Not Contain ${result.stdout} SIMPLE_PRE + +SETTINGS ID - VIRTUAL HEADER ABSENT + ${result} = Scan Message With Rspamc ${MESSAGE_ABSENT_MIME} + Check Rspamc ${result} SIMPLE_VIRTUAL (10 + Should Not Contain ${result.stdout} SIMPLE_TEST + Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} SIMPLE_POST + Should Not Contain ${result.stdout} SIMPLE_PRE + +SETTINGS ID - VIRTUAL REQUEST HEADER + ${result} = Scan Message With Rspamc ${MESSAGE} --header Test=passed + Check Rspamc ${result} SIMPLE_VIRTUAL (10 + Should Not Contain ${result.stdout} SIMPLE_TEST + Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} SIMPLE_POST + Should Not Contain ${result.stdout} SIMPLE_PRE + *** Keywords *** Settings Setup Copy File ${TESTDIR}/data/bayes.spam.sqlite3 /tmp/bayes.spam.sqlite3 diff --git a/test/functional/configs/settings.conf b/test/functional/configs/settings.conf index d46c46b30..8a68465f4 100644 --- a/test/functional/configs/settings.conf +++ b/test/functional/configs/settings.conf @@ -21,6 +21,20 @@ settings { } id_virtual_group { + user = "test@example.com"; + from = "test2@example.com"; + hostname = "example.com"; + selector = "rcpts:addr.in(test3@example.com)"; + header = { + "Content-Transfer-Encoding" = "7bit"; + "Custom-Header" = true; + "Mime-Version" = false; + } + request_header = { + "Test" = "passed"; + } + + expression = 'user || from || hostname || selector:1 || header:mime_version || header:custom_header || header:1 || request_header:test' apply { groups_enabled = ["vg"]; SIMPLE_VIRTUAL = 10.0; diff --git a/test/functional/messages/empty-plain-text.eml b/test/functional/messages/empty-plain-text.eml index 2c4fa3e90..1deeaf1ad 100644 --- a/test/functional/messages/empty-plain-text.eml +++ b/test/functional/messages/empty-plain-text.eml @@ -10,5 +10,6 @@ Message-ID: Subject: Test Subject To: Me Content-Type: text/plain; charset="UTF-8" +Custom-Header: foo -- cgit v1.2.3