1require "vnd.dovecot.testsuite";
2require "envelope";
3
4/* Test message environment */
5
6test "Message Environment" {
7	test_set "message" text:
8From: sirius@example.org
9To: nico@frop.example.com
10Subject: Frop!
11
12Frop!
13.
14	;
15
16	if not header :contains "from" "example.org" {
17		test_fail "message data not set properly.";
18	}
19
20	test_set "message" text:
21From: nico@frop.example.com
22To: stephan@nl.example.com
23Subject: Friep!
24
25Friep!
26.
27	;
28
29	if not header :is "from" "nico@frop.example.com" {
30    	test_fail "message data not set properly.";
31	}
32
33	keep;
34}
35
36/* Test envelope environment */
37
38test "Envelope Environment" {
39	test_set "envelope.from" "stephan@hutsefluts.example.net";
40
41	if not envelope :is "from" "stephan@hutsefluts.example.net" {
42		test_fail "envelope.from data not set properly (1).";
43	}
44
45	test_set "envelope.to" "news@example.org";
46
47	if not envelope :is "to" "news@example.org" {
48		test_fail "envelope.to data not set properly (1).";
49	}
50
51	test_set "envelope.auth" "sirius";
52
53	if not envelope :is "auth" "sirius" {
54		test_fail "envelope.auth data not set properly (1).";
55	}
56
57	test_set "envelope.from" "stephan@example.org";
58
59	if not envelope :is "from" "stephan@example.org" {
60		test_fail "envelope.from data not reset properly (2).";
61	}
62
63	test_set "envelope.to" "past-news@example.org";
64
65	if not envelope :is "to" "past-news@example.org" {
66		test_fail "envelope.to data not reset properly (2).";
67	}
68
69	test_set "envelope.auth" "zilla";
70
71	if not envelope :is "auth" "zilla" {
72		test_fail "envelope.auth data not reset properly (2).";
73	}
74}
75
76