summaryrefslogtreecommitdiffstats
path: root/pigeonhole/tests/extensions/vacation/utf-8.svtest
blob: e94f7b9b84ee1e11087c1613e9be5b92fd855f77 (plain)
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
require "vnd.dovecot.testsuite";
require "vacation";
require "variables";

test_set "message" text:
From: stephan@example.org
Subject: frop
References: <1234@local.machine.example> <3456@example.net>
 <435444@ttms.com> <4223@froop.example.net> <m345444444@message-id.exp>
Message-ID: <432df324@example.org>
To: nico@frop.example.org

Frop
.
;

test "UTF-8 Subject" {
	/* Trigger vacation response with rediculous Russian subject */
	vacation :subject "Auto: Я могу есть стекло, оно мне не вредит."
		"I am not in today";

	/* Execute Sieve result (sending message to dummy SMTP) */
	if not test_result_execute {
		test_fail "execution of result failed";
	}

	/* Retrieve message from dummy SMTP and set it as the active message under
	 * test.
	 */
	test_message :smtp 0;

	set "expected" "Auto: Я могу есть стекло, оно мне не вредит.";
	if not header :is "subject" "${expected}" {
		if header :matches "subject" "*" { set "subject" "${1}"; }

		test_fail text:
subject header is not encoded/decoded properly:
expected: ${expected}
decoded: ${subject}
.
;
	}
}

test_result_reset;

test_set "message" text:
From: stephan@example.org
Subject: frop
References: <1234@local.machine.example> <3456@example.net>
 <435444@ttms.com> <4223@froop.example.net> <m345444444@message-id.exp>
Message-ID: <432df324@example.org>
To: nico@frop.example.org

Frop
.
;


test "MIME Encoded Subject" {
	/* Trigger vacation response with rediculous Russian subject */
	vacation :subject "=?utf-8?b?w4TDlsOc?= sadasd"
		"I am not in today";

	/* Execute Sieve result (sending message to dummy SMTP) */
	if not test_result_execute {
		test_fail "execution of result failed";
	}

	/* Retrieve message from dummy SMTP and set it as the active message under
	 * test.
	 */
	test_message :smtp 0;

	set "expected" "ÄÖÜ sadasd";
	if not header :is "subject" "${expected}" {
		if header :matches "subject" "*" { set "subject" "${1}"; }

		test_fail text:
subject header is not encoded/decoded properly:
expected: ${expected}
decoded: ${subject}
.
;
	}
}

test_result_reset;

test_set "message" text:
From: stephan@example.org
Subject: frop
Message-ID: <432df324@example.org>
To: <g.m.karotte@example.com>

Frop
.
;


test "MIME Encoded From" {
	vacation :subject "Frop"
		:from "=?utf-8?q?G=C3=BCnther?= M. Karotte <g.m.karotte@example.com>"
		"I am not in today";

	/* Execute Sieve result (sending message to dummy SMTP) */
	if not test_result_execute {
		test_fail "execution of result failed";
	}

	/* Retrieve message from dummy SMTP and set it as the active message under
	 * test.
	 */
	test_message :smtp 0;

	set "expected" "Günther M. Karotte <g.m.karotte@example.com>";
	if not header :is "from" "${expected}" {
		if header :matches "from" "*" { set "decoded" "${1}"; }

		test_fail text:
from header is not encoded/decoded properly:
expected: ${expected}
decoded: ${decoded}
.
;
	}
}

test_result_reset;

test_set "message" text:
From: stephan@example.org
Subject: frop
Message-ID: <432df324@example.org>
To: <g.m.karotte@example.com>

Frop
.
;


test "MIME Encoded From - UTF-8 in phrase" {
	vacation :subject "Frop"
		:from "Günther M. Karotte <g.m.karotte@example.com>"
		"I am not in today";

	/* Execute Sieve result (sending message to dummy SMTP) */
	if not test_result_execute {
		test_fail "execution of result failed";
	}

	/* Retrieve message from dummy SMTP and set it as the active message under
	 * test.
	 */
	test_message :smtp 0;

	set "expected" "Günther M. Karotte <g.m.karotte@example.com>";
	if not header :is "from" "${expected}" {
		if header :matches "from" "*" { set "decoded" "${1}"; }

		test_fail text:
from header is not encoded/decoded properly:
expected: ${expected}
decoded: ${decoded}
.
;
	}
}