~ubuntu-dev/ubuntu/lucid/dovecot/lucid-201002101901

« back to all changes in this revision

Viewing changes to libsieve/tests/extensions/body/content.svtest

  • Committer: Chuck Short
  • Date: 2010-01-21 20:21:25 UTC
  • mfrom: (4.1.11 squeeze)
  • Revision ID: zulcss@ubuntu.com-20100121202125-pme73o491kfwj5nc
* Merge from debian testing, remaining changes:
  + Add new binary pkg dovecot-postfix that integrates postfix and dovecot
    automatically: (LP: #164837)
  + debian/control:
    - add new binary with short description
    - set Architecture all for dovecot-postfix (LP: #329878)
  + debian/dovecot-postfix.postinst:
    - create initial certificate symlinks to snakeoil.
    - set up postfix with postconf to:
      - use Maildir/ as the default mailbox.
      - use dovecot as the sasl authentication server.
      - use dovecot LDA (deliver).
      - use tls for smtp{d} services.
    - fix certificates paths in postfix' main.cf
    - add reject_unauth_destination to postfix' recipient restrictions
    - add reject_unknown_sender_domain to postfix' sender restriction
    - rename configuration name on remove, delete on purge
    - restart dovecot after linking certificates
    - handle use case when postfix is unconfigurated
  + debian/dovecot-postfix.dirs: create backup directory for postfix's config
    configuration
  + restart postfix and dovecot.
  + debian/dovecot-postfix.postrm:
    - remove all dovecot related configuration from postfix.
    - restart postfix and dovecot.
  + debian/dovecot-common.init:
    - check if /etc/dovecot/dovecot-postfix.conf exists and use it
      as the configuration file if so.
  + debian/patches/warning-ubuntu-postfix.dpatch
    - add warning about dovecot-postfix.conf in dovecot default
      configuration file
  + debian/patches/dovecot-postfix.conf.diff:
    - Ubuntu server custom changes to the default dovecot configuration for
      better interfation with postfix.
    - enable sieve plugin.
    - Ubuntu server custom changes to the default dovecot configuration for
      better integration with postfix:
      - enable imap, pop3, imaps, pop3s and managesieve by default.
      - enable dovecot LDA (deliver).
      - enable SASL auth socket in postfix private directory
   + debian/rules:
     - copy, patch and install dovecot-postfix.conf in /etc/dovecot/.
     - build architecure independent packages too
   + Use Snakeoil SSL certificates by default.
     - debian/control: Depend on ssl-cert.
     - debian/patches/ssl-cert-snakeoil.dpatch: Change default SSL cert
       paths to snakeoil.
     - debian/dovecot-common.postinst: Relax grep for SSL_* a bit.
   + Add autopkgtest to debian/tests/*.
   + Fast TearDown: Update the lsb init header to not stop in level 6.
   + Add ufw integration:
     - Created debian/dovecot-common.ufw.profile.
     - debian/rules: install profile.
     - debian/control: suggest ufw.
   + debian/{control,rules}: enable PIE hardening.
   + dovecot-imapd, dovecot-pop3: Replaces dovecot-common (<< 1:1.1). (LP: #254721)
   + debian/control: Update Vcs-* headers.
   + Add SMTP-AUTH support for Outlook (login auth mechanism)
* New upstream release.
* debian/patches/gold-fix.patch: Removed. Fixed upstream.
* Moved libexec to lib corrections in dovecot-managesieve.patch and
  dovecot-managesieve-dist.patch to dovecot-example.patch
* debian/patches/dovecot-mboxlocking.patch: Regenerated to avoid FTBFS
  when quilt isn't installed.
* debian/patches/quota-mountpoint.patch: Removed. Not needed anymore.
* debian/patches/dovecot-quota.patch: Removed. Quotas aren't properly
  enabled unless mail_plugins = quota imap_quota.
* debian/patches/gold-fix.patch: Fixed configure script to build even
  with binutils-gold or --no-add-needed linker flag (Closes: #554306)
* debian/dovecot-common.init: fixed LSB headers. Thanks to Pascal Volk.
  (Closes: #558040)
* debian/changelog: added CVE references to previous changelog entry.
* debian/rules: checked up the build system. It's not fragile anymore.
  (Closes: 493803)
* debian/dovecot-common.postinst: Now invoking dpkg-reconfigure
  on dovecot-common is enough to generate new certificates
  if the previous ones were removed. (Closes: #545582)
* debian/rules: No longer install convert-tool in /usr/bin.
  It isn't an user utility and it should stay in /usr/lib/dovecot
  like all other similar tool.
* New upstream release. (Closes: #557601)
* [SECURITY] Fixes local information disclosure and denial of service.
  (see: http://www.dovecot.org/list/dovecot-news/2009-November/000143.html
  and CVE-2009-3897)
* Added myself to uploaders.
* Switched to the new source format "3.0 (quilt)":
  - removed dpatch from build-depends
  - removed debian/README.source because now we use only standard
    dpkg features
  - regenerated all patches
* Prepared to switch to multi-origin source:
  - recreated dovecot-libsieve.patch and dovecot-managesieve-dist.patch
    starting from the upstream tarball
  - removed all autotools related build-depends and build-conflict
  - renamed dovecot-libsieve and dovecot-managesieve directories
    to libsieve and managesieve.
* debian/rules: Moved the configuration of libsieve and managesieve from
  the build phase to the configuration phase
* Added dovecot-dbg package  with debugging symbols.  Thanks Stephan Bosch.
  (Closes: #554710)
* Fixed some stray libexec'isms in the default configuration.
* New upstream release.
* debian/dovecot-common.init:
  - use $CONF when starting the daemon. (Closes: #549944)
  - always output start/stop messages. (Closes: #523810)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require "vnd.dovecot.testsuite";
 
2
require "relational";
 
3
require "comparator-i;ascii-numeric";
 
4
 
 
5
require "body";
 
6
 
 
7
/*
 
8
 *
 
9
 */
 
10
 
 
11
test_set "message" text:
 
12
From: justin@example.com
 
13
To: carl@example.nl
 
14
Subject: Frop
 
15
Content-Type: multipart/mixed; boundary=donkey
 
16
 
 
17
This is a multi-part message in MIME format.
 
18
 
 
19
--donkey
 
20
Content-Type: text/plain
 
21
 
 
22
Plain Text
 
23
 
 
24
--donkey
 
25
Content-Type: text/stupid
 
26
 
 
27
Stupid Text
 
28
 
 
29
--donkey
 
30
Content-Type: text/plain/stupid
 
31
 
 
32
Plain Stupid Text
 
33
 
 
34
--donkey--
 
35
.
 
36
;
 
37
 
 
38
/*
 
39
 * RFC5173, Section 5.2:
 
40
 *  If an individual content type begins or ends with a '/' (slash) or
 
41
 *  contains multiple slashes, then it matches no content types.
 
42
 *  ...
 
43
 */
 
44
 
 
45
test "Basic Match" {
 
46
        if not body :content "text/plain" :matches "Plain Text*" {
 
47
                test_fail "failed to match (1)";
 
48
        }
 
49
 
 
50
        if not body :content "text/plain" :contains "" {
 
51
                test_fail "failed to match (2)";
 
52
        }
 
53
 
 
54
        if not body :content "text/stupid" :contains "" {
 
55
                test_fail "failed to match (3)";
 
56
        }
 
57
}
 
58
 
 
59
test "Begin Slash" {
 
60
        if body :content "/plain" :contains "" {
 
61
                test_fail "matched :content \"/plain\"";
 
62
        }
 
63
}
 
64
 
 
65
test "End Slash" {
 
66
        if body :content "text/" :contains "" {
 
67
                test_fail "matched :content \"text/\"";
 
68
        }
 
69
}
 
70
 
 
71
test "Double Slash" {
 
72
        if body :content "text/plain/stupid" :contains "" {
 
73
                test_fail "matched :content \"text/plain/stupid\"";
 
74
        }
 
75
}
 
76
 
 
77
/*
 
78
 *
 
79
 */
 
80
 
 
81
test_set "message" text:
 
82
From: justin@example.com
 
83
To: carl@example.nl
 
84
Subject: Frop
 
85
Content-Type: multipart/mixed; boundary=limit
 
86
 
 
87
This is a multi-part message in MIME format.
 
88
 
 
89
--limit
 
90
Content-Type: text/plain
 
91
 
 
92
This is a text message.
 
93
 
 
94
--limit
 
95
Content-Type: text/html
 
96
 
 
97
<html><body>This is HTML</body></html>
 
98
 
 
99
--limit
 
100
Content-Type: application/sieve
 
101
 
 
102
keep;
 
103
 
 
104
--limit--
 
105
.
 
106
;
 
107
 
 
108
/* RFC5173, Section 5.2:
 
109
 *  ...
 
110
 *  Otherwise, if it contains a slash, then it specifies a full
 
111
 *  <type>/<subtype> pair, and matches only that specific content type.
 
112
 *  If it is the empty string, all MIME content types are matched.
 
113
 *  Otherwise, it specifies a <type> only, and any subtype of that type
 
114
 *  matches it.
 
115
 */
 
116
 
 
117
test "Full Content Type" {
 
118
        if not body :content "text/plain" :matches "This is a text message.*" {
 
119
                test_fail "failed to match text/plain content";
 
120
        }
 
121
 
 
122
        if body :content "text/plain" :matches "<html><body>This is HTML</body></html>*" {
 
123
                test_fail "erroneously matched text/html content";
 
124
        }
 
125
 
 
126
        if not body :content "text/html" :matches "<html><body>This is HTML</body></html>*" {
 
127
                test_fail "failed to match text/html content";
 
128
        }
 
129
 
 
130
        if body :content "text/html" :matches "This is a text message.*" {
 
131
                test_fail "erroneously matched text/plain content";
 
132
        }
 
133
 
 
134
        if body :content "text/html" :matches "This is HTML*" {
 
135
                test_fail "body :content test matched plain text";
 
136
        }
 
137
}
 
138
 
 
139
test "Empty Content Type" {
 
140
        if not body :content "" :matches "This is a text message.*" {
 
141
                test_fail "failed to match text/plain content";
 
142
        }       
 
143
 
 
144
        if not body :content "" :matches "<html><body>This is HTML</body></html>*" {
 
145
                test_fail "failed to match text/html content";
 
146
        }
 
147
 
 
148
        if not body :content "" :matches "keep;*" {
 
149
                test_fail "failed to match application/sieve content";
 
150
        }       
 
151
 
 
152
        if body :content "" :matches "*blurdybloop*" {
 
153
                test_fail "body :content \"\" test matches nonsense";
 
154
        }       
 
155
}
 
156
 
 
157
test "Main Content Type" {
 
158
        if not body :content "text" :matches "This is a text message.*" {
 
159
                test_fail "failed to match text/plain content";
 
160
        }       
 
161
 
 
162
        if not body :content "text" :matches "<html><body>This is HTML</body></html>*" {
 
163
                test_fail "failed to match text/html content";
 
164
        }
 
165
 
 
166
        if body :content "text" :matches "keep;*" {
 
167
                test_fail "erroneously matched application/sieve content";
 
168
        }       
 
169
}
 
170
 
 
171
/*
 
172
 *
 
173
 */
 
174
 
 
175
test_set "message" text:
 
176
From: Whomever <whoever@example.com>
 
177
To: Someone <someone@example.com>
 
178
Date: Sat, 10 Oct 2009 00:30:04 +0200
 
179
Subject: whatever
 
180
Content-Type: multipart/mixed; boundary=outer
 
181
 
 
182
This is a multi-part message in MIME format.
 
183
 
 
184
--outer
 
185
Content-Type: multipart/alternative; boundary=inner
 
186
 
 
187
This is a nested multi-part message in MIME format.
 
188
 
 
189
--inner
 
190
Content-Type: text/plain; charset="us-ascii"
 
191
 
 
192
Hello
 
193
        
 
194
--inner
 
195
Content-Type: text/html; charset="us-ascii"
 
196
 
 
197
<html><body>Hello</body></html>
 
198
 
 
199
--inner--
 
200
 
 
201
This is the end of the inner MIME multipart.
 
202
 
 
203
--outer
 
204
Content-Type: message/rfc822
 
205
 
 
206
From: Someone Else
 
207
Subject: hello request
 
208
 
 
209
Please say Hello
 
210
 
 
211
--outer--
 
212
 
 
213
This is the end of the outer MIME multipart.
 
214
.
 
215
;
 
216
 
 
217
/* RFC5173, Section 5.2:
 
218
 *
 
219
 *  The search for MIME parts matching the :content specification is
 
220
 *  recursive and automatically descends into multipart and
 
221
 *  message/rfc822 MIME parts.  All MIME parts with matching types are
 
222
 *  searched for the key strings.  The test returns true if any
 
223
 *  combination of a searched MIME part and key-list argument match.
 
224
 */
 
225
 
 
226
test "Nested Search" {
 
227
        if not body :content "text/plain" :matches "Hello*" {
 
228
                test_fail "failed to match text/plain content";
 
229
        }
 
230
 
 
231
        if body :content "text/plain" :matches "<html><body>Hello</body></html>*" {
 
232
                test_fail "erroneously matched text/html content";
 
233
        }
 
234
 
 
235
        if not body :content "text/html" :matches "<html><body>Hello</body></html>*" {
 
236
                test_fail "failed to match text/html content";
 
237
        }
 
238
 
 
239
        if body :content "text/html" :matches "Hello*" {
 
240
                test_fail "erroneously matched text/plain content";
 
241
        }
 
242
 
 
243
        if not body :content "text" :contains "html" {
 
244
                test_fail "failed match text content (1)";      
 
245
        }
 
246
 
 
247
        if not body :content "text" :contains "hello" {
 
248
                test_fail "failed match text content (2)";
 
249
        }
 
250
 
 
251
        if not body :content "text/plain" :contains "please say hello" {
 
252
                test_fail "failed match nested message content as text/plain";
 
253
        }
 
254
 
 
255
        if not body :content "text" :contains "please say hello" {
 
256
                test_fail "failed match nested message content as text/*";
 
257
        }
 
258
        
 
259
        if not body :content "text" :count "eq" :comparator "i;ascii-numeric" "3" {
 
260
                test_fail "matched wrong number of \"text/*\" body parts";
 
261
        }
 
262
}
 
263
 
 
264
/* RFC5173, Section 5.2:
 
265
 *
 
266
 *  If the :content specification matches a multipart MIME part, only the
 
267
 *  prologue and epilogue sections of the part will be searched for the
 
268
 *  key strings, treating the entire prologue and the entire epilogue as
 
269
 *  separate strings; the contents of nested parts are only searched if
 
270
 *  their respective types match the :content specification.
 
271
 *
 
272
 */
 
273
 
 
274
test "Multipart Content" {
 
275
        if not body :content "multipart" :contains
 
276
                "This is a multi-part message in MIME format" {
 
277
                test_fail "missed first multipart body part";
 
278
        }
 
279
 
 
280
        if not body :content "multipart" :contains
 
281
                "This is a nested multi-part message in MIME format" {
 
282
                test_fail "missed second multipart body part";
 
283
        }
 
284
        
 
285
/* FIXME: FAILS
 
286
 
 
287
        if not body :content "multipart" :contains
 
288
                "This is the end of the inner MIME multipart" {
 
289
                test_fail "missed third multipart body part";
 
290
        }
 
291
 
 
292
        if not body :content "multipart" :contains
 
293
                "This is the end of the outer MIME multipart." {
 
294
                test_fail "missed fourth multipart body part";
 
295
        }       
 
296
 
 
297
        if body :content "multipart" :contains "--inner" {
 
298
                test_fail "inner boundary is part of match";
 
299
        }
 
300
 
 
301
        if body :content "multipart" :contains "--outer" {
 
302
                test_fail "outer boundary is part of match";
 
303
        }
 
304
*/
 
305
}
 
306
 
 
307
/* RFC5173, Section 5.2:
 
308
 *
 
309
 *  If the :content specification matches a message/rfc822 MIME part,
 
310
 *  only the header of the nested message will be searched for the key
 
311
 *  strings, treating the header as a single string; the contents of the
 
312
 *  nested message body parts are only searched if their content type
 
313
 *  matches the :content specification.
 
314
 */
 
315
 
 
316
/* FIXME */
 
317
 
 
318