File: errors.svtest

package info (click to toggle)
dovecot 1%3A2.2.13-12~deb8u4
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 38,792 kB
  • sloc: ansic: 341,472; sh: 16,920; makefile: 5,393; cpp: 1,474; perl: 265; xml: 44; python: 34; pascal: 27
file content (167 lines) | stat: -rw-r--r-- 3,799 bytes parent folder | download | duplicates (3)
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
require "vnd.dovecot.testsuite";
require "comparator-i;ascii-numeric";
require "relational";

require "editheader";

test "Invalid field-name" {
	if test_script_compile "errors/field-name.sieve" {
		test_fail "compile should have failed";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "5" {
		test_fail "wrong number of errors reported";
	}

	if not test_error :index 1 :matches "*field name*X-field:*invalid*" {
		test_fail "wrong error reported (1)";
	}

	if not test_error :index 2 :matches "*field name*X field*invalid*" {
		test_fail "wrong error reported (2)";
	}

	if not test_error :index 3 :matches "*field name*X-field:*invalid*" {
		test_fail "wrong error reported (3)";
	}

	if not test_error :index 4 :matches "*field name*X field*invalid*" {
		test_fail "wrong error reported (4)";
	}
}

test "Invalid field-name at runtime " {
	if not test_script_compile "errors/field-name-runtime.sieve" {
		test_fail "compile failed";
	}

	if test_script_run {
		test_fail "run should have failed";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "1" {
		test_fail "wrong number of errors reported";
	}

	if not test_error :matches "*field name*X-field:*invalid*" {
		test_fail "wrong error reported";
	}
}

test "Invalid field value" {
	if test_script_compile "errors/field-value.sieve" {
		test_fail "compile should have failed";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "3" {
		test_fail "wrong number of errors reported";
	}

	if not test_error :index 1 :matches "*value*Yeah!?*invalid*" {
		test_fail "wrong error reported (1)";
	}

	if not test_error :index 2 :matches "*value*Woah!*invalid*" {
		test_fail "wrong error reported (2)";
	}
}

test "Command syntax (FIXME: count only)" {
	if test_script_compile "errors/command-syntax.sieve" {
		test_fail "compile should have failed";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "10" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * TEST - Size limit
 */

test "Size limit" {
	if not test_script_compile "errors/size-limit.sieve" {
		test_fail "compile should have succeeded";
	}

	test_config_set "sieve_editheader_max_header_size" "1024";
	test_config_reload :extension "editheader";

	if test_script_compile "errors/size-limit.sieve" {
		test_fail "compile should have failed";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "2" {
		test_fail "wrong number of errors reported";
	}
}


/*
 * TEST - Size limit at runtime
 */

test_config_set "sieve_editheader_max_header_size" "";
test_config_reload :extension "editheader";

test "Size limit at runtime" {
	if not test_script_compile "errors/size-limit-runtime.sieve" {
		test_fail "compile should have succeeded";
	}

	if not test_script_run {
		test_fail "run failed";
	}

	test_config_set "sieve_editheader_max_header_size" "1024";
	test_config_reload :extension "editheader";

	if not test_script_compile "errors/size-limit-runtime.sieve" {
		test_fail "compile should have succeeded";
	}

	if test_script_run {
		test_fail "run should have failed";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "1" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * TEST - Implicit keep at runtime error
 */

test_set "message" text:
From: stephan@example.com
To: tss@example.com
Subject: Frop

Frop!
.
;

test "Implicit keep at runtime error" {
	if not test_script_compile "errors/runtime-error.sieve" {
		test_fail "compile failed";
	}

	if not test_script_run {
		test_fail "run failed";
	}

	if test_result_execute {
		test_fail "result execution should have failed";
	}

	if not test_message :folder "INBOX" 0 {
		test_fail "message not stored (no implicit keep)";
	}

	if exists "X-Frop" {
		test_fail "implicit keep message has editheader changes";
	}
}