File: message.svtest

package info (click to toggle)
dovecot 1:2.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 (180 lines) | stat: -rw-r--r-- 3,634 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
require "vnd.dovecot.testsuite";
require "vacation";
require "variables";
require "envelope";
require "body";

/*
 * References
 */

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

Frop
.
;

test "References" {
	vacation "I am not in today!";

	if not test_result_execute {
		test_fail "execution of result failed";
	}

	test_message :smtp 0;

	if not header :contains "references" "432df324@example.org" {
		test_fail "references header does not contain new id";
	}

	if anyof (
		not header :contains "references" "1234@local.machine.example",
		not header :contains "references" "3456@example.net",
		not header :contains "references" "435444@ttms.example.org",
		not header :contains "references" "4223@froop.example.net",
		not header :contains "references" "m345444444@message-id.exp"
		) {
		test_fail "references header does not contain all existing ids";
	}

	if header :contains "references" "hutsefluts" {
		test_fail "references header contains nonsense";
	}
}

/*
 * In-Reply-To
 */

test "In-Reply-To" {
	if not header :is "in-reply-to" "<432df324@example.org>" {
		test_fail "in-reply-to header set incorrectly";
	}
}

/*
 * Variables
 */

test_result_reset;

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

Frop
.
;

test "Variables" {
	set "message" "I am not in today!";
	set "subject" "Out of office";
	set "from" "user@example.com";

	vacation :from "${from}" :subject "${subject}" "${message}";

	if not test_result_execute {
		test_fail "execution of result failed";
	}

	test_message :smtp 0;

	if not header :contains "subject" "Out of office" {
		test_fail "subject not set properly";
	}

	if not header :contains "from" "user@example.com" {
		test_fail "from address not set properly";
	}

	if not body :contains :raw "I am not in today!" {
		test_fail "message not set properly";
	}
}

/*
 * NULL Sender
 */

test_result_reset;

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

Frop
.
;

test_set "envelope.to" "nico@frop.example.org";

test "NULL Sender" {
	set "message" "I am not in today!";
	set "subject" "Out of office";
	set "from" "user@example.com";

	vacation :from "${from}" :subject "${subject}" "${message}";

	if not test_result_execute {
		test_fail "execution of result failed";
	}

	test_message :smtp 0;

	if not envelope :is "from" "" {
		if envelope :matches "from" "*" {}
		test_fail "envelope sender not set properly: ${1}";
	}
}

/*
 * Send from recipient
 */

test_result_reset;

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

Frop
.
;

test_set "envelope.to" "nico@frop.example.org";

test_config_set "sieve_vacation_send_from_recipient" "yes";
test_config_reload :extension "vacation";

test "Send from recipient" {
	set "message" "I am not in today!";
	set "subject" "Out of office";
	set "from" "user@example.com";

	vacation :from "${from}" :subject "${subject}" "${message}";

	if not test_result_execute {
		test_fail "execution of result failed";
	}

	test_message :smtp 0;

	if not envelope "from" "nico@frop.example.org" {
		test_fail "envelope sender not set properly";
	}
}