File: smtp.svtest

package info (click to toggle)
dovecot 1%3A2.2.27-3%2Bdeb9u5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 48,792 kB
  • sloc: ansic: 430,517; sh: 17,438; makefile: 6,587; cpp: 1,557; perl: 295; python: 67; xml: 44; pascal: 27
file content (240 lines) | stat: -rw-r--r-- 5,344 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
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
require "vnd.dovecot.testsuite";
require "envelope";

test_set "message" text:
From: stephan@example.org
To: tss@example.net
Subject: Frop!

Frop!
.
;

test_set "envelope.from" "sirius@example.org";
test_set "envelope.to" "timo@example.net";

test "Redirect" {
	redirect "cras@example.net";

	if not test_result_execute {
		test_fail "failed to execute redirect";
	}

	test_message :smtp 0;

	if not address :is "to" "tss@example.net" {
		test_fail "to address incorrect (strange forward)";
	}

	if not address :is "from" "stephan@example.org" {
		test_fail "from address incorrect (strange forward)";
	}

	if not envelope :is "to" "cras@example.net" {
		test_fail "envelope recipient incorrect";
	}

	if not envelope :is "from" "sirius@example.org" {
		test_fail "envelope sender incorrect";
	}
}

test_result_reset;
test_set "envelope.from" "<>";

test "Redirect from <>" {
	redirect "cras@example.net";

	if not test_result_execute {
		test_fail "failed to execute redirect";
	}

	test_message :smtp 0;

	if envelope :is "from" "sirius@example.org" {
		test_fail "envelope sender incorrect (not changed)";
	}

	if not envelope :is "from" "" {
		test_fail "envelope sender incorrect";
	}
}

test_result_reset;
test_set "envelope.from" "sirius@example.org";
test_set "envelope.to" "timo@example.net";

test_config_set "sieve_redirect_envelope_from" " recipient ";
test_config_reload;

test "Redirect from [recipient]" {
	redirect "cras@example.net";

	if not test_result_execute {
		test_fail "failed to execute redirect";
	}

	test_message :smtp 0;

	if envelope :is "from" "sirius@example.org" {
		test_fail "envelope sender incorrect (not changed)";
	}

	if not envelope :is "from" "timo@example.net" {
		test_fail "envelope sender incorrect";
	}
}

test_result_reset;
test_set "envelope.from" "sirius@example.org";
test_set "envelope.to" "timo@example.net";
test_set "envelope.orig_to" "tss@example.net";

test_config_set "sieve_redirect_envelope_from" "orig_recipient ";
test_config_reload;

test "Redirect from [original recipient]" {
	redirect "cras@example.net";

	if not test_result_execute {
		test_fail "failed to execute redirect";
	}

	test_message :smtp 0;

	if envelope :is "from" "sirius@example.org" {
		test_fail "envelope sender incorrect (not changed)";
	}

	if not envelope :is "from" "tss@example.net" {
		test_fail "envelope sender incorrect";
	}
}


test_result_reset;
test_set "envelope.from" "sirius@example.org";
test_set "envelope.to" "timo@example.net";
test_set "envelope.orig_to" "tss@example.net";

test_config_set "sieve_redirect_envelope_from" "< backscatter@example.net> ";
test_config_reload;

test "Redirect from [<explicit>]" {
	redirect "cras@example.net";

	if not test_result_execute {
		test_fail "failed to execute redirect";
	}

	test_message :smtp 0;

	if envelope :is "from" "sirius@example.org" {
		test_fail "envelope sender incorrect (not changed)";
	}

	if not envelope :is "from" "backscatter@example.net" {
		test_fail "envelope sender incorrect";
	}
}

test_result_reset;
test_set "envelope.from" "sirius@example.org";
test_set "envelope.to" "timo@example.net";

test_config_set "sieve_redirect_envelope_from" "<>";
test_config_reload;

test "Redirect from [<>]" {
	redirect "cras@example.net";

	if not test_result_execute {
		test_fail "failed to execute redirect";
	}

	test_message :smtp 0;

	if envelope :is "from" "sirius@example.org" {
		test_fail "envelope sender incorrect (not changed)";
	}

	if not envelope :is "from" "" {
		test_fail "envelope sender incorrect";
	}
}

test_result_reset;
test_set "envelope.from" "<>";
test_set "envelope.to" "timo@example.net";
test_set "envelope.orig_to" "tss@example.net";

test_config_set "sieve_redirect_envelope_from" "<backscatter@example.net>";
test_config_reload;

test "Redirect from <> with [<explicit>]" {
	redirect "cras@example.net";

	if not test_result_execute {
		test_fail "failed to execute redirect";
	}

	test_message :smtp 0;

	if envelope :is "from" "backscatter@example.net" {
		test_fail "envelope sender incorrect (erroneously changed)";
	}

	if not envelope :is "from" "" {
		test_fail "envelope sender incorrect";
	}
}

test_result_reset;
test_set "envelope.from" "sirius@example.org";
test_set "envelope.to" "timo@example.net";
test_set "envelope.orig_to" "tss@example.net";

test_config_set "sieve_redirect_envelope_from" "user_email";
test_config_reload;

test "Redirect from [user email - fallback default]" {
	redirect "cras@example.net";

	if not test_result_execute {
		test_fail "failed to execute redirect";
	}

	test_message :smtp 0;

	if not envelope :is "from" "timo@example.net" {
		test_fail "envelope sender incorrect";
	}
}

test_result_reset;
test_set "envelope.from" "sirius@example.org";
test_set "envelope.to" "timo@example.net";
test_set "envelope.orig_to" "tss@example.net";

test_config_set "sieve_redirect_envelope_from" "user_email";
test_config_set "sieve_user_email" "t.sirainen@example.net";
test_config_reload;

test "Redirect from [user email]" {
	redirect "cras@example.net";

	if not test_result_execute {
		test_fail "failed to execute redirect";
	}

	test_message :smtp 0;

	if envelope :is "from" "sirius@example.org" {
		test_fail "envelope sender incorrect (not changed)";
	}

	if not envelope :is "from" "t.sirainen@example.net" {
		test_fail "envelope sender incorrect";
	}
}