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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
require "vnd.dovecot.testsuite";
require "mime";
require "foreverypart";
/*
* Basic functionionality
*/
test_set "message" text:
From: stephan@example.com
To: nico@nl.example.com, harry@de.example.com
cc: Timo <tss(no spam)@fi.iki>
Subject: Frobnitzm
Test.
.
;
test "Basic functionality" {
/* Must match */
if not address :mime :anychild :contains ["to", "from"] "harry" {
test_fail "failed to match address (1)";
}
if not address :mime :anychild :contains ["to", "from"] "de.example" {
test_fail "failed to match address (2)";
}
if not address :mime :anychild :matches "to" "*@*.example.com" {
test_fail "failed to match address (3)";
}
if not address :mime :anychild :is "to" "harry@de.example.com" {
test_fail "failed to match address (4)";
}
/* Must not match */
if address :mime :anychild :is ["to", "from"] "nonsense@example.com" {
test_fail "matches erroneous address";
}
/* Match first key */
if not address :mime :anychild :contains ["to"] ["nico", "fred", "henk"] {
test_fail "failed to match first key";
}
/* Match second key */
if not address :mime :anychild :contains ["to"] ["fred", "nico", "henk"] {
test_fail "failed to match second key";
}
/* Match last key */
if not address :mime :anychild :contains ["to"] ["fred", "henk", "nico"] {
test_fail "failed to match last key";
}
/* First header */
if not address :mime :anychild :contains
["to", "from"] ["fred", "nico", "henk"] {
test_fail "failed to match first header";
}
/* Second header */
if not address :mime :anychild :contains
["from", "to"] ["fred", "nico", "henk"] {
test_fail "failed to match second header";
}
/* Comment */
if not address :mime :anychild :is "cc" "tss@fi.iki" {
test_fail "failed to ignore comment in address";
}
}
/*
* Basic functionionality - foreverypart
*/
test "Basic functionality - foreverypart" {
foreverypart {
/* Must match */
if not address :mime :anychild :contains ["to", "from"] "harry" {
test_fail "failed to match address (1)";
}
if not address :mime :anychild :contains ["to", "from"] "de.example" {
test_fail "failed to match address (2)";
}
if not address :mime :anychild :matches "to" "*@*.example.com" {
test_fail "failed to match address (3)";
}
if not address :mime :anychild :is "to" "harry@de.example.com" {
test_fail "failed to match address (4)";
}
/* Must not match */
if address :mime :anychild :is ["to", "from"] "nonsense@example.com" {
test_fail "matches erroneous address";
}
/* Match first key */
if not address :mime :anychild :contains ["to"] ["nico", "fred", "henk"] {
test_fail "failed to match first key";
}
/* Match second key */
if not address :mime :anychild :contains ["to"] ["fred", "nico", "henk"] {
test_fail "failed to match second key";
}
/* Match last key */
if not address :mime :anychild :contains ["to"] ["fred", "henk", "nico"] {
test_fail "failed to match last key";
}
/* First header */
if not address :mime :anychild :contains
["to", "from"] ["fred", "nico", "henk"] {
test_fail "failed to match first header";
}
/* Second header */
if not address :mime :anychild :contains
["from", "to"] ["fred", "nico", "henk"] {
test_fail "failed to match second header";
}
/* Comment */
if not address :mime :anychild :is "cc" "tss@fi.iki" {
test_fail "failed to ignore comment in address";
}
}
}
/*
* Address headers
*/
test_set "message" text:
From: stephan@friep.frop
To: henk@tukkerland.ex
CC: ivo@boer.ex
Bcc: joop@hooibaal.ex
Sender: s.bosch@friep.frop
Resent-From: ivo@boer.ex
Resent-To: idioot@dombo.ex
Subject: Berichtje
Test.
.
;
test "Address headers" {
if not address :mime :anychild "from" "stephan@friep.frop" {
test_fail "from header not recognized";
}
if not address :mime :anychild "to" "henk@tukkerland.ex" {
test_fail "to header not recognized";
}
if not address :mime :anychild "cc" "ivo@boer.ex" {
test_fail "cc header not recognized";
}
if not address :mime :anychild "bcc" "joop@hooibaal.ex" {
test_fail "bcc header not recognized";
}
if not address :mime :anychild "sender" "s.bosch@friep.frop" {
test_fail "sender header not recognized";
}
if not address :mime :anychild "resent-from" "ivo@boer.ex" {
test_fail "resent-from header not recognized";
}
if not address :mime :anychild "resent-to" "idioot@dombo.ex" {
test_fail "resent-to header not recognized";
}
}
/*
* Address headers - foreverypart
*/
test "Address headers - foreverypart" {
foreverypart {
if not address :mime :anychild "from" "stephan@friep.frop" {
test_fail "from header not recognized";
}
if not address :mime :anychild "to" "henk@tukkerland.ex" {
test_fail "to header not recognized";
}
if not address :mime :anychild "cc" "ivo@boer.ex" {
test_fail "cc header not recognized";
}
if not address :mime :anychild "bcc" "joop@hooibaal.ex" {
test_fail "bcc header not recognized";
}
if not address :mime :anychild "sender" "s.bosch@friep.frop" {
test_fail "sender header not recognized";
}
if not address :mime :anychild "resent-from" "ivo@boer.ex" {
test_fail "resent-from header not recognized";
}
if not address :mime :anychild "resent-to" "idioot@dombo.ex" {
test_fail "resent-to header not recognized";
}
}
}
/*
* Multipart anychild
*/
test_set "message" text:
From: Hendrik <hendrik@example.com>
To: Harrie <harrie@example.com>
Date: Sat, 11 Oct 2010 00:31:44 +0200
Subject: Harrie is een prutser
Content-Type: multipart/mixed; boundary=AA
CC: AA@example.com
This is a multi-part message in MIME format.
--AA
Content-Type: multipart/mixed; boundary=BB
CC: BB@example.com
This is a multi-part message in MIME format.
--BB
Content-Type: text/plain; charset="us-ascii"
CC: CC@example.com
Hello
--BB
Content-Type: text/plain; charset="us-ascii"
CC: DD@example.com
Hello again
--BB--
This is the end of MIME multipart.
--AA
Content-Type: text/plain; charset="us-ascii"
CC: EE@example.com
And again
--AA--
This is the end of MIME multipart.
.
;
test "Multipart anychild" {
if not address :mime :anychild :localpart "Cc" "AA" {
test_fail "AA Cc repient does not exist";
}
if not address :mime :anychild :localpart "Cc" "BB" {
test_fail "BB Cc repient does not exist";
}
if not address :mime :anychild :localpart "Cc" "CC" {
test_fail "CC Cc repient does not exist";
}
if not address :mime :anychild :localpart "Cc" "DD" {
test_fail "DD Cc repient does not exist";
}
if not address :mime :anychild :localpart "Cc" "EE" {
test_fail "EE Cc repient does not exist";
}
}
|