File: execute.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 (104 lines) | stat: -rw-r--r-- 2,447 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
require "vnd.dovecot.testsuite";
require "vnd.dovecot.execute";
require "vnd.dovecot.debug";
require "variables";
require "relational";
require "environment";

test_set "message" text:
From: stephan@example.com
To: pipe@example.net
Subject: Frop!

Frop!
.
;

test_config_set "sieve_execute_bin_dir" "${tst.path}/../bin";
test_config_reload :extension "vnd.dovecot.execute";
test_result_reset;

test "Execute - bare" {
	execute "program";
}

test_result_reset;
test "Execute - i/o" {
	execute :input "FROP" :output "out" "frame";

	if not string "${out}" "FRAMED { FROP }" {
		test_fail "wrong string returned: ${out}";
	}
}

test_result_reset;
test "Execute - i/o and arguments" {
	execute :input "FROP" :output "out" "frame" ["FRIEP "];

	if not string "${out}" "FRAMED FRIEP { FROP }" {
		test_fail "wrong string returned: ${out}";
	}
}

test_result_reset;
test "Execute - pipe" {
	execute :pipe :output "msg" "cat";

	if not string :contains "${msg}" "Subject: Frop!" {
		test_fail "wrong string returned: ${out}";
	}
}

test_result_reset;
test "Execute - env" {
	test_set "envelope.from" "stephan@sub.example.com";
	test_set "envelope.to" "stephan@sub.example.net";
	test_set "envelope.orig_to" "all@sub.example.net";

	execute :output "out" "env" "SENDER";
	if not string :is "${out}" "stephan@sub.example.com" {
		test_fail "wrong SENDER env returned: '${out}'";
	}

	execute :output "out" "env" "RECIPIENT";
	if not string :is "${out}" "stephan@sub.example.net" {
		test_fail "wrong RECIPIENT env returned: '${out}'";
	}

	execute :output "out" "env" "ORIG_RECIPIENT";
	if not string :is "${out}" "all@sub.example.net" {
		test_fail "wrong ORIG_RECIPIENT env returned: '${out}'";
	}

	execute :output "out" "env" "HOST";
	if not environment :is "host" "${out}" {
		test_fail "wrong HOST env returned: '${out}'";
	}

	execute :output "out" "env" "HOME";
	if string :count "eq" "${out}" "0" {
		test_fail "empty HOME env returned";
	}

	execute :output "out" "env" "USER";
	if string :count "eq" "${out}" "0" {
		test_fail "empty USER env returned";
	}
}

test_result_reset;
test "Execute - used as test" {
	if execute :pipe :output "msg" "dog" {
		test_fail "execute action indicated success with invalid program";
	}

	if not execute :pipe :output "msg" "cat" {
		test_fail "execute action indicated failure with valid program";
	}

	if not string :contains "${msg}" "Subject: Frop!" {
		test_fail "wrong string returned: ${out}";
	}
}