~ubuntu-branches/ubuntu/utopic/dovecot/utopic-proposed

« back to all changes in this revision

Viewing changes to pigeonhole/tests/plugins/extprograms/filter/execute.svtest

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-08 09:35:49 UTC
  • mfrom: (4.1.35 sid)
  • Revision ID: package-import@ubuntu.com-20140108093549-i72o93pux8p0dlaf
Tags: 1:2.2.9-1ubuntu1
* Merge from Debian unstable, remaining changes:
  + Add mail-stack-delivery package:
    - Update d/rules
    - d/control: convert existing dovecot-postfix package to a dummy
      package and add new mail-stack-delivery package.
    - Update maintainer scripts.
    - Rename d/dovecot-postfix.* to debian/mail-stack-delivery.*
    - d/mail-stack-delivery.preinst: Move previously installed backups and
      config files to a new package namespace.
    - d/mail-stack-delivery.prerm: Added to handle downgrades.
  + Use Snakeoil SSL certificates by default:
    - d/control: Depend on ssl-cert.
    - d/dovecot-core.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - d/dovecot-core.ufw.profile: new ufw profile.
    - d/rules: install profile in dovecot-core.
    - d/control: dovecot-core - suggest ufw.
  + d/dovecot-core.dirs: Added usr/share/doc/dovecot-core
  + Add apport hook:
    - d/rules, d/source_dovecot.py
  + Add upstart job:
    - d/rules, d/dovecot-core.dovecot.upstart, d/control,
      d/dovecot-core.dirs, dovecot-imapd.{postrm, postinst, prerm},
      d/dovecot-pop3d.{postinst, postrm, prerm}.
      d/mail-stack-deliver.postinst: Convert init script to upstart.
  + Use the autotools-dev dh addon to update config.guess/config.sub for
    arm64.
* Dropped changes, included in Debian:
  - Update Dovecot name to reflect distribution in login greeting.
  - Update Drac plugin for >= 2.0.0 support.
* d/control: Drop dovecot-postfix package as its no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require "vnd.dovecot.testsuite";
 
2
require "vnd.dovecot.filter";
 
3
require "vnd.dovecot.debug";
 
4
require "variables";
 
5
require "editheader";
 
6
require "body";
 
7
require "fileinto";
 
8
require "mailbox";
 
9
 
 
10
test_set "message" text:
 
11
From: stephan@example.com
 
12
To: pipe@example.net
 
13
Subject: Frop!
 
14
 
 
15
Frop!
 
16
.
 
17
;
 
18
 
 
19
test_config_set "sieve_filter_bin_dir" "${tst.path}/../bin";
 
20
test_config_reload :extension "vnd.dovecot.filter";
 
21
test_result_reset;
 
22
 
 
23
test_result_reset;
 
24
test "Replace" {
 
25
        if header :contains "subject" "replacement" {
 
26
                test_fail "message already replaced";
 
27
        }
 
28
 
 
29
        filter "replace";
 
30
 
 
31
        if not header :contains "subject" "replacement" {
 
32
                test_fail "message not replaced";
 
33
        }
 
34
}
 
35
 
 
36
test_result_reset;
 
37
test "Used as test" {
 
38
        if filter "nonsense" {
 
39
                test_fail "filter action indicated success with invalid program";
 
40
        }
 
41
 
 
42
        if not filter "replace" {
 
43
                test_fail "filter action indicated failure with valid program";
 
44
        }
 
45
 
 
46
        if not header :contains "subject" "replacement" {
 
47
                test_fail "message not replaced; filter not actually executed";
 
48
        }
 
49
}       
 
50
 
 
51
test_result_reset;
 
