| 1 |
*** Settings *** |
| 2 |
Library ${RSPAMD_TESTDIR}/lib/rspamd.py |
| 3 |
Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot |
| 4 |
Variables ${RSPAMD_TESTDIR}/lib/vars.py |
| 5 |
|
| 6 |
*** Variables *** |
| 7 |
${CONFIG} ${RSPAMD_TESTDIR}/configs/stats.conf |
| 8 |
${MESSAGE_HAM} ${RSPAMD_TESTDIR}/messages/ham.eml |
| 9 |
${MESSAGE_SPAM} ${RSPAMD_TESTDIR}/messages/spam_message.eml |
| 10 |
${REDIS_SCOPE} Suite |
| 11 |
${RSPAMD_REDIS_SERVER} null |
| 12 |
${RSPAMD_SCOPE} Suite |
| 13 |
${RSPAMD_STATS_BACKEND} redis |
| 14 |
${RSPAMD_STATS_HASH} null |
| 15 |
${RSPAMD_STATS_KEY} null |
| 16 |
${RSPAMD_STATS_PER_USER} ${EMPTY} |
| 17 |
|
| 18 |
*** Keywords *** |
| 19 |
Broken Learn Test |
| 20 |
${result} = Run Rspamc -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} learn_spam ${MESSAGE_SPAM} |
| 21 |
Check Rspamc ${result} Unknown statistics error |
| 22 |
|
| 23 |
Empty Part Test |
| 24 |
Set Test Variable ${MESSAGE} ${RSPAMD_TESTDIR}/messages/empty_part.eml |
| 25 |
${result} = Run Rspamc -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} learn_spam ${MESSAGE} |
| 26 |
Check Rspamc ${result} |
| 27 |
Scan File ${MESSAGE} |
| 28 |
Expect Symbol BAYES_SPAM |
| 29 |
|
| 30 |
Learn |
| 31 |
[Arguments] ${user} ${class} ${message} |
| 32 |
IF "${user}" |
| 33 |
${result} = Run Rspamc -d ${user} -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} learn_${class} ${message} |
| 34 |
ELSE |
| 35 |
${result} = Run Rspamc -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} learn_${class} ${message} |
| 36 |
END |
| 37 |
Check Rspamc ${result} |
| 38 |
|
| 39 |
Learn Test |
| 40 |
[Arguments] ${user}=${EMPTY} |
| 41 |
Set Suite Variable ${RSPAMD_STATS_LEARNTEST} 0 |
| 42 |
Set Test Variable ${kwargs} &{EMPTY} |
| 43 |
IF "${user}" |
| 44 |
Set To Dictionary ${kwargs} Deliver-To=${user} |
| 45 |
END |
| 46 |
Learn ${user} spam ${MESSAGE_SPAM} |
| 47 |
Learn ${user} ham ${MESSAGE_HAM} |
| 48 |
Scan File ${MESSAGE_SPAM} &{kwargs} |
| 49 |
Expect Symbol BAYES_SPAM |
| 50 |
Scan File ${MESSAGE_HAM} &{kwargs} |
| 51 |
Expect Symbol BAYES_HAM |
| 52 |
Set Suite Variable ${RSPAMD_STATS_LEARNTEST} 1 |
| 53 |
|
| 54 |
Relearn Test |
| 55 |
[Arguments] ${user}=${EMPTY} |
| 56 |
IF ${RSPAMD_STATS_LEARNTEST} == 0 |
| 57 |
Fail "Learn test was not run" |
| 58 |
END |
| 59 |
Learn ${user} ham ${MESSAGE_SPAM} |
| 60 |
Set Test Variable ${kwargs} &{EMPTY} |
| 61 |
IF "${user}" |
| 62 |
Set To Dictionary ${kwargs} Deliver-To=${user} |
| 63 |
END |
| 64 |
Scan File ${MESSAGE_SPAM} &{kwargs} |
| 65 |
${pass} = Run Keyword And Return Status Expect Symbol BAYES_HAM |
| 66 |
IF ${pass} |
| 67 |
Pass Execution What Me Worry |
| 68 |
END |
| 69 |
Do Not Expect Symbol BAYES_SPAM |