blob: 6e02e57a392e5a3bd66e8d62a83585209853228b (
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
*** Settings ***
Suite Setup Settings Setup
Suite Teardown Settings Teardown
Library ${TESTDIR}/lib/rspamd.py
Resource ${TESTDIR}/lib/rspamd.robot
Variables ${TESTDIR}/lib/vars.py
*** Variables ***
${CONFIG} ${TESTDIR}/configs/plugins.conf
${LUA_SCRIPT} ${TESTDIR}/lua/settings.lua
${MESSAGE} ${TESTDIR}/messages/spam_message.eml
${MESSAGE_PRIORITY} ${TESTDIR}/messages/priority.eml
${MESSAGE_7BIT} ${TESTDIR}/messages/utf.eml
${MESSAGE_CUSTOM_HDR} ${TESTDIR}/messages/empty-plain-text.eml
${MESSAGE_ABSENT_MIME} ${TESTDIR}/messages/ed25519.eml
${SPAM_MESSAGE} ${TESTDIR}/messages/spam.eml
${HAM_MESSAGE} ${TESTDIR}/messages/ham.eml
${RSPAMD_SCOPE} Suite
${URL_TLD} ${TESTDIR}/../lua/unit/test_tld.dat
*** Keywords ***
Check Everything Disabled
Expect Action no action
Do Not Expect Symbol SIMPLE_VIRTUAL
Do Not Expect Symbol SIMPLE_PRE
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol BAYES_SPAM
*** Test Cases ***
NO SETTINGS SPAM
Scan File ${SPAM_MESSAGE}
Expect Symbol SIMPLE_TEST
Expect Symbol SIMPLE_VIRTUAL
Do Not Expect Symbol SIMPLE_VIRTUAL1
Expect Symbol SIMPLE_PRE
Expect Symbol SIMPLE_POST
Expect Symbol BAYES_SPAM
NO SETTINGS HAM
Scan File ${HAM_MESSAGE}
Expect Symbol SIMPLE_TEST
Expect Symbol SIMPLE_PRE
Expect Symbol SIMPLE_POST
Expect Symbol BAYES_HAM
EMPTY SYMBOLS ENABLED - STATIC
Scan File ${SPAM_MESSAGE} IP=5.5.5.5
Check Everything Disabled
EMPTY GROUPS ENABLED - STATIC
Scan File ${SPAM_MESSAGE} IP=5.5.5.6
Check Everything Disabled
EMPTY SYMBOLS ENABLED - SETTINGS-ID
Scan File ${SPAM_MESSAGE} Settings-Id=empty_symbols_enabled
Check Everything Disabled
EMPTY GROUPS ENABLED - SETTINGS-ID
Scan File ${SPAM_MESSAGE} Settings-Id=empty_groups_enabled
Check Everything Disabled
ENABLE SYMBOL - NORMAL
Scan File ${HAM_MESSAGE} Settings={symbols_enabled = ["SIMPLE_TEST"]}
Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_PRE
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol BAYES_HAM
ENABLE SYMBOL - POSTFILTER
Scan File ${HAM_MESSAGE} Settings={symbols_enabled = ["SIMPLE_TEST", "SIMPLE_POST"]}
Expect Symbol SIMPLE_TEST
Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
Do Not Expect Symbol BAYES_HAM
ENABLE SYMBOL - PREFILTER
Scan File ${HAM_MESSAGE} Settings={symbols_enabled = ["SIMPLE_PRE"]}
Expect Symbol SIMPLE_PRE
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol BAYES_HAM
ENABLE SYMBOL - CLASSIFIER
Scan File ${HAM_MESSAGE} Settings={symbols_enabled = ["BAYES_HAM", "BAYES_SPAM"]}
Expect Symbol BAYES_HAM
Do Not Expect Symbol SIMPLE_PRE
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_TEST
DISABLE SYMBOL - NORMAL
Scan File ${MESSAGE} Settings={symbols_disabled = ["SIMPLE_TEST"]}
Do Not Expect Symbol SIMPLE_TEST
Expect Symbol SIMPLE_PRE
Expect Symbol SIMPLE_POST
RESCORE SYMBOL - NORMAL
Scan File ${MESSAGE} Settings={SIMPLE_TEST = 3.33}
Expect Symbol With Score SIMPLE_TEST 3.33
INJECT SYMBOL - NORMAL
Scan File ${MESSAGE} Settings={symbols = ["INJECTED_SYMBOL1", "INJECTED_SYMBOL2"]}
Expect Symbol INJECTED_SYMBOL1
Expect Symbol INJECTED_SYMBOL2
RESCORE ACTION
Scan File ${MESSAGE} Settings={actions { reject = 1234.5; } }
Expect Required Score 1234.5
DISABLE GROUP - NORMAL
Scan File ${MESSAGE} Settings={groups_disabled = ["b"]}
Do Not Expect Symbol SIMPLE_TEST
Expect Symbol SIMPLE_PRE
Expect Symbol SIMPLE_POST
ENABLE GROUP - NORMAL
Scan File ${MESSAGE} Settings={groups_enabled = ["b"]}
Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_PRE
Do Not Expect Symbol SIMPLE_POST
SETTINGS ID - NORMAL
Scan File ${MESSAGE} Settings-Id=id_test
Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_PRE
Do Not Expect Symbol SIMPLE_POST
SETTINGS ID - PRE
Scan File ${MESSAGE} Settings-Id=id_pre
Expect Symbol SIMPLE_PRE
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_POST
SETTINGS ID - VIRTUAL
Scan File ${MESSAGE} Settings-Id=id_virtual
Expect Symbol SIMPLE_VIRTUAL
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_VIRTUAL1
Do Not Expect Symbol DEP_REAL
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
SETTINGS ID - VIRTUAL GROUP
Scan File ${MESSAGE} Settings-Id=id_virtual_group
Expect Symbol With Score SIMPLE_VIRTUAL 10
Expect Symbol With Score EXPLICIT_VIRTUAL 10
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_VIRTUAL1
Do Not Expect Symbol DEP_REAL
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
SETTINGS ID - VIRTUAL FROM
Scan File ${MESSAGE} From=test2@example.com
Expect Symbol With Score SIMPLE_VIRTUAL 10
Expect Symbol With Score EXPLICIT_VIRTUAL 10
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_VIRTUAL1
Do Not Expect Symbol DEP_REAL
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
SETTINGS ID - VIRTUAL USER
Scan File ${MESSAGE} User=test@example.com
Expect Symbol With Score SIMPLE_VIRTUAL 10
Expect Symbol With Score EXPLICIT_VIRTUAL 10
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_VIRTUAL1
Do Not Expect Symbol DEP_REAL
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
SETTINGS ID - VIRTUAL HOSTNAME
Scan File ${MESSAGE} Hostname=example.com
Expect Symbol With Score SIMPLE_VIRTUAL 10
Expect Symbol With Score EXPLICIT_VIRTUAL 10
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_VIRTUAL1
Do Not Expect Symbol DEP_REAL
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
SETTINGS ID - VIRTUAL SELECTOR
Scan File ${MESSAGE} Rcpt=user3@example.com
Expect Symbol With Score SIMPLE_VIRTUAL 10
Expect Symbol With Score EXPLICIT_VIRTUAL 10
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_VIRTUAL1
Do Not Expect Symbol DEP_REAL
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
SETTINGS ID - ANGLED RECIPIENT
Scan File ${MESSAGE} Rcpt=<user3@example.com>
Expect Symbol With Score SIMPLE_VIRTUAL 10
Expect Symbol With Score EXPLICIT_VIRTUAL 10
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_VIRTUAL1
Do Not Expect Symbol DEP_REAL
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
SETTINGS ID - VIRTUAL HEADER MATCH
Scan File ${MESSAGE_7BIT}
Expect Symbol With Score SIMPLE_VIRTUAL 10
Expect Symbol With Score EXPLICIT_VIRTUAL 10
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_VIRTUAL1
Do Not Expect Symbol DEP_REAL
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
SETTINGS ID - VIRTUAL HEADER EXISTS
Scan File ${MESSAGE_CUSTOM_HDR}
Expect Symbol With Score SIMPLE_VIRTUAL 10
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_VIRTUAL1
Do Not Expect Symbol DEP_REAL
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
SETTINGS ID - VIRTUAL HEADER ABSENT
Scan File ${MESSAGE_ABSENT_MIME}
Expect Symbol With Score SIMPLE_VIRTUAL 10
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_VIRTUAL1
Do Not Expect Symbol DEP_REAL
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
SETTINGS ID - VIRTUAL REQUEST HEADER
Scan File ${MESSAGE} Test=passed
Expect Symbol With Score SIMPLE_VIRTUAL 10
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_VIRTUAL1
Do Not Expect Symbol DEP_REAL
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
SETTINGS ID - VIRTUAL DEP
Scan File ${MESSAGE} Settings-Id=id_virtual1
Expect Symbol EXPLICIT_VIRTUAL1
Expect Symbol DEP_VIRTUAL
Expect Symbol DEP_REAL
Do Not Expect Symbol SIMPLE_TEST
Do Not Expect Symbol SIMPLE_VIRTUAL
Do Not Expect Symbol SIMPLE_POST
Do Not Expect Symbol SIMPLE_PRE
PRIORITY
Scan File ${MESSAGE_PRIORITY} Settings-Id=id_virtual_group From=user@test.com
Expect Symbol PRIORITY_2
*** Keywords ***
Settings Setup
Copy File ${TESTDIR}/data/bayes.spam.sqlite3 /tmp/bayes.spam.sqlite3
Copy File ${TESTDIR}/data/bayes.ham.sqlite3 /tmp/bayes.ham.sqlite3
${PLUGIN_CONFIG} = Get File ${TESTDIR}/configs/settings.conf
Set Suite Variable ${PLUGIN_CONFIG}
Generic Setup PLUGIN_CONFIG
Settings Teardown
Normal Teardown
|