relational.at
3.47 KB
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
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2007-2012, 2014-2015 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef([MUT_SIEVE_MAILBOX],[relational.mbox])
m4_pushdef([MUT_SIEVE_OPTIONS],[--set ":mailbox:folder=`pwd`" dnl
--set ":mailbox:mailbox-pattern=`pwd`/"'${user}'])
MUT_TESTCASE([relational address],[test relational address comparator i-ascii-numeric],
[
require [["relational", "comparator-i;ascii-numeric"]];
if address :count "ge" :comparator "i;ascii-numeric" [["to", "cc"] ["3"]]
{
discard;
}
],[],[0],[],
[DISCARD on msg uid 1: marking as deleted
IMPLICIT KEEP on msg uid 2
IMPLICIT KEEP on msg uid 3
IMPLICIT KEEP on msg uid 4
IMPLICIT KEEP on msg uid 5
IMPLICIT KEEP on msg uid 6
IMPLICIT KEEP on msg uid 7
IMPLICIT KEEP on msg uid 8
DISCARD on msg uid 9: marking as deleted
])
MUT_TESTCASE([relational header],[test relational header comparator i-ascii-numeric],
[
require [["relational", "comparator-i;ascii-numeric"]];
if header :count "gt" [["received"]] [["2"]]
{
discard;
}
],[],[0],[],
[IMPLICIT KEEP on msg uid 1
IMPLICIT KEEP on msg uid 2
IMPLICIT KEEP on msg uid 3
IMPLICIT KEEP on msg uid 4
IMPLICIT KEEP on msg uid 5
IMPLICIT KEEP on msg uid 6
IMPLICIT KEEP on msg uid 7
IMPLICIT KEEP on msg uid 8
DISCARD on msg uid 9: marking as deleted
])
m4_pushdef([FILEEXISTS],[test -f "$1" || echo "$1 missing"])
MUT_TESTCASE([relational big test],[test relational relational-hairy],
[
require [["relational", "comparator-i;ascii-numeric", "fileinto"]];
if header :value "lt" :comparator "i;ascii-numeric" [["x-priority"]] [["3"]]
{
fileinto "%Priority";
}
elsif address :count "gt" :comparator "i;ascii-numeric" [["to"]] [["5"]]
{
# everything with more than 5 recipients in the "to" field
# is considered SPAM
fileinto "%SPAM";
}
elsif address :value "gt" :all :comparator "i;ascii-casemap" [["from"]] [["M"]]
{
fileinto "%From_N-Z";
}
else
{
fileinto "%From_A-M";
}
if allof (address :count "eq" :comparator "i;ascii-numeric"
[["to", "cc"]] [["1"]] ,
address :all :comparator "i;ascii-casemap"
[["to", "cc"]] [["me@foo.example.com.invalid"]])
{
fileinto "%Only_me";
}
],
[
FILEEXISTS([From_A-M])
FILEEXISTS([From_N-Z])
FILEEXISTS([Priority])
FILEEXISTS([Only_me])
FILEEXISTS([SPAM])
],[0],[],
[FILEINTO on msg uid 1: delivering into %From_A-M
FILEINTO on msg uid 2: delivering into %From_N-Z
FILEINTO on msg uid 3: delivering into %Priority
FILEINTO on msg uid 4: delivering into %Priority
FILEINTO on msg uid 5: delivering into %Priority
FILEINTO on msg uid 6: delivering into %From_A-M
FILEINTO on msg uid 7: delivering into %From_A-M
FILEINTO on msg uid 8: delivering into %From_A-M
FILEINTO on msg uid 8: delivering into %Only_me
FILEINTO on msg uid 9: delivering into %SPAM
])
m4_popdef([FILEEXISTS])
m4_popdef([MUT_SIEVE_MAILBOX])
m4_popdef([MUT_SIEVE_OPTIONS])