File: exists.svtest

package info (click to toggle)
dovecot 1%3A2.3.4.1-5%2Bdeb10u6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 48,648 kB
  • sloc: ansic: 500,433; makefile: 7,372; sh: 5,592; cpp: 1,555; perl: 303; python: 73; xml: 44; pascal: 27
file content (237 lines) | stat: -rw-r--r-- 5,382 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
226
227
228
229
230
231
232
233
234
235
236
237
require "vnd.dovecot.testsuite";
require "mime";
require "foreverypart";

test_set "message" text:
From: stephan@example.org
To: nico@vestingbar.bl
Subject: Test message
Date: Wed, 29 Jul 2009 18:21:44 +0300
X-Spam-Status: Not Spam
Resent-To: nico@frop.example.com

Test!
.
;

/*
 * One header
 */

test "One header" {
	if not exists :mime :anychild "from" {
		test_fail "exists test missed from header";
	}

	if exists :mime :anychild "x-nonsense" {
		test_fail "exists test found non-existent header";
	}
}

/*
 * One header - foreverypart
 */

test "One header - foreverypart" {
	foreverypart {
		if not exists :mime :anychild "from" {
			test_fail "exists test missed from header";
		}

		if exists :mime :anychild "x-nonsense" {
			test_fail "exists test found non-existent header";
		}
	}
}

/*
 * Two headers
 */

test "Two headers" {
	if not exists :mime :anychild ["from","to"] {
		test_fail "exists test missed from or to header";
	}

	if exists :mime :anychild ["from","x-nonsense"] {
		test_fail "exists test found non-existent header (1)";
	}

	if exists :mime :anychild ["x-nonsense","to"] {
		test_fail "exists test found non-existent header (2)";
	}

	if exists :mime :anychild ["x-nonsense","x-nonsense2"] {
		test_fail "exists test found non-existent header (3)";
	}
}

/*
 * Two headers - foreverypart
 */

test "Two headers - foreverypart" {
	foreverypart {
		if not exists :mime :anychild ["from","to"] {
			test_fail "exists test missed from or to header";
		}

		if exists :mime :anychild ["from","x-nonsense"] {
			test_fail "exists test found non-existent header (1)";
		}

		if exists :mime :anychild ["x-nonsense","to"] {
			test_fail "exists test found non-existent header (2)";
		}

		if exists :mime :anychild ["x-nonsense","x-nonsense2"] {
			test_fail "exists test found non-existent header (3)";
		}
	}
}

/*
 * Three headers
 */

test "Three headers" {
	if not exists :mime :anychild ["Subject","date","resent-to"] {
		test_fail "exists test missed subject, date or resent-to header";
	}

	if exists :mime :anychild ["x-nonsense","date","resent-to"] {
		test_fail "exists test found non-existent header (1)";
	}

	if exists :mime :anychild ["subject", "x-nonsense","resent-to"] {
		test_fail "exists test found non-existent header (2)";
	}

	if exists :mime :anychild ["subject","date","x-nonsense"] {
		test_fail "exists test found non-existent header (3)";
	}

	if exists :mime :anychild ["subject", "x-nonsense","x-nonsense2"] {
		test_fail "exists test found non-existent header (4)";
	}

	if exists :mime :anychild ["x-nonsense","date","x-nonsense2"] {
		test_fail "exists test found non-existent header (5)";
	}

	if exists :mime :anychild ["x-nonsense","x-nonsense2","resent-to"] {
		test_fail "exists test found non-existent header (6)";
	}

	if exists :mime :anychild ["x-nonsense","x-nonsense2","x-nonsense3"] {
		test_fail "exists test found non-existent header (7)";
	}
}

/*
 * Three headers - foreverypart
 */

test "Three headers - foreverypart " {
	foreverypart {
		if not exists :mime :anychild ["Subject","date","resent-to"] {
			test_fail "exists test missed subject, date or resent-to header";
		}

		if exists :mime :anychild ["x-nonsense","date","resent-to"] {
			test_fail "exists test found non-existent header (1)";
		}

		if exists :mime :anychild ["subject", "x-nonsense","resent-to"] {
			test_fail "exists test found non-existent header (2)";
		}

		if exists :mime :anychild ["subject","date","x-nonsense"] {
			test_fail "exists test found non-existent header (3)";
		}

		if exists :mime :anychild ["subject", "x-nonsense","x-nonsense2"] {
			test_fail "exists test found non-existent header (4)";
		}

		if exists :mime :anychild ["x-nonsense","date","x-nonsense2"] {
			test_fail "exists test found non-existent header (5)";
		}

		if exists :mime :anychild ["x-nonsense","x-nonsense2","resent-to"] {
			test_fail "exists test found non-existent header (6)";
		}

		if exists :mime :anychild ["x-nonsense","x-nonsense2","x-nonsense3"] {
			test_fail "exists test found non-existent header (7)";
		}
	}
}

/*
 * 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
X-Test1: AA

This is a multi-part message in MIME format.
--AA
Content-Type: multipart/mixed; boundary=BB
X-Test2: BB

This is a multi-part message in MIME format.
--BB
Content-Type: text/plain; charset="us-ascii"
X-Test3: CC

Hello

--BB
Content-Type: text/plain; charset="us-ascii"
X-Test4: DD

Hello again

--BB--
This is the end of MIME multipart.

--AA
Content-Type: text/plain; charset="us-ascii"
X-Test5: EE

And again

--AA--
This is the end of  MIME multipart.
.
;

test "Multipart anychild" {
	if not exists :mime :anychild "X-Test1" {
		test_fail "X-Test1 header does exist";
	}
	if not exists :mime :anychild "X-Test2" {
		test_fail "X-Test2 header does exist";
	}
	if not exists :mime :anychild "X-Test3" {
		test_fail "X-Test3 header does exist";
	}
	if not exists :mime :anychild "X-Test4" {
		test_fail "X-Test4 header does exist";
	}
	if not exists :mime :anychild "X-Test5" {
		test_fail "X-Test5 header does exist";
	}
	if not exists :mime :anychild
			["X-Test1", "X-Test2", "X-Test3", "X-Test4", "X-Test5"] {
		test_fail "Not all headers exist";
	}
}