File: text.svtest

package info (click to toggle)
dovecot 1%3A2.2.27-3%2Bdeb9u2~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 48,520 kB
  • sloc: ansic: 430,475; sh: 17,438; makefile: 6,587; cpp: 1,557; perl: 295; python: 67; xml: 44; pascal: 27
file content (225 lines) | stat: -rw-r--r-- 4,344 bytes parent folder | download | duplicates (9)
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
require "vnd.dovecot.testsuite";
require "relational";
require "comparator-i;ascii-numeric";

require "body";

/*
 *
 */

test_set "message" text:
From: justin@example.com
To: carl@example.nl
Subject: Frop
Content-Type: multipart/mixed; boundary=donkey

This is a multi-part message in MIME format.

--donkey
Content-Type: text/plain

Plain Text

--donkey
Content-Type: text/stupid

Stupid Text

--donkey
Content-Type: text/plain/stupid

Plain Stupid Text

--donkey--
.
;

test "Basic Match" {
	if not body :text :contains "Plain Text" {
		test_fail "failed to match (1)";
	}

	if not body :text :contains "Stupid Text" {
		test_fail "failed to match (2)";
	}
}

test "Double Slash" {
	if body :text :contains "Plain Stupid Text" {
		test_fail "matched \"text/plain/stupid\"";
	}
}

/*
 *
 */

test_set "message" text:
From: justin@example.com
To: carl@example.nl
Subject: Frop
Content-Type: multipart/mixed; boundary=limit

This is a multi-part message in MIME format.

--limit
Content-Type: text/plain

This is a text message.

--limit
Content-Type: text/html

<html><body>This is HTML</body></html>

--limit
Content-Type: application/sieve

keep;

--limit--
.
;

test "Full Content Type" {
	if not body :text :contains "This is a text message" {
		test_fail "failed to match text/plain content";
	}

	if not body :text :contains "This is HTML" {
		test_fail "failed to match text/html content";
	}

	if body :text :contains "<html>" {
		test_fail "erroneously matched text/html markup";
	}

	if body :text :contains "keep;" {
		test_fail "body :text test matched non-text content";
	}
}

/*
 *
 */

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: text/plain; charset="us-ascii"

Hello

--inner
Content-Type: text/html; charset="us-ascii"

<html><body>HTML Hello</body></html>

--inner
Content-Type: application/xhtml+xml; charset="us-ascii"

<html><body>XHTML Hello</body></html>

--inner--

This is the end of the inner MIME multipart.

--outer
Content-Type: message/rfc822

From: Someone Else
Subject: Hello, this is an elaborate request for you to finally say hello
 already!

Please say Hello

--outer--

This is the end of the outer MIME multipart.
.
;

/* RFC5173, Section 5.2:
 *
 *  The search for MIME parts matching the :content specification is
 *  recursive and automatically descends into multipart and
 *  message/rfc822 MIME parts.  All MIME parts with matching types are
 *  searched for the key strings.  The test returns true if any
 *  combination of a searched MIME part and key-list argument match.
 */

test "Nested Search" {
	if not body :text :contains "Hello" {
		test_fail "failed to match text/plain content";
	}
	if not body :text :contains "HTML Hello" {
		test_fail "failed to match text/html content";
	}
	if not body :text :contains "XHTML Hello" {
		test_fail "failed to match application/xhtml+xml content";
	}
	if body :text :contains ["<html>", "body"] {
		test_fail "erroneously matched text/html markup";
	}
	if not body :text :contains "Please say Hello" {
		test_fail "failed to match message/rfc822 body";
	}
	if body :text :contains "MIME" {
		test_fail "erroneously matched multipart prologue/epilogue text";
	}
}

/*
 * Broken/Empty parts
 */

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: text/html

--outer
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: multipart/related
Content-Disposition: inline

<html><body>Please say Hello</body></html>

--outer--

This is the end of the outer MIME multipart.
.
;

test "Nested Search" {
	if body :text :contains "Hello" {
		test_fail "Cannot match empty/broken part";
	}
	if body :text :contains ["<html>", "body"] {
		test_fail "erroneously matched text/html markup";
	}
	if body :text :contains "MIME" {
		test_fail "erroneously matched multipart prologue/epilogue text";
	}
}