blob: d9df49813c24d3abe97b495fbe02e8641c5a48b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
*** 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}
Should Contain ${result.stdout} success = true
Follow Rspamd Log
${result} = Scan Message With Rspamc ${MESSAGE}
Follow Rspamd Log
Should Contain ${result.stdout} 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}
Follow Rspamd Log
Should Contain ${result.stdout} success = true
${result} = Scan Message With Rspamc ${MESSAGE}
Follow Rspamd Log
Should Contain ${result.stdout} 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}
Follow Rspamd Log
Should Contain ${result.stdout} success = true
${result} = Scan Message With Rspamc ${MESSAGE}
Follow Rspamd Log
Should Contain ${result.stdout} 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}
Follow Rspamd Log
Should Contain ${result.stdout} success = true
${result} = Scan Message With Rspamc ${MESSAGE}
Follow Rspamd Log
Should Contain ${result.stdout} BAYES_SPAM
${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_ham ${MESSAGE}
Follow Rspamd Log
Should Contain ${result.stdout} success = true
${result} = Scan Message With Rspamc ${MESSAGE}
Follow Rspamd Log
Should Contain ${result.stdout} 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}
Follow Rspamd Log
Should Contain ${result.stdout} success = true
${result} = Scan Message With Rspamc ${MESSAGE}
Follow Rspamd Log
Should Contain ${result.stdout} 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}
Follow Rspamd Log
Should Contain ${result.stdout} success = true
${result} = Scan Message With Rspamc ${MESSAGE}
Follow Rspamd Log
Should Contain ${result.stdout} BAYES_SPAM
${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_ham ${MESSAGE}
Follow Rspamd Log
Should Contain ${result.stdout} success = true
${result} = Scan Message With Rspamc ${MESSAGE}
Follow Rspamd Log
Should Contain ${result.stdout} BAYES_HAM
[Teardown] Generic Teardown
|