*** Settings ***
-Suite Setup Export Global Variables
-Library ../lib/rspamd.py
-Variables ../lib/vars.py
+Suite Setup Export Global Variables
+Library ../lib/rspamd.py
+Variables ../lib/vars.py
*** Keywords ***
Export Global Variables
- ${TESTDIR} = Get Test Directory
- Set Global Variable ${KEY_PUB1}
- Set Global Variable ${KEY_PVT1}
- Set Global Variable ${LOCAL_ADDR}
- Set Global Variable ${PORT_CONTROLLER}
- Set Global Variable ${PORT_NORMAL}
- Set Global Variable ${RSPAMC} ${TESTDIR}/../../src/client/rspamc
- Set Global Variable ${RSPAMD} ${TESTDIR}/../../src/rspamd
- Set Global Variable ${RSPAMD_GROUP}
- Set Global Variable ${RSPAMD_USER}
- Set Global Variable ${TESTDIR}
+ ${TESTDIR} = Get Test Directory
+ Set Global Variable ${RSPAMADM} ${TESTDIR}/../../src/rspamadm/rspamadm
+ Set Global Variable ${RSPAMC} ${TESTDIR}/../../src/client/rspamc
+ Set Global Variable ${RSPAMD} ${TESTDIR}/../../src/rspamd
+ Set Global Variable ${TESTDIR}
--- /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
*** Settings ***
-Library ${TESTDIR}/lib/rspamd.py
-Resource ${TESTDIR}/lib/rspamd.robot
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_KEYWORDS} KEY_PUBLIC=${KEY_PUB1} KEY_PRIVATE=${KEY_PVT1} LOCAL_ADDR=${LOCAL_ADDR} PORT_NORMAL=${PORT_NORMAL} TESTDIR=${TESTDIR}
-${RSPAMD_SCOPE} Suite
+${CONFIG} ${TESTDIR}/configs/trivial.conf
+${GTUBE} ${TESTDIR}/messages/gtube.eml
+${RSPAMD_SCOPE} Suite
*** Test Cases ***
GTUBE
Check Rspamc ${result} GTUBE (
GTUBE - Encrypted
- ${result} = Run Rspamc -p -h ${LOCAL_ADDR}:${PORT_NORMAL} --key ${KEY_PUB1} ${GTUBE}
+ ${result} = Run Rspamc -p -h ${LOCAL_ADDR}:${PORT_NORMAL} --key ${KEY_PUB1}
+ ... ${GTUBE}
Check Rspamc ${result} GTUBE (
GTUBE - Scan File feature
*** 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
+${CONFIG} ${TESTDIR}/configs/lua_test.conf
+${MESSAGE} ${TESTDIR}/messages/spam_message.eml
${RSPAMD_SCOPE} Test
-*** Keywords ***
-Lua Setup
- [Arguments] ${lua_script}
- &{RSPAMD_KEYWORDS} = Create Dictionary LOCAL_ADDR=${LOCAL_ADDR} LUA_SCRIPT=${lua_script} PORT_CONTROLLER=${PORT_CONTROLLER} PORT_NORMAL=${PORT_NORMAL} TESTDIR=${TESTDIR}
- Set Test Variable &{RSPAMD_KEYWORDS}
- Generic Setup
-
*** Test Cases ***
Flags
[Setup] Lua Setup ${TESTDIR}/lua/flags.lua
Follow Rspamd Log
${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} stat
Should Contain ${result.stdout} Messages scanned: 0
- [Teardown] Generic Teardown
Dependencies
[Setup] Lua Setup ${TESTDIR}/lua/deps.lua
${result} = Scan Message With Rspamc ${MESSAGE}
Check Rspamc ${result} DEP10
- [Teardown] Generic Teardown
+
+*** Keywords ***
+Lua Setup
+ [Arguments] ${LUA_SCRIPT}
+ Set Test Variable ${LUA_SCRIPT}
+ Generic Setup
+++ /dev/null
-*** Settings ***
-Library ${TESTDIR}/lib/rspamd.py
-Resource ${TESTDIR}/lib/rspamd.robot
-
-*** Variables ***
-@{ALIASES} STATSDIR
-${CONFIG} ${TESTDIR}/configs/stats.conf
-${MESSAGE} ${TESTDIR}/messages/spam_message.eml
-${RSPAMD_SCOPE} Test
-
-*** Keywords ***
-Statistics Setup
- [Arguments] @{aliases} &{kw}
- &{RSPAMD_KEYWORDS} = Create Dictionary KEY_PRIVATE=${KEY_PVT1} KEY_PUBLIC=${KEY_PUB1} LOCAL_ADDR=${LOCAL_ADDR} PORT_CONTROLLER=${PORT_CONTROLLER} PORT_NORMAL=${PORT_NORMAL} TESTDIR=${TESTDIR}
- Update Dictionary ${RSPAMD_KEYWORDS} ${kw}
- Set Test Variable &{RSPAMD_KEYWORDS}
- ${TMPDIR} ${RSPAMD_PID} ${RSPAMD_LOGPOS} = Run Rspamd @{aliases} &{RSPAMD_KEYWORDS}
- Export Rspamd Vars To Test ${TMPDIR} ${RSPAMD_LOGPOS} ${RSPAMD_PID}
-
-*** Test Cases ***
-Sqlite Learn - Keyed, siphash
- [Setup] Statistics Setup @{ALIASES} STATS_BACKEND=sqlite3 STATS_HASH=siphash STATS_KEY=${KEY_PVT1}
- ${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
- [Teardown] Generic Teardown
-
-Sqlite Learn - Keyed, xxhash
- [Setup] Statistics Setup @{ALIASES} STATS_BACKEND=sqlite3 STATS_HASH=xxh STATS_KEY=${KEY_PVT1}
- ${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
- [Teardown] Generic Teardown
-
-Sqlite Learn - Broken Stats Directory
- [Setup] Statistics Setup @{EMPTY} STATS_BACKEND=sqlite3 STATS_HASH=xxh STATS_KEY=${KEY_PVT1} STATSDIR=/does/not/exist
- ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE}
- Follow Rspamd Log
- Should Not Contain ${result.stdout} success = true
- [Teardown] Generic Teardown
-
-Sqlite Learn - Empty part
- [Setup] Statistics Setup @{ALIASES} STATS_BACKEND=sqlite3 STATS_HASH=xxh STATS_KEY=${KEY_PVT1}
- 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
- [Teardown] Generic Teardown
-
-Sqlite Relearn
- [Setup] Statistics Setup @{ALIASES} STATS_BACKEND=sqlite3 STATS_HASH=xxh STATS_KEY=${KEY_PVT1}
- ${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
- ${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
- [Teardown] Generic Teardown
-
-Mmap Learn
- [Setup] Statistics Setup @{ALIASES} STATS_BACKEND=mmap STATS_HASH=compat STATS_KEY=${KEY_PVT1}
- ${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
- [Teardown] Generic Teardown
-
-Mmap Relearn
- [Setup] Statistics Setup @{ALIASES} STATS_BACKEND=mmap STATS_HASH=compat STATS_KEY=${KEY_PVT1}
- ${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
- ${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
- [Teardown] Generic Teardown
--- /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}";
+
+*** 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";
+
+*** 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}
+ Follow Rspamd Log
+ Should Not Contain ${result.stdout} success = true
+ Should Not Equal As Integers ${result.rc} 0
+
+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 ${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 = "${LOCAL_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 = "${LOCAL_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 = "${LOCAL_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 = "${LOCAL_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
+options = {
+ filters = "fuzzy_check";
+ pidfile = "${TMPDIR}/rspamd.pid"
+ control_socket = "${TMPDIR}/rspamd.sock mode=0600";
+}
+logging = {
+ type = "file",
+ level = "debug"
+ filename = "${TMPDIR}/rspamd.log"
+}
+metric = {
+ name = "default",
+ actions = {
+ reject = 100500,
+ }
+ unknown_weight = 1
+ symbol {
+ weight = 0.0;
+ name = "R_TEST_FUZZY_UNKNOWN";
+ }
+ symbol {
+ weight = 10.0;
+ name = "${FLAG1_SYMBOL}";
+ }
+ symbol {
+ weight = -1.0;
+ name = "${FLAG2_SYMBOL}";
+ }
+}
+
+worker {
+ type = normal
+ bind_socket = "${LOCAL_ADDR}:${PORT_NORMAL}";
+ count = 1
+}
+
+worker {
+ type = controller
+ bind_socket = "${LOCAL_ADDR}:${PORT_CONTROLLER}";
+ count = 1
+ secure_ip = ["${LOCAL_ADDR}"];
+}
+
+worker {
+ bind_socket = "${LOCAL_ADDR}:${PORT_FUZZY}";
+ type = "fuzzy";
+ hashfile = "${TMPDIR}/fuzzy.db";
+ allow_update = ["${LOCAL_ADDR}"];
+ ${SETTINGS_FUZZY_WORKER}
+}
+
+fuzzy_check {
+ min_bytes = 100;
+
+ rule {
+ servers = "${LOCAL_ADDR}:${PORT_FUZZY}";
+ symbol = "R_TEST_FUZZY";
+ max_score = 10.0;
+ mime_types = ["application/*"];
+ read_only = false;
+ skip_unknown = true;
+ ${SETTINGS_FUZZY_CHECK}
+ fuzzy_map = {
+ ${FLAG1_SYMBOL} {
+ max_score = 10.0;
+ flag = ${FLAG1_NUMBER};
+ }
+ ${FLAG2_SYMBOL} {
+ max_score = 1.0;
+ flag = ${FLAG2_NUMBER};
+ }
+ }
+ }
+}
--- /dev/null
+bind ${LOCAL_ADDR}
+daemonize yes
+pidfile ${TMPDIR}/redis.pid
+port ${REDIS_PORT}
bind_socket = ${LOCAL_ADDR}:${PORT_NORMAL}
count = 1
keypair {
- pubkey = "${KEY_PUBLIC}";
- privkey = "${KEY_PRIVATE}";
+ pubkey = "${KEY_PUB1}";
+ privkey = "${KEY_PVT1}";
}
}
worker {
bind_socket = ${LOCAL_ADDR}:${PORT_CONTROLLER}
count = 1
keypair {
- pubkey = "${KEY_PUBLIC}";
- privkey = "${KEY_PRIVATE}";
+ pubkey = "${KEY_PUB1}";
+ privkey = "${KEY_PVT1}";
}
secure_ip = ["127.0.0.1", "::1"];
}
languages_enabled = true;
tokenizer {
name = "osb";
- hash = ${STATS_HASH}
- key = ${STATS_KEY}
+ ${STATS_HASH}
+ ${STATS_KEY}
}
backend = ${STATS_BACKEND}
statfile {
symbol = BAYES_SPAM;
- path = ${STATSDIR}/rspamd-bats-bayes.spam;
+ ${STATS_PATH_SPAM}
size = 1M;
- write_servers = ${REDIS_SERVER}
+ ${REDIS_SERVER}
}
statfile {
symbol = BAYES_HAM;
- path = ${STATSDIR}/rspamd-bats-bayes.ham;
+ ${STATS_PATH_HAM}
size = 1M;
- write_servers = ${REDIS_SERVER}
+ ${REDIS_SERVER}
}
cache {
- path = ${STATSDIR}/rspamd-bats-cache.sqlite;
- write_servers = ${REDIS_SERVER}
+ ${STATS_PATH_CACHE}
+ ${REDIS_SERVER}
}
}
bind_socket = ${LOCAL_ADDR}:${PORT_NORMAL}
count = 1
keypair {
- pubkey = "${KEY_PUBLIC}";
- privkey = "${KEY_PRIVATE}";
+ pubkey = "${KEY_PUB1}";
+ privkey = "${KEY_PVT1}";
}
}
def make_temporary_directory():
return tempfile.mkdtemp()
-def populate_rspamd_config(template_file, temporary_dir, **config):
- t = string.Template(open(template_file).read())
- f = open("%s/rspamd.conf" % temporary_dir, "w")
- f.write(t.safe_substitute(config))
- f.close()
-
def process_should_exist(pid):
pid = int(pid)
os.kill(pid, 0)
a.update(b)
return a
-def shutdown_rspamd(pid):
+def shutdown_process(pid):
pid = int(pid)
process_should_exist(pid)
i = 0
*** Settings ***
-Library Collections
-Library OperatingSystem
-Library Process
+Library Collections
+Library OperatingSystem
+Library Process
*** Keywords ***
Check Rspamc
... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite'
Generic Setup
- ${TMPDIR} ${RSPAMD_PID} ${RSPAMD_LOGPOS} = Run Rspamd
+ [Arguments] @{vargs}
+ ${TMPDIR} ${RSPAMD_PID} ${RSPAMD_LOGPOS} = Run Rspamd @{vargs}
Run Keyword If '${RSPAMD_SCOPE}' == 'Test' Export Rspamd Vars To Test ${TMPDIR} ${RSPAMD_LOGPOS} ${RSPAMD_PID}
... ELSE IF '${RSPAMD_SCOPE}' == 'Suite' Export Rspamd Vars To Suite ${TMPDIR} ${RSPAMD_LOGPOS} ${RSPAMD_PID}
... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite'
Generic Teardown
- Shutdown Rspamd ${RSPAMD_PID}
- Cleanup Temporary Directory ${TMPDIR}
+ Shutdown Process ${RSPAMD_PID}
+ Cleanup Temporary Directory ${TMPDIR}
Log Logs
- [Arguments] ${logfile} ${position}
- ${the_log} ${position} = Read Log From Position ${logfile} ${position}
- Log ${the_log}
- [Return] ${position}
+ [Arguments] ${logfile} ${position}
+ ${the_log} ${position} = Read Log From Position ${logfile} ${position}
+ Log ${the_log}
+ [Return] ${position}
+
+Run Redis
+ ${template} = Get File ${TESTDIR}/configs/redis-server.conf
+ ${config} = Replace Variables ${template}
+ Create File ${TMPDIR}/redis-server.conf ${config}
+ ${result} = Run Process redis-server ${TMPDIR}/redis-server.conf
+ Should Be Equal As Integers ${result.rc} 0
+ ${REDIS_PID} = Get File ${TMPDIR}/redis.pid
+ Run Keyword If '${REDIS_SCOPE}' == 'Test' Set Test Variable ${REDIS_PID}
+ ... ELSE IF '${REDIS_SCOPE}' == 'Suite' Set Suite Variable ${REDIS_PID}
Run Rspamc
- [Arguments] @{args}
- ${result} = Run Process ${RSPAMC} @{args}
- [Return] ${result}
+ [Arguments] @{args}
+ ${result} = Run Process ${RSPAMC} @{args}
+ [Return] ${result}
Run Rspamd
- [Arguments] @{args} &{kw}
- ${tmpdir} = Make Temporary Directory
- Set Directory Ownership ${tmpdir} ${RSPAMD_USER} ${RSPAMD_GROUP}
- Set To Dictionary ${RSPAMD_KEYWORDS} TMPDIR=${tmpdir}
- Update Dictionary ${RSPAMD_KEYWORDS} ${kw}
- :FOR ${i} IN @{args}
- \ Set To Dictionary ${RSPAMD_KEYWORDS} ${i} ${tmpdir}
- Populate Rspamd Config ${CONFIG} ${tmpdir} &{RSPAMD_KEYWORDS}
- ${result} = Run Process ${RSPAMD} -u ${RSPAMD_USER} -g ${RSPAMD_GROUP} -c ${tmpdir}/rspamd.conf
- ${rspamd_logpos} = Log Logs ${tmpdir}/rspamd.log 0
- Should Be Equal As Integers ${result.rc} 0
- ${rspamd_pid} = Get File ${tmpdir}/rspamd.pid
- [Return] ${tmpdir} ${rspamd_pid} ${rspamd_logpos}
+ [Arguments] @{vargs}
+ ${TMPDIR} = Make Temporary Directory
+ Set Directory Ownership ${TMPDIR} ${RSPAMD_USER} ${RSPAMD_GROUP}
+ ${template} = Get File ${CONFIG}
+ : FOR ${i} IN @{vargs}
+ \ ${newvalue} = Replace Variables ${${i}}
+ \ Set Suite Variable ${${i}} ${newvalue}
+ \ Run Keyword If '${RSPAMD_SCOPE}' == 'Test' Set Test Variable ${${i}} ${newvalue}
+ \ ... ELSE IF '${RSPAMD_SCOPE}' == 'Suite' Set Suite Variable ${${i}} ${newvalue}
+ \ ... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite'
+ ${config} = Replace Variables ${template}
+ Log ${config}
+ Create File ${TMPDIR}/rspamd.conf ${config}
+ ${result} = Run Process ${RSPAMD} -u ${RSPAMD_USER} -g ${RSPAMD_GROUP}
+ ... -c ${TMPDIR}/rspamd.conf
+ ${rspamd_logpos} = Log Logs ${TMPDIR}/rspamd.log 0
+ Should Be Equal As Integers ${result.rc} 0
+ ${rspamd_pid} = Get File ${TMPDIR}/rspamd.pid
+ [Return] ${TMPDIR} ${rspamd_pid} ${rspamd_logpos}
Scan Message With Rspamc
- [Arguments] ${msg_file}
- ${result} = Run Rspamc -p -h ${LOCAL_ADDR}:${PORT_NORMAL} ${msg_file}
- [Return] ${result}
+ [Arguments] ${msg_file}
+ ${result} = Run Rspamc -p -h ${LOCAL_ADDR}:${PORT_NORMAL} ${msg_file}
+ [Return] ${result}
+
+Sync Fuzzy Storage
+ ${result} = Run Process ${RSPAMADM} control -s ${TMPDIR}/rspamd.sock fuzzy_sync
+ Log ${result.stdout}
+ Follow Rspamd Log
KEY_PUB1 = 'm8kneubpcjsb8sbsoj7jy7azj9fdd3xmj63txni86a8ye9ncomny'
LOCAL_ADDR = 'localhost'
PORT_CONTROLLER = 56790
+PORT_FUZZY = 56791
PORT_NORMAL = 56789
+REDIS_PORT = 56379
RSPAMD_GROUP = 'nogroup'
RSPAMD_USER = 'nobody'