diff options
author | Andrew Lewis <nerf@judo.za.org> | 2017-04-26 16:35:20 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2017-04-26 16:35:20 +0200 |
commit | 1ca24ef40609f571241fc18151d8c8cc7ef02e78 (patch) | |
tree | bb7af0f92a251c750bb688a699d51780ca83ee1e /test/functional | |
parent | a31d3cddc4e366cbe2489a17cf2a124149e2fa21 (diff) | |
download | rspamd-1ca24ef40609f571241fc18151d8c8cc7ef02e78.tar.gz rspamd-1ca24ef40609f571241fc18151d8c8cc7ef02e78.zip |
[Test] Some tests for settings
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/cases/108_settings.robot | 41 | ||||
-rw-r--r-- | test/functional/configs/settings.conf | 3 | ||||
-rw-r--r-- | test/functional/lua/settings.lua | 26 |
3 files changed, 70 insertions, 0 deletions
diff --git a/test/functional/cases/108_settings.robot b/test/functional/cases/108_settings.robot new file mode 100644 index 000000000..9a5a92e42 --- /dev/null +++ b/test/functional/cases/108_settings.robot @@ -0,0 +1,41 @@ +*** Settings *** +Suite Setup Settings Setup +Suite Teardown Settings Teardown +Library ${TESTDIR}/lib/rspamd.py +Resource ${TESTDIR}/lib/rspamd.robot +Variables ${TESTDIR}/lib/vars.py + +*** Variables *** +${CONFIG} ${TESTDIR}/configs/plugins.conf +${LUA_SCRIPT} ${TESTDIR}/lua/settings.lua +${MESSAGE} ${TESTDIR}/messages/spam_message.eml +${RSPAMD_SCOPE} Suite +${URL_TLD} ${TESTDIR}/../lua/unit/test_tld.dat + +*** Test Cases *** +NO SETTINGS + ${result} = Scan Message With Rspamc ${MESSAGE} + Check Rspamc ${result} SIMPLE_TEST + Should Contain ${result.stdout} SIMPLE_PRE + Should Contain ${result.stdout} SIMPLE_POST + +ENABLE SYMBOL - SIMPLE_TEST + ${result} = Scan Message With Rspamc ${MESSAGE} --header Settings={symbols_enabled = ["SIMPLE_TEST"]} + Check Rspamc ${result} SIMPLE_TEST + Should Not Contain ${result.stdout} SIMPLE_PRE + Should Not Contain ${result.stdout} SIMPLE_POST + +ENABLE SYMBOL - SIMPLE_POST + ${result} = Scan Message With Rspamc ${MESSAGE} --header Settings={symbols_enabled = ["SIMPLE_TEST", "SIMPLE_POST"]} + Check Rspamc ${result} SIMPLE_TEST + Should Contain ${result.stdout} SIMPLE_POST + Should Not Contain ${result.stdout} SIMPLE_PRE + +*** Keywords *** +Settings Setup + ${PLUGIN_CONFIG} = Get File ${TESTDIR}/configs/settings.conf + Set Suite Variable ${PLUGIN_CONFIG} + Generic Setup PLUGIN_CONFIG + +Settings Teardown + Normal Teardown diff --git a/test/functional/configs/settings.conf b/test/functional/configs/settings.conf new file mode 100644 index 000000000..d6baa9596 --- /dev/null +++ b/test/functional/configs/settings.conf @@ -0,0 +1,3 @@ +lua = ${LUA_SCRIPT}; + +settings { } diff --git a/test/functional/lua/settings.lua b/test/functional/lua/settings.lua new file mode 100644 index 000000000..0be6f71bf --- /dev/null +++ b/test/functional/lua/settings.lua @@ -0,0 +1,26 @@ +rspamd_config:register_symbol({ + name = 'SIMPLE_PRE', + score = 1.0, + priority = 9, -- after settings + type = 'prefilter', + callback = function() + return true, 'Fires always' + end +}) + +rspamd_config:register_symbol({ + name = 'SIMPLE_POST', + score = 1.0, + type = 'postfilter', + callback = function() + return true, 'Fires always' + end +}) + +rspamd_config:register_symbol({ + name = 'SIMPLE_TEST', + score = 1.0, + callback = function() + return true, 'Fires always' + end +}) |