From: Vsevolod Stakhov Date: Thu, 28 Jul 2016 12:57:55 +0000 (+0100) Subject: [Test] Reorder tests X-Git-Tag: 1.3.1~44 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d4bab2f70adbabf14e734f4c9bc497843c298f5c;p=rspamd.git [Test] Reorder tests --- diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index 3851e26c4..d4fcee6e4 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -29,7 +29,9 @@ local function ip_to_rbl(ip, rbl) return table.concat(ip:inversed_str_octets(), ".") .. '.' .. rbl end -local function multimap_callback(task, pre_filter) +local function multimap_callback(task, rule) + local pre_filter = rule['prefilter'] + -- Applies specific filter for input local function apply_filter(filter, input, rule) if filter == 'email:addr' or filter == 'email' then @@ -345,97 +347,16 @@ local function multimap_callback(task, pre_filter) end end - -- IP rules - local ip = task:get_from_ip() - if ip:is_valid() then - each(function(r) match_rule(r, ip) end, - filter(function(r) - return pre_filter == r['prefilter'] and r['type'] == 'ip' - end, rules)) - end - - -- Header rules - each(function(r) - local hv = task:get_header_full(r['header']) - match_list(r, hv, {'decoded'}) - end, - filter(function(r) - return pre_filter == r['prefilter'] and r['type'] == 'header' - end, rules)) - - -- Rcpt rules - if task:has_recipients() then - local rcpts = task:get_recipients() - each(function(r) - match_addr(r, rcpts) - end, - filter(function(r) - return pre_filter == r['prefilter'] and r['type'] == 'rcpt' - end, rules)) - end - - -- From rules - if task:has_from() then - local from = task:get_from() - if from then - each(function(r) - match_addr(r, from) - end, - filter(function(r) - return pre_filter == r['prefilter'] and r['type'] == 'from' - end, rules)) - end - end - -- URL rules - if task:has_urls() then - local urls = task:get_urls() - for i,url in ipairs(urls) do - each(function(r) - match_url(r, url) - end, - filter(function(r) - return pre_filter == r['prefilter'] and r['type'] == 'url' - end, rules)) - end - end - -- Filename rules - local function check_file(fn) - each(function(r) - match_filename(r, fn) - end, - filter(function(r) - return pre_filter == r['prefilter'] and r['type'] == 'filename' - end, rules)) - end - -- Body rules - each(function(r) - match_content(r) - end, - filter(function(r) - return pre_filter == r['prefilter'] and r['type'] == 'content' - end, rules)) - - local parts = task:get_parts() - for i,p in ipairs(parts) do - if p:is_archive() then - local fnames = p:get_archive():get_files() - - for ii,fn in ipairs(fnames) do - check_file(fn) - end - end - - local fn = p:get_filename() - if fn then - check_file(fn) - end - end - -- RBL rules - if ip:is_valid() then - each(function(r) + local rt = rule['type'] + if rt == 'ip' or rt == 'dnsbl' then + local ip = task:get_from_ip() + if ip:is_valid() then + if rt == 'ip' then + match_rule(rule, ip) + else local cb = function (resolver, to_resolve, results, err, rbl) if results then - task:insert_result(r['symbol'], 1, r['map']) + task:insert_result(rule['symbol'], 1, r['map']) if pre_filter then task:set_pre_result(r['action'], 'Matched map: ' .. r['symbol']) @@ -444,22 +365,56 @@ local function multimap_callback(task, pre_filter) end task:get_resolver():resolve_a({task = task, - name = ip_to_rbl(ip, r['map']), + name = ip_to_rbl(ip, rule['map']), callback = cb, - }) - end, - filter(function(r) - return pre_filter == r['prefilter'] and r['type'] == 'dnsbl' - end, rules)) - end -end + }) + end + end + elseif rt == 'header' then + local hv = task:get_header_full(r['header']) + match_list(rule, hv, {'decoded'}) + elseif rt == 'rcpt' then + if task:has_recipients('smtp') then + local rcpts = task:get_recipients('smtp') + match_addr(rule, rcpts) + end + elseif rt == 'from' then + if task:has_from('smtp') then + local from = task:get_from('smtp') + match_addr(rule, from) + end + elseif rt == 'url' then + if task:has_urls() then + local urls = task:get_urls() + for i,url in ipairs(urls) do + match_url(rule, url) + end + end + elseif rt == 'filename' then + local parts = task:get_parts() + for i,p in ipairs(parts) do + if p:is_archive() then + local fnames = p:get_archive():get_files() + + for ii,fn in ipairs(fnames) do + match_filename(rule, fn) + end + end -local function multimap_filter_callback(task) - multimap_callback(task, false) + local fn = p:get_filename() + if fn then + match_filename(rule, fn) + end + end + elseif rt == 'content' then + match_content(rule) + end end -local function multimap_prefilter_callback(task) - multimap_callback(task, true) +local function gen_multimap_callback(rule) + return function(task) + multimap_callback(task, rule) + end end local function add_multimap_rule(key, newrule) @@ -587,17 +542,11 @@ if opts and type(opts) == 'table' then end -- add fake symbol to check all maps inside a single callback if any(function(r) return not r['prefilter'] end, rules) then - local id = rspamd_config:register_symbol({ - type = 'callback', - priority = -1, - callback = multimap_filter_callback, - flags = 'empty' - }) for i,rule in ipairs(rules) do rspamd_config:register_symbol({ - type = 'virtual', + type = 'normal', name = rule['symbol'], - parent = id, + callback = gen_multimap_callback(rule), }) end end @@ -605,8 +554,8 @@ if opts and type(opts) == 'table' then if any(function(r) return r['prefilter'] end, rules) then rspamd_config:register_symbol({ type = 'prefilter', - name = 'MULTIMAP_PREFILTERS', - callback = multimap_prefilter_callback + name = rule['symbol'], + callback = gen_multimap_callback(rule), }) end end diff --git a/test/functional/cases/100_general.robot b/test/functional/cases/100_general.robot new file mode 100644 index 000000000..8876ef980 --- /dev/null +++ b/test/functional/cases/100_general.robot @@ -0,0 +1,42 @@ +*** Settings *** +Suite Setup Generic Setup +Suite Teardown Generic Teardown +Library ${TESTDIR}/lib/rspamd.py +Resource ${TESTDIR}/lib/rspamd.robot +Variables ${TESTDIR}/lib/vars.py + +*** Variables *** +${CONFIG} ${TESTDIR}/configs/trivial.conf +${GTUBE} ${TESTDIR}/messages/gtube.eml +${RSPAMD_SCOPE} Suite + +*** Test Cases *** +GTUBE + ${result} = Scan Message With Rspamc ${GTUBE} + Check Rspamc ${result} GTUBE ( + +GTUBE - Encrypted + ${result} = Run Rspamc -p -h ${LOCAL_ADDR}:${PORT_NORMAL} --key ${KEY_PUB1} + ... ${GTUBE} + Check Rspamc ${result} GTUBE ( + +GTUBE - Scan File feature + ${result} = Scan File ${LOCAL_ADDR} ${PORT_NORMAL} ${GTUBE} + Follow Rspamd Log + Should Contain ${result} GTUBE + +GTUBE - Scan File feature (encoded) + ${encoded} = Encode Filename ${GTUBE} + ${result} = Scan File ${LOCAL_ADDR} ${PORT_NORMAL} ${encoded} + Follow Rspamd Log + Should Contain ${result} GTUBE + +GTUBE - SPAMC + ${result} = Spamc ${LOCAL_ADDR} ${PORT_NORMAL} ${GTUBE} + Follow Rspamd Log + Should Contain ${result} GTUBE + +GTUBE - RSPAMC + ${result} = Rspamc ${LOCAL_ADDR} ${PORT_NORMAL} ${GTUBE} + Follow Rspamd Log + Should Contain ${result} GTUBE diff --git a/test/functional/cases/101_lua.robot b/test/functional/cases/101_lua.robot new file mode 100644 index 000000000..5e5dff6c8 --- /dev/null +++ b/test/functional/cases/101_lua.robot @@ -0,0 +1,35 @@ +*** Settings *** +Test Teardown Generic Teardown +Library ${TESTDIR}/lib/rspamd.py +Resource ${TESTDIR}/lib/rspamd.robot +Variables ${TESTDIR}/lib/vars.py + +*** Variables *** +${CONFIG} ${TESTDIR}/configs/lua_test.conf +${MESSAGE} ${TESTDIR}/messages/spam_message.eml +${RSPAMD_SCOPE} Test + +*** Test Cases *** +Flags + [Setup] Lua Setup ${TESTDIR}/lua/flags.lua + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} stat + Should Contain ${result.stdout} Messages scanned: 0 + +Dependencies + [Setup] Lua Setup ${TESTDIR}/lua/deps.lua + ${result} = Scan Message With Rspamc ${MESSAGE} + Check Rspamc ${result} DEP10 + +Pre and Post Filters + [Setup] Lua Setup ${TESTDIR}/lua/prepostfilters.lua + ${result} = Scan Message With Rspamc ${MESSAGE} + Check Rspamc ${result} TEST_PRE + Check Rspamc ${result} TEST_POST rc_nocheck=1 + +*** Keywords *** +Lua Setup + [Arguments] ${LUA_SCRIPT} + Set Test Variable ${LUA_SCRIPT} + Generic Setup diff --git a/test/functional/cases/105_archives.robot b/test/functional/cases/105_archives.robot new file mode 100644 index 000000000..16a14bfda --- /dev/null +++ b/test/functional/cases/105_archives.robot @@ -0,0 +1,23 @@ +*** Settings *** +Suite Setup Generic Setup +Suite Teardown Generic Teardown +Library ${TESTDIR}/lib/rspamd.py +Resource ${TESTDIR}/lib/rspamd.robot +Variables ${TESTDIR}/lib/vars.py + +*** Variables *** +${CONFIG} ${TESTDIR}/configs/plugins.conf +${RSPAMD_SCOPE} Suite + +*** Test Cases *** +Zip + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/zip.eml + Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[exe\\]\\n re=1 + +Zip Double Bad Extension + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/zip-doublebad.eml + Check Rspamc ${result} MIME_DOUBLE_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[\\.pdf\\.exe\\]\\n re=1 + +Rar4 + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/rar4.eml + Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[exe\\]\\n re=1 diff --git a/test/functional/cases/110_statistics/compat-keyed.robot b/test/functional/cases/110_statistics/compat-keyed.robot new file mode 100644 index 000000000..1242df12c --- /dev/null +++ b/test/functional/cases/110_statistics/compat-keyed.robot @@ -0,0 +1,20 @@ +*** Settings *** +Suite Setup Statistics Setup +Suite Teardown Statistics Teardown +Resource lib.robot + +*** Variables *** +${STATS_BACKEND} mmap +${STATS_HASH} hash = "compat"; +${STATS_KEY} key = "${KEY_PVT1}"; +${STATS_PATH_CACHE} name = "sqlite3"; path = "\${TMPDIR}/learn_cache.db"; + +*** Test Cases *** +Learn + Learn Test + +Relearn + Relearn Test + +Empty Part + Empty Part Test diff --git a/test/functional/cases/110_statistics/compat-plain.robot b/test/functional/cases/110_statistics/compat-plain.robot new file mode 100644 index 000000000..12bbaedcd --- /dev/null +++ b/test/functional/cases/110_statistics/compat-plain.robot @@ -0,0 +1,19 @@ +*** Settings *** +Suite Setup Statistics Setup +Suite Teardown Statistics Teardown +Resource lib.robot + +*** Variables *** +${STATS_BACKEND} mmap +${STATS_HASH} hash = "compat"; +${STATS_PATH_CACHE} name = "sqlite3"; path = "\${TMPDIR}/learn_cache.db"; + +*** Test Cases *** +Learn + Learn Test + +Relearn + Relearn Test + +Empty Part + Empty Part Test diff --git a/test/functional/cases/110_statistics/lib.robot b/test/functional/cases/110_statistics/lib.robot new file mode 100644 index 000000000..5f9e96038 --- /dev/null +++ b/test/functional/cases/110_statistics/lib.robot @@ -0,0 +1,57 @@ +*** Settings *** +Library ${TESTDIR}/lib/rspamd.py +Resource ${TESTDIR}/lib/rspamd.robot +Variables ${TESTDIR}/lib/vars.py + +*** Variables *** +${CONFIG} ${TESTDIR}/configs/stats.conf +${MESSAGE} ${TESTDIR}/messages/spam_message.eml +${REDIS_SCOPE} Suite +${REDIS_SERVER} ${EMPTY} +${RSPAMD_SCOPE} Suite +${STATS_HASH} ${EMPTY} +${STATS_KEY} ${EMPTY} +${STATS_PATH_CACHE} path = "\${TMPDIR}/bayes-cache.sqlite"; +${STATS_PATH_HAM} path = "\${TMPDIR}/bayes-ham.sqlite"; +${STATS_PATH_SPAM} path = "\${TMPDIR}/bayes-spam.sqlite"; + +*** Keywords *** +Broken Learn Test + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} + Check Rspamc ${result} cannot find statfile backend + +Empty Part Test + Set Test Variable ${MESSAGE} ${TESTDIR}/messages/empty_part.eml + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} + Check Rspamc ${result} + ${result} = Scan Message With Rspamc ${MESSAGE} + Check Rspamc ${result} BAYES_SPAM + +Learn Test + Set Suite Variable ${RSPAMD_STATS_LEARNTEST} 0 + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} + Check Rspamc ${result} + ${result} = Scan Message With Rspamc ${MESSAGE} + Check Rspamc ${result} BAYES_SPAM + Set Suite Variable ${RSPAMD_STATS_LEARNTEST} 1 + +Relearn Test + Run Keyword If ${RSPAMD_STATS_LEARNTEST} == 0 Fail "Learn test was not run" + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_ham ${MESSAGE} + Check Rspamc ${result} + ${result} = Scan Message With Rspamc ${MESSAGE} + Check Rspamc ${result} BAYES_HAM + +Redis Statistics Setup + Generic Setup + Run Redis + +Redis Statistics Teardown + Generic Teardown + Shutdown Process With Children ${REDIS_PID} + +Statistics Setup + Generic Setup STATS_PATH_CACHE STATS_PATH_HAM STATS_PATH_SPAM + +Statistics Teardown + Generic Teardown diff --git a/test/functional/cases/110_statistics/redis-keyed-siphash.robot b/test/functional/cases/110_statistics/redis-keyed-siphash.robot new file mode 100644 index 000000000..ec95efcd1 --- /dev/null +++ b/test/functional/cases/110_statistics/redis-keyed-siphash.robot @@ -0,0 +1,20 @@ +*** Settings *** +Suite Setup Redis Statistics Setup +Suite Teardown Redis Statistics Teardown +Resource lib.robot + +*** Variables *** +${REDIS_SERVER} servers = "${REDIS_ADDR}:${REDIS_PORT}" +${STATS_BACKEND} redis +${STATS_HASH} hash = "siphash"; +${STATS_KEY} key = "${KEY_PVT1}"; + +*** Test Cases *** +Learn + Learn Test + +Relearn + Relearn Test + +Empty Part + Empty Part Test diff --git a/test/functional/cases/110_statistics/redis-keyed-xxhash.robot b/test/functional/cases/110_statistics/redis-keyed-xxhash.robot new file mode 100644 index 000000000..5a7b2daf3 --- /dev/null +++ b/test/functional/cases/110_statistics/redis-keyed-xxhash.robot @@ -0,0 +1,20 @@ +*** Settings *** +Suite Setup Redis Statistics Setup +Suite Teardown Redis Statistics Teardown +Resource lib.robot + +*** Variables *** +${REDIS_SERVER} servers = "${REDIS_ADDR}:${REDIS_PORT}" +${STATS_BACKEND} redis +${STATS_HASH} hash = "xxhash"; +${STATS_KEY} key = "${KEY_PVT1}"; + +*** Test Cases *** +Learn + Learn Test + +Relearn + Relearn Test + +Empty Part + Empty Part Test diff --git a/test/functional/cases/110_statistics/redis-plain-siphash.robot b/test/functional/cases/110_statistics/redis-plain-siphash.robot new file mode 100644 index 000000000..d436b1a68 --- /dev/null +++ b/test/functional/cases/110_statistics/redis-plain-siphash.robot @@ -0,0 +1,19 @@ +*** Settings *** +Suite Setup Redis Statistics Setup +Suite Teardown Redis Statistics Teardown +Resource lib.robot + +*** Variables *** +${REDIS_SERVER} servers = "${REDIS_ADDR}:${REDIS_PORT}" +${STATS_BACKEND} redis +${STATS_HASH} hash = "siphash"; + +*** Test Cases *** +Learn + Learn Test + +Relearn + Relearn Test + +Empty Part + Empty Part Test diff --git a/test/functional/cases/110_statistics/redis-plain-xxhash.robot b/test/functional/cases/110_statistics/redis-plain-xxhash.robot new file mode 100644 index 000000000..0c45ac16b --- /dev/null +++ b/test/functional/cases/110_statistics/redis-plain-xxhash.robot @@ -0,0 +1,19 @@ +*** Settings *** +Suite Setup Redis Statistics Setup +Suite Teardown Redis Statistics Teardown +Resource lib.robot + +*** Variables *** +${REDIS_SERVER} servers = "${REDIS_ADDR}:${REDIS_PORT}" +${STATS_BACKEND} redis +${STATS_HASH} hash = "xxhash"; + +*** Test Cases *** +Learn + Learn Test + +Relearn + Relearn Test + +Empty Part + Empty Part Test diff --git a/test/functional/cases/110_statistics/sqlite-broken-stats-dir.robot b/test/functional/cases/110_statistics/sqlite-broken-stats-dir.robot new file mode 100644 index 000000000..57d75c294 --- /dev/null +++ b/test/functional/cases/110_statistics/sqlite-broken-stats-dir.robot @@ -0,0 +1,15 @@ +*** Settings *** +Suite Setup Generic Setup +Suite Teardown Generic Teardown +Resource ${TESTDIR}/lib/rspamd.robot +Resource lib.robot + +*** Variables *** +${STATS_BACKEND} sqlite3 +${STATS_PATH_CACHE} path = "/does/not/exist/bayes-cache.sqlite"; +${STATS_PATH_HAM} path = "/does/not/exist/bayes-ham.sqlite"; +${STATS_PATH_SPAM} path = "/does/not/exist/bayes-spam.sqlite"; + +*** Test Cases *** +Broken Stats Directory + Broken Learn Test diff --git a/test/functional/cases/110_statistics/sqlite-keyed-siphash.robot b/test/functional/cases/110_statistics/sqlite-keyed-siphash.robot new file mode 100644 index 000000000..8b9661a9a --- /dev/null +++ b/test/functional/cases/110_statistics/sqlite-keyed-siphash.robot @@ -0,0 +1,19 @@ +*** Settings *** +Suite Setup Statistics Setup +Suite Teardown Statistics Teardown +Resource lib.robot + +*** Variables *** +${STATS_BACKEND} sqlite3 +${STATS_HASH} hash = "siphash"; +${STATS_KEY} key = "${KEY_PVT1}"; + +*** Test Cases *** +Learn + Learn Test + +Relearn + Relearn Test + +Empty Part + Empty Part Test diff --git a/test/functional/cases/110_statistics/sqlite-keyed-xxhash.robot b/test/functional/cases/110_statistics/sqlite-keyed-xxhash.robot new file mode 100644 index 000000000..7a51e93ae --- /dev/null +++ b/test/functional/cases/110_statistics/sqlite-keyed-xxhash.robot @@ -0,0 +1,19 @@ +*** Settings *** +Suite Setup Statistics Setup +Suite Teardown Statistics Teardown +Resource lib.robot + +*** Variables *** +${STATS_BACKEND} sqlite3 +${STATS_HASH} hash = "xxhash"; +${STATS_KEY} key = "${KEY_PVT1}"; + +*** Test Cases *** +Learn + Learn Test + +Relearn + Relearn Test + +Empty Part + Empty Part Test diff --git a/test/functional/cases/110_statistics/sqlite-plain-siphash.robot b/test/functional/cases/110_statistics/sqlite-plain-siphash.robot new file mode 100644 index 000000000..2f88e0a95 --- /dev/null +++ b/test/functional/cases/110_statistics/sqlite-plain-siphash.robot @@ -0,0 +1,18 @@ +*** Settings *** +Suite Setup Statistics Setup +Suite Teardown Statistics Teardown +Resource lib.robot + +*** Variables *** +${STATS_BACKEND} sqlite3 +${STATS_HASH} hash = "siphash"; + +*** Test Cases *** +Learn + Learn Test + +Relearn + Relearn Test + +Empty Part + Empty Part Test diff --git a/test/functional/cases/110_statistics/sqlite-plain-xxhash.robot b/test/functional/cases/110_statistics/sqlite-plain-xxhash.robot new file mode 100644 index 000000000..dd8198222 --- /dev/null +++ b/test/functional/cases/110_statistics/sqlite-plain-xxhash.robot @@ -0,0 +1,18 @@ +*** Settings *** +Suite Setup Statistics Setup +Suite Teardown Statistics Teardown +Resource lib.robot + +*** Variables *** +${STATS_BACKEND} sqlite3 +${STATS_HASH} hash = "xxhash"; + +*** Test Cases *** +Learn + Learn Test + +Relearn + Relearn Test + +Empty Part + Empty Part Test diff --git a/test/functional/cases/120_fuzzy/encrypted.robot b/test/functional/cases/120_fuzzy/encrypted.robot new file mode 100644 index 000000000..45408d7f8 --- /dev/null +++ b/test/functional/cases/120_fuzzy/encrypted.robot @@ -0,0 +1,20 @@ +*** Settings *** +Suite Setup Encrypted Fuzzy Setup +Suite Teardown Generic Teardown +Resource lib.robot + +*** Test Cases *** +Fuzzy Add + Fuzzy Add Test + +Fuzzy Delete + Fuzzy Delete Test + +Fuzzy Overwrite + Fuzzy Overwrite Test + +*** Keywords *** +Encrypted Fuzzy Setup + Set Suite Variable ${SETTINGS_FUZZY_WORKER} "keypair": {"pubkey": "${KEY_PUB1}", "privkey": "${KEY_PVT1}"}; "encrypted_only": true; + Set Suite Variable ${SETTINGS_FUZZY_CHECK} encryption_key = "${KEY_PUB1}"; + Generic Setup diff --git a/test/functional/cases/120_fuzzy/lib.robot b/test/functional/cases/120_fuzzy/lib.robot new file mode 100644 index 000000000..e5e9cbcb7 --- /dev/null +++ b/test/functional/cases/120_fuzzy/lib.robot @@ -0,0 +1,48 @@ +*** Settings *** +Library ${TESTDIR}/lib/rspamd.py +Resource ${TESTDIR}/lib/rspamd.robot +Variables ${TESTDIR}/lib/vars.py + +*** Variables *** +${CONFIG} ${TESTDIR}/configs/fuzzy.conf +${FLAG1_NUMBER} 50 +${FLAG1_SYMBOL} R_TEST_FUZZY_DENIED +${FLAG2_NUMBER} 51 +${FLAG2_SYMBOL} R_TEST_FUZZY_WHITE +${MESSAGE} ${TESTDIR}/messages/bad_message.eml +${RSPAMD_SCOPE} Suite + +*** Keywords *** +Fuzzy Add Test + Set Suite Variable ${RSPAMD_FUZZY_ADD} 0 + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} -w 10 -f + ... ${FLAG1_NUMBER} fuzzy_add ${MESSAGE} + Check Rspamc ${result} + Sync Fuzzy Storage + ${result} = Scan Message With Rspamc ${MESSAGE} + Check Rspamc ${result} ${FLAG1_SYMBOL} + Set Suite Variable ${RSPAMD_FUZZY_ADD} 1 + +Fuzzy Delete Test + Run Keyword If ${RSPAMD_FUZZY_ADD} == 0 Fail "Fuzzy Add was not run" + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} -f ${FLAG1_NUMBER} fuzzy_del + ... ${MESSAGE} + Check Rspamc ${result} + Sync Fuzzy Storage + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + Should Not Contain ${result.stdout} ${FLAG1_SYMBOL} + Should Be Equal As Integers ${result.rc} 0 + +Fuzzy Overwrite Test + ${flag_numbers} = Create List ${FLAG1_NUMBER} ${FLAG2_NUMBER} + : FOR ${i} IN @{flag_numbers} + \ ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} -w 10 + \ ... -f ${i} fuzzy_add ${MESSAGE} + \ Check Rspamc ${result} + Sync Fuzzy Storage + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + Should Not Contain ${result.stdout} ${FLAG1_SYMBOL} + Should Contain ${result.stdout} ${FLAG2_SYMBOL} + Should Be Equal As Integers ${result.rc} 0 diff --git a/test/functional/cases/120_fuzzy/plain.robot b/test/functional/cases/120_fuzzy/plain.robot new file mode 100644 index 000000000..2fc2fd5ef --- /dev/null +++ b/test/functional/cases/120_fuzzy/plain.robot @@ -0,0 +1,18 @@ +*** Settings *** +Suite Setup Generic Setup +Suite Teardown Generic Teardown +Resource lib.robot + +*** Variables *** +${SETTINGS_FUZZY_WORKER} ${EMPTY} +${SETTINGS_FUZZY_CHECK} ${EMPTY} + +*** Test Cases *** +Fuzzy Add + Fuzzy Add Test + +Fuzzy Delete + Fuzzy Delete Test + +Fuzzy Overwrite + Fuzzy Overwrite Test diff --git a/test/functional/cases/archives.robot b/test/functional/cases/archives.robot deleted file mode 100644 index 16a14bfda..000000000 --- a/test/functional/cases/archives.robot +++ /dev/null @@ -1,23 +0,0 @@ -*** Settings *** -Suite Setup Generic Setup -Suite Teardown Generic Teardown -Library ${TESTDIR}/lib/rspamd.py -Resource ${TESTDIR}/lib/rspamd.robot -Variables ${TESTDIR}/lib/vars.py - -*** Variables *** -${CONFIG} ${TESTDIR}/configs/plugins.conf -${RSPAMD_SCOPE} Suite - -*** Test Cases *** -Zip - ${result} = Scan Message With Rspamc ${TESTDIR}/messages/zip.eml - Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[exe\\]\\n re=1 - -Zip Double Bad Extension - ${result} = Scan Message With Rspamc ${TESTDIR}/messages/zip-doublebad.eml - Check Rspamc ${result} MIME_DOUBLE_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[\\.pdf\\.exe\\]\\n re=1 - -Rar4 - ${result} = Scan Message With Rspamc ${TESTDIR}/messages/rar4.eml - Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[exe\\]\\n re=1 diff --git a/test/functional/cases/fuzzy/encrypted.robot b/test/functional/cases/fuzzy/encrypted.robot deleted file mode 100644 index 45408d7f8..000000000 --- a/test/functional/cases/fuzzy/encrypted.robot +++ /dev/null @@ -1,20 +0,0 @@ -*** Settings *** -Suite Setup Encrypted Fuzzy Setup -Suite Teardown Generic Teardown -Resource lib.robot - -*** Test Cases *** -Fuzzy Add - Fuzzy Add Test - -Fuzzy Delete - Fuzzy Delete Test - -Fuzzy Overwrite - Fuzzy Overwrite Test - -*** Keywords *** -Encrypted Fuzzy Setup - Set Suite Variable ${SETTINGS_FUZZY_WORKER} "keypair": {"pubkey": "${KEY_PUB1}", "privkey": "${KEY_PVT1}"}; "encrypted_only": true; - Set Suite Variable ${SETTINGS_FUZZY_CHECK} encryption_key = "${KEY_PUB1}"; - Generic Setup diff --git a/test/functional/cases/fuzzy/lib.robot b/test/functional/cases/fuzzy/lib.robot deleted file mode 100644 index e5e9cbcb7..000000000 --- a/test/functional/cases/fuzzy/lib.robot +++ /dev/null @@ -1,48 +0,0 @@ -*** Settings *** -Library ${TESTDIR}/lib/rspamd.py -Resource ${TESTDIR}/lib/rspamd.robot -Variables ${TESTDIR}/lib/vars.py - -*** Variables *** -${CONFIG} ${TESTDIR}/configs/fuzzy.conf -${FLAG1_NUMBER} 50 -${FLAG1_SYMBOL} R_TEST_FUZZY_DENIED -${FLAG2_NUMBER} 51 -${FLAG2_SYMBOL} R_TEST_FUZZY_WHITE -${MESSAGE} ${TESTDIR}/messages/bad_message.eml -${RSPAMD_SCOPE} Suite - -*** Keywords *** -Fuzzy Add Test - Set Suite Variable ${RSPAMD_FUZZY_ADD} 0 - ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} -w 10 -f - ... ${FLAG1_NUMBER} fuzzy_add ${MESSAGE} - Check Rspamc ${result} - Sync Fuzzy Storage - ${result} = Scan Message With Rspamc ${MESSAGE} - Check Rspamc ${result} ${FLAG1_SYMBOL} - Set Suite Variable ${RSPAMD_FUZZY_ADD} 1 - -Fuzzy Delete Test - Run Keyword If ${RSPAMD_FUZZY_ADD} == 0 Fail "Fuzzy Add was not run" - ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} -f ${FLAG1_NUMBER} fuzzy_del - ... ${MESSAGE} - Check Rspamc ${result} - Sync Fuzzy Storage - ${result} = Scan Message With Rspamc ${MESSAGE} - Follow Rspamd Log - Should Not Contain ${result.stdout} ${FLAG1_SYMBOL} - Should Be Equal As Integers ${result.rc} 0 - -Fuzzy Overwrite Test - ${flag_numbers} = Create List ${FLAG1_NUMBER} ${FLAG2_NUMBER} - : FOR ${i} IN @{flag_numbers} - \ ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} -w 10 - \ ... -f ${i} fuzzy_add ${MESSAGE} - \ Check Rspamc ${result} - Sync Fuzzy Storage - ${result} = Scan Message With Rspamc ${MESSAGE} - Follow Rspamd Log - Should Not Contain ${result.stdout} ${FLAG1_SYMBOL} - Should Contain ${result.stdout} ${FLAG2_SYMBOL} - Should Be Equal As Integers ${result.rc} 0 diff --git a/test/functional/cases/fuzzy/plain.robot b/test/functional/cases/fuzzy/plain.robot deleted file mode 100644 index 2fc2fd5ef..000000000 --- a/test/functional/cases/fuzzy/plain.robot +++ /dev/null @@ -1,18 +0,0 @@ -*** Settings *** -Suite Setup Generic Setup -Suite Teardown Generic Teardown -Resource lib.robot - -*** Variables *** -${SETTINGS_FUZZY_WORKER} ${EMPTY} -${SETTINGS_FUZZY_CHECK} ${EMPTY} - -*** Test Cases *** -Fuzzy Add - Fuzzy Add Test - -Fuzzy Delete - Fuzzy Delete Test - -Fuzzy Overwrite - Fuzzy Overwrite Test diff --git a/test/functional/cases/general.robot b/test/functional/cases/general.robot deleted file mode 100644 index 8876ef980..000000000 --- a/test/functional/cases/general.robot +++ /dev/null @@ -1,42 +0,0 @@ -*** Settings *** -Suite Setup Generic Setup -Suite Teardown Generic Teardown -Library ${TESTDIR}/lib/rspamd.py -Resource ${TESTDIR}/lib/rspamd.robot -Variables ${TESTDIR}/lib/vars.py - -*** Variables *** -${CONFIG} ${TESTDIR}/configs/trivial.conf -${GTUBE} ${TESTDIR}/messages/gtube.eml -${RSPAMD_SCOPE} Suite - -*** Test Cases *** -GTUBE - ${result} = Scan Message With Rspamc ${GTUBE} - Check Rspamc ${result} GTUBE ( - -GTUBE - Encrypted - ${result} = Run Rspamc -p -h ${LOCAL_ADDR}:${PORT_NORMAL} --key ${KEY_PUB1} - ... ${GTUBE} - Check Rspamc ${result} GTUBE ( - -GTUBE - Scan File feature - ${result} = Scan File ${LOCAL_ADDR} ${PORT_NORMAL} ${GTUBE} - Follow Rspamd Log - Should Contain ${result} GTUBE - -GTUBE - Scan File feature (encoded) - ${encoded} = Encode Filename ${GTUBE} - ${result} = Scan File ${LOCAL_ADDR} ${PORT_NORMAL} ${encoded} - Follow Rspamd Log - Should Contain ${result} GTUBE - -GTUBE - SPAMC - ${result} = Spamc ${LOCAL_ADDR} ${PORT_NORMAL} ${GTUBE} - Follow Rspamd Log - Should Contain ${result} GTUBE - -GTUBE - RSPAMC - ${result} = Rspamc ${LOCAL_ADDR} ${PORT_NORMAL} ${GTUBE} - Follow Rspamd Log - Should Contain ${result} GTUBE diff --git a/test/functional/cases/lua.robot b/test/functional/cases/lua.robot deleted file mode 100644 index 5e5dff6c8..000000000 --- a/test/functional/cases/lua.robot +++ /dev/null @@ -1,35 +0,0 @@ -*** Settings *** -Test Teardown Generic Teardown -Library ${TESTDIR}/lib/rspamd.py -Resource ${TESTDIR}/lib/rspamd.robot -Variables ${TESTDIR}/lib/vars.py - -*** Variables *** -${CONFIG} ${TESTDIR}/configs/lua_test.conf -${MESSAGE} ${TESTDIR}/messages/spam_message.eml -${RSPAMD_SCOPE} Test - -*** Test Cases *** -Flags - [Setup] Lua Setup ${TESTDIR}/lua/flags.lua - ${result} = Scan Message With Rspamc ${MESSAGE} - Follow Rspamd Log - ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} stat - Should Contain ${result.stdout} Messages scanned: 0 - -Dependencies - [Setup] Lua Setup ${TESTDIR}/lua/deps.lua - ${result} = Scan Message With Rspamc ${MESSAGE} - Check Rspamc ${result} DEP10 - -Pre and Post Filters - [Setup] Lua Setup ${TESTDIR}/lua/prepostfilters.lua - ${result} = Scan Message With Rspamc ${MESSAGE} - Check Rspamc ${result} TEST_PRE - Check Rspamc ${result} TEST_POST rc_nocheck=1 - -*** Keywords *** -Lua Setup - [Arguments] ${LUA_SCRIPT} - Set Test Variable ${LUA_SCRIPT} - Generic Setup diff --git a/test/functional/cases/statistics/compat-keyed.robot b/test/functional/cases/statistics/compat-keyed.robot deleted file mode 100644 index 1242df12c..000000000 --- a/test/functional/cases/statistics/compat-keyed.robot +++ /dev/null @@ -1,20 +0,0 @@ -*** Settings *** -Suite Setup Statistics Setup -Suite Teardown Statistics Teardown -Resource lib.robot - -*** Variables *** -${STATS_BACKEND} mmap -${STATS_HASH} hash = "compat"; -${STATS_KEY} key = "${KEY_PVT1}"; -${STATS_PATH_CACHE} name = "sqlite3"; path = "\${TMPDIR}/learn_cache.db"; - -*** Test Cases *** -Learn - Learn Test - -Relearn - Relearn Test - -Empty Part - Empty Part Test diff --git a/test/functional/cases/statistics/compat-plain.robot b/test/functional/cases/statistics/compat-plain.robot deleted file mode 100644 index 12bbaedcd..000000000 --- a/test/functional/cases/statistics/compat-plain.robot +++ /dev/null @@ -1,19 +0,0 @@ -*** Settings *** -Suite Setup Statistics Setup -Suite Teardown Statistics Teardown -Resource lib.robot - -*** Variables *** -${STATS_BACKEND} mmap -${STATS_HASH} hash = "compat"; -${STATS_PATH_CACHE} name = "sqlite3"; path = "\${TMPDIR}/learn_cache.db"; - -*** Test Cases *** -Learn - Learn Test - -Relearn - Relearn Test - -Empty Part - Empty Part Test diff --git a/test/functional/cases/statistics/lib.robot b/test/functional/cases/statistics/lib.robot deleted file mode 100644 index 5f9e96038..000000000 --- a/test/functional/cases/statistics/lib.robot +++ /dev/null @@ -1,57 +0,0 @@ -*** Settings *** -Library ${TESTDIR}/lib/rspamd.py -Resource ${TESTDIR}/lib/rspamd.robot -Variables ${TESTDIR}/lib/vars.py - -*** Variables *** -${CONFIG} ${TESTDIR}/configs/stats.conf -${MESSAGE} ${TESTDIR}/messages/spam_message.eml -${REDIS_SCOPE} Suite -${REDIS_SERVER} ${EMPTY} -${RSPAMD_SCOPE} Suite -${STATS_HASH} ${EMPTY} -${STATS_KEY} ${EMPTY} -${STATS_PATH_CACHE} path = "\${TMPDIR}/bayes-cache.sqlite"; -${STATS_PATH_HAM} path = "\${TMPDIR}/bayes-ham.sqlite"; -${STATS_PATH_SPAM} path = "\${TMPDIR}/bayes-spam.sqlite"; - -*** Keywords *** -Broken Learn Test - ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} - Check Rspamc ${result} cannot find statfile backend - -Empty Part Test - Set Test Variable ${MESSAGE} ${TESTDIR}/messages/empty_part.eml - ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} - Check Rspamc ${result} - ${result} = Scan Message With Rspamc ${MESSAGE} - Check Rspamc ${result} BAYES_SPAM - -Learn Test - Set Suite Variable ${RSPAMD_STATS_LEARNTEST} 0 - ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} - Check Rspamc ${result} - ${result} = Scan Message With Rspamc ${MESSAGE} - Check Rspamc ${result} BAYES_SPAM - Set Suite Variable ${RSPAMD_STATS_LEARNTEST} 1 - -Relearn Test - Run Keyword If ${RSPAMD_STATS_LEARNTEST} == 0 Fail "Learn test was not run" - ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_ham ${MESSAGE} - Check Rspamc ${result} - ${result} = Scan Message With Rspamc ${MESSAGE} - Check Rspamc ${result} BAYES_HAM - -Redis Statistics Setup - Generic Setup - Run Redis - -Redis Statistics Teardown - Generic Teardown - Shutdown Process With Children ${REDIS_PID} - -Statistics Setup - Generic Setup STATS_PATH_CACHE STATS_PATH_HAM STATS_PATH_SPAM - -Statistics Teardown - Generic Teardown diff --git a/test/functional/cases/statistics/redis-keyed-siphash.robot b/test/functional/cases/statistics/redis-keyed-siphash.robot deleted file mode 100644 index ec95efcd1..000000000 --- a/test/functional/cases/statistics/redis-keyed-siphash.robot +++ /dev/null @@ -1,20 +0,0 @@ -*** Settings *** -Suite Setup Redis Statistics Setup -Suite Teardown Redis Statistics Teardown -Resource lib.robot - -*** Variables *** -${REDIS_SERVER} servers = "${REDIS_ADDR}:${REDIS_PORT}" -${STATS_BACKEND} redis -${STATS_HASH} hash = "siphash"; -${STATS_KEY} key = "${KEY_PVT1}"; - -*** Test Cases *** -Learn - Learn Test - -Relearn - Relearn Test - -Empty Part - Empty Part Test diff --git a/test/functional/cases/statistics/redis-keyed-xxhash.robot b/test/functional/cases/statistics/redis-keyed-xxhash.robot deleted file mode 100644 index 5a7b2daf3..000000000 --- a/test/functional/cases/statistics/redis-keyed-xxhash.robot +++ /dev/null @@ -1,20 +0,0 @@ -*** Settings *** -Suite Setup Redis Statistics Setup -Suite Teardown Redis Statistics Teardown -Resource lib.robot - -*** Variables *** -${REDIS_SERVER} servers = "${REDIS_ADDR}:${REDIS_PORT}" -${STATS_BACKEND} redis -${STATS_HASH} hash = "xxhash"; -${STATS_KEY} key = "${KEY_PVT1}"; - -*** Test Cases *** -Learn - Learn Test - -Relearn - Relearn Test - -Empty Part - Empty Part Test diff --git a/test/functional/cases/statistics/redis-plain-siphash.robot b/test/functional/cases/statistics/redis-plain-siphash.robot deleted file mode 100644 index d436b1a68..000000000 --- a/test/functional/cases/statistics/redis-plain-siphash.robot +++ /dev/null @@ -1,19 +0,0 @@ -*** Settings *** -Suite Setup Redis Statistics Setup -Suite Teardown Redis Statistics Teardown -Resource lib.robot - -*** Variables *** -${REDIS_SERVER} servers = "${REDIS_ADDR}:${REDIS_PORT}" -${STATS_BACKEND} redis -${STATS_HASH} hash = "siphash"; - -*** Test Cases *** -Learn - Learn Test - -Relearn - Relearn Test - -Empty Part - Empty Part Test diff --git a/test/functional/cases/statistics/redis-plain-xxhash.robot b/test/functional/cases/statistics/redis-plain-xxhash.robot deleted file mode 100644 index 0c45ac16b..000000000 --- a/test/functional/cases/statistics/redis-plain-xxhash.robot +++ /dev/null @@ -1,19 +0,0 @@ -*** Settings *** -Suite Setup Redis Statistics Setup -Suite Teardown Redis Statistics Teardown -Resource lib.robot - -*** Variables *** -${REDIS_SERVER} servers = "${REDIS_ADDR}:${REDIS_PORT}" -${STATS_BACKEND} redis -${STATS_HASH} hash = "xxhash"; - -*** Test Cases *** -Learn - Learn Test - -Relearn - Relearn Test - -Empty Part - Empty Part Test diff --git a/test/functional/cases/statistics/sqlite-broken-stats-dir.robot b/test/functional/cases/statistics/sqlite-broken-stats-dir.robot deleted file mode 100644 index 57d75c294..000000000 --- a/test/functional/cases/statistics/sqlite-broken-stats-dir.robot +++ /dev/null @@ -1,15 +0,0 @@ -*** Settings *** -Suite Setup Generic Setup -Suite Teardown Generic Teardown -Resource ${TESTDIR}/lib/rspamd.robot -Resource lib.robot - -*** Variables *** -${STATS_BACKEND} sqlite3 -${STATS_PATH_CACHE} path = "/does/not/exist/bayes-cache.sqlite"; -${STATS_PATH_HAM} path = "/does/not/exist/bayes-ham.sqlite"; -${STATS_PATH_SPAM} path = "/does/not/exist/bayes-spam.sqlite"; - -*** Test Cases *** -Broken Stats Directory - Broken Learn Test diff --git a/test/functional/cases/statistics/sqlite-keyed-siphash.robot b/test/functional/cases/statistics/sqlite-keyed-siphash.robot deleted file mode 100644 index 8b9661a9a..000000000 --- a/test/functional/cases/statistics/sqlite-keyed-siphash.robot +++ /dev/null @@ -1,19 +0,0 @@ -*** Settings *** -Suite Setup Statistics Setup -Suite Teardown Statistics Teardown -Resource lib.robot - -*** Variables *** -${STATS_BACKEND} sqlite3 -${STATS_HASH} hash = "siphash"; -${STATS_KEY} key = "${KEY_PVT1}"; - -*** Test Cases *** -Learn - Learn Test - -Relearn - Relearn Test - -Empty Part - Empty Part Test diff --git a/test/functional/cases/statistics/sqlite-keyed-xxhash.robot b/test/functional/cases/statistics/sqlite-keyed-xxhash.robot deleted file mode 100644 index 7a51e93ae..000000000 --- a/test/functional/cases/statistics/sqlite-keyed-xxhash.robot +++ /dev/null @@ -1,19 +0,0 @@ -*** Settings *** -Suite Setup Statistics Setup -Suite Teardown Statistics Teardown -Resource lib.robot - -*** Variables *** -${STATS_BACKEND} sqlite3 -${STATS_HASH} hash = "xxhash"; -${STATS_KEY} key = "${KEY_PVT1}"; - -*** Test Cases *** -Learn - Learn Test - -Relearn - Relearn Test - -Empty Part - Empty Part Test diff --git a/test/functional/cases/statistics/sqlite-plain-siphash.robot b/test/functional/cases/statistics/sqlite-plain-siphash.robot deleted file mode 100644 index 2f88e0a95..000000000 --- a/test/functional/cases/statistics/sqlite-plain-siphash.robot +++ /dev/null @@ -1,18 +0,0 @@ -*** Settings *** -Suite Setup Statistics Setup -Suite Teardown Statistics Teardown -Resource lib.robot - -*** Variables *** -${STATS_BACKEND} sqlite3 -${STATS_HASH} hash = "siphash"; - -*** Test Cases *** -Learn - Learn Test - -Relearn - Relearn Test - -Empty Part - Empty Part Test diff --git a/test/functional/cases/statistics/sqlite-plain-xxhash.robot b/test/functional/cases/statistics/sqlite-plain-xxhash.robot deleted file mode 100644 index dd8198222..000000000 --- a/test/functional/cases/statistics/sqlite-plain-xxhash.robot +++ /dev/null @@ -1,18 +0,0 @@ -*** Settings *** -Suite Setup Statistics Setup -Suite Teardown Statistics Teardown -Resource lib.robot - -*** Variables *** -${STATS_BACKEND} sqlite3 -${STATS_HASH} hash = "xxhash"; - -*** Test Cases *** -Learn - Learn Test - -Relearn - Relearn Test - -Empty Part - Empty Part Test