blob: 172433984f30ddfc12fa61c257fd0652e5c65afe (
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
|
require "vnd.dovecot.testsuite";
require "notify";
require "body";
require "relational";
require "comparator-i;ascii-numeric";
/*
* Simple test
*/
test_set "message" text:
From: stephan@example.org
To: nico@frop.example.org
Subject: Frop!
Klutsefluts.
.
;
test "Simple" {
notify :method "mailto" :options "stephan@example.org";
if not test_result_execute {
test_fail "failed to execute notify";
}
test_message :smtp 0;
if not header :matches "Auto-Submitted" "auto-generated*" {
test_fail "auto-submitted header set inappropriately";
}
if not exists "X-Sieve" {
test_fail "x-sieve header missing from outgoing message";
}
}
/*
* Multiple recipients
*/
test_result_reset;
test_set "message" text:
From: stephan@example.org
To: nico@frop.example.org
Subject: Frop!
Klutsefluts.
.
;
test "Multiple recipients" {
notify :options ["timo@example.com","stephan@dovecot.example.net","postmaster@frop.example.org"];
if not test_result_execute {
test_fail "failed to execute notify";
}
test_message :smtp 0;
if not address :is "to" "timo@example.com" {
test_fail "first To address missing";
}
test_message :smtp 1;
if not address :is "to" "stephan@dovecot.example.net" {
test_fail "second To address missing";
}
if not header :matches "Auto-Submitted" "auto-generated*" {
test_fail "auto-submitted header not found for second message";
}
test_message :smtp 2;
if not address :is "to" "postmaster@frop.example.org" {
test_fail "third To address missing";
}
if not header :matches "Auto-Submitted" "auto-generated*" {
test_fail "auto-submitted header not found for third message";
}
if not address :count "eq" :comparator "i;ascii-numeric" "to" "3" {
test_fail "wrong number of recipients in To header";
}
if not address :count "eq" :comparator "i;ascii-numeric" "cc" "0" {
test_fail "too many recipients in Cc header";
}
}
/*
* Duplicate recipients
*/
test_result_reset;
test_set "message" text:
From: stephan@example.org
To: nico@frop.example.org
Subject: Frop!
Klutsefluts.
.
;
test "Duplicate recipients" {
notify :options ["timo@example.com", "stephan@dovecot.example.net", "stephan@dovecot.example.net"];
notify :options ["timo@example.com", "stephan@example.org"];
if not test_result_execute {
test_fail "failed to execute notify";
}
test_message :smtp 2;
if address "To" "stephan@dovecot.example.net" {
test_fail "duplicate recipient not removed from first message";
}
if address "To" "timo@example.com" {
test_fail "duplicate recipient not removed from second message";
}
}
/*
* Notifying on automated messages
*/
test_result_reset;
test_set "message" text:
From: stephan@example.org
To: nico@frop.example.org
Auto-submitted: auto-notify
Subject: Frop!
Klutsefluts.
.
;
test "Notifying on automated messages" {
notify :options "stephan@example.org";
if not test_result_execute {
test_fail "failed to execute notify";
}
if test_message :smtp 0 {
test_fail "notified of auto-submitted message";
}
}
test_result_reset;
test_set "message" text:
To: nico@frop.example.org
From: stephan@example.org
Subject: Test
Test. Test
Frop!
.
;
test "Body; Singular Message" {
notify :low :id "frop" :options "stephan@example.org"
:message text:
Received interesting message:
$text$
You have been notified.
.
;
if not test_result_execute {
test_fail "failed to execute notify";
}
test_message :smtp 0;
if not body :raw :contains "Received interesting message" {
test_fail "notification has no heading";
}
if not body :raw :contains "You have been notified" {
test_fail "notification has no footer";
}
if not allof(
body :raw :contains "Test. Test",
body :raw :contains "Frop" ) {
test_fail "notification has no original message";
}
}
test_result_reset;
test_set "message" text:
To: nico@frop.example.org
From: stephan@example.org
Subject: Test
Test. Test
Frop!
.
;
test "Body; $text[maxsize]$" {
notify :low :id "frop" :options "sirius@example.org"
:message text:
Received interesting message:
$text[5]$
You have been notified.
.
;
if not test_result_execute {
test_fail "failed to execute notify";
}
test_message :smtp 0;
if not body :raw :contains "Received interesting message" {
test_fail "notification has no heading";
}
if not body :raw :contains "You have been notified" {
test_fail "notification has no footer";
}
if anyof(
body :raw :contains "Test. Test",
body :raw :contains "Frop" ) {
test_fail "original message in notification is not truncated";
}
if not body :raw :contains "Test." {
test_fail "notification does not contain the required message";
}
}
test_result_reset;
test_set "message" text:
From: Whomever <whoever@example.com>
To: Someone <someone@example.com>
Date: Sat, 10 Oct 2009 00:30:04 +0200
Subject: whatever
Content-Type: multipart/mixed; boundary=outer
This is a multi-part message in MIME format.
--outer
Content-Type: multipart/alternative; boundary=inner
This is a nested multi-part message in MIME format.
--inner
Content-Type: application/sieve; charset="us-ascii"
keep;
--inner
Content-Type: text/plain; charset="us-ascii"
Friep!
--inner--
This is the end of the inner MIME multipart.
--outer
Content-Type: message/rfc822
From: Someone Else
Subject: hello request
Please say Hello
--outer--
This is the end of the outer MIME multipart.
.
;
test "Body; Multipart Message" {
notify :low :id "frop" :options "stephan@example.org"
:message text:
Received interesting message:
$text$
You have been notified.
.
;
if not test_result_execute {
test_fail "failed to execute notify";
}
test_message :smtp 0;
if not body :raw :contains "Friep!" {
test_fail "notification has incorrect content";
}
}
|