52
test "Modify" {
 
53
        if anyof (
 
54
                body :contains "extra",
 
55
                exists "x-frop") {
 
56
                test_fail "message already modified";
 
57
        }
 
58
 
 
59
        if not header "subject" "Frop!" {
 
60
                test_fail "message is wrong";
 
61
        }
 
62
 
 
63
        filter "modify";
 
64
 
 
65
        if not header "subject" "Frop!" {
 
66
                test_fail "message replaced erroneously";
 
67
        }
 
68
 
 
69
        if not header :contains "x-frop" "extra" {
 
70
                test_fail "message header not modified";
 
71
        }
 
72
 
 
73
        if not body :contains "Extra" {
 
74
                test_fail "message body not modified";
 
75
        }
 
76
}
 
77
 
 
78
test_result_reset;
 
79
test "Editheader" {
 
80
        if anyof ( exists "X-A", exists "X-B", exists "X-C", exists "X-D",
 
81
                exists "X-E") {
 
82
                test_fail "message already modified";
 
83
        }
 
84
 
 
85
        addheader "X-A" "1";
 
86
        if not header "X-A" "1" {
 
87
                test_fail "X-A header missing";
 
88
        }
 
89
 
 
90
        fileinto :create "A";
 
91
 
 
92
        filter "addheader" ["X-B", "2"];
 
93
        if not header "X-B" "2" {
 
94
                test_fail "X-B header missing";
 
95
        }
 
96
 
 
97
        fileinto :create "B";
 
98
 
 
99
        addheader "X-C" "3";
 
100
        if not header "X-C" "3" {
 
101
                test_fail "X-C header missing";
 
102
        }
 
103
 
 
104
        fileinto :create "C";
 
105
 
 
106
        filter "addheader" ["X-D", "4"];
 
107
        if not header "X-D" "4" {
 
108
                test_fail "X-D header missing";
 
109
        }
 
110
 
 
111
        fileinto :create "D";
 
112
 
 
113
        addheader "X-E" "5";
 
114
        if not header "X-E" "5" {
 
115
                test_fail "X-E header missing";
 
116
        }
 
117
 
 
118
        fileinto :create "E";
 
119
 
 
120
        if not test_result_execute {
 
121
                test_fail "failed to execute result";
 
122
        }
 
123
 
 
124
        test_message :folder "A" 0;
 
125
 
 
126
        if not header "X-A" "1" {
 
127
                test_fail "X-A header missing";
 
128
        }
 
129
        if anyof (
 
130
                header "X-B" "2", header "X-C" "3",
 
131
                header "X-D" "4", header "X-E" "5") {
 
132
                test_fail "X-B, X-C, X-D or X-E header found";
 
133
        }
 
134
 
 
135
        test_message :folder "B" 0;
 
136
 
 
137
        if not header "X-B" "2" {
 
138
                test_fail "X-B header missing";
 
139
        }
 
140
        if anyof (
 
141
                header "X-C" "3", header "X-D" "4", header "X-E" "5") {
 
142
                test_fail "X-C, X-D or X-E header found";
 
143
        }
 
144
 
 
145
        test_message :folder "C" 0;
 
146
 
 
147
        if not header "X-C" "3" {
 
148
                test_fail "X-C header missing";
 
149
        }
 
150
        if anyof (header "X-D" "4", header "X-E" "5") {
 
151
                test_fail "X-D or X-E header found";
 
152
        }
 
153
 
 
154
        test_message :folder "D" 0;
 
155
 
 
156
        if not header "X-D" "4" {
 
157
                test_fail "X-D header missing";
 
158
        }
 
159
        if anyof (header "X-E" "5") {
 
160
                test_fail "X-E header found";
 
161
        }
 
162
 
 
163
        test_message :folder "E" 0;
 
164
 
 
165
        if not header "X-A" "1" {
 
166
                test_fail "X-A header missing in final message";
 
167
        }
 
168
        if not header "X-B" "2" {
 
169
                test_fail "X-B header missing in final message";
 
170
        }
 
171
        if not header "X-C" "3" {
 
172
                test_fail "X-C header missing in final message";
 
173
        }
 
174
        if not header "X-D" "4" {
 
175
                test_fail "X-D header missing in final message";
 
176
        }
 
177
        if not header "X-E" "5" {
 
178
                test_fail "X-E header missing in final message";
 
179
        }
 
180
}