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
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'])
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)
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
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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
--- /dev/null
+*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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
+++ /dev/null
-*** 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