",
78 | header :matches "Subject" [ "*Closure*", "*closure*" ]
79 | )
80 | {
81 | keep;
82 | stop;
83 | }
84 | '''
85 | self.assertFalse(checksieve.parse_string(sieve, False))
86 |
87 | def test_empty_block(self):
88 | sieve = '''
89 | if header :matches "Subject" "NOT A VIRUS" {
90 |
91 | }
92 | '''
93 | self.assertFalse(checksieve.parse_string(sieve, False))
94 |
95 |
96 | if __name__ == '__main__':
97 | unittest.main()
98 |
--------------------------------------------------------------------------------
/test/3028/misc_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestMiscellany(unittest.TestCase):
5 |
6 | def test_fileinto_no_require(self):
7 | sieve = 'fileinto "Inbox";'
8 | self.assertTrue(checksieve.parse_string(sieve, True))
9 |
10 | def test_fileinto(self):
11 | sieve = '''
12 | require "fileinto";
13 | fileinto "Inbox";'''
14 | self.assertFalse(checksieve.parse_string(sieve, False))
15 |
16 | def test_unnecessary_semicolon(self):
17 | sieve = 'if header :matches "Subject" "*" { keep; stop; };'
18 | self.assertTrue(checksieve.parse_string(sieve, True))
19 |
20 | def test_multiline_string(self):
21 | sieve = '''
22 | require "fileinto";
23 | fileinto text:
24 | Inbox
25 | .
26 | ;'''
27 | self.assertFalse(checksieve.parse_string(sieve, False))
28 |
29 | def test_multiline_string_with_comment(self):
30 | sieve = '''
31 | require "fileinto";
32 | fileinto text: #inline comment
33 | Inbox
34 | .
35 | ;'''
36 | self.assertFalse(checksieve.parse_string(sieve, False))
37 |
38 | def test_multiple_requires(self):
39 | sieve = '''
40 | require "fileinto";
41 | require "copy";
42 |
43 | if header :matches "Subject" "*" {
44 | fileinto :copy "All Mail";
45 | }
46 |
47 | keep;
48 | stop;
49 | '''
50 | self.assertFalse(checksieve.parse_string(sieve, False))
51 |
52 | def test_stop_too_many_args(self):
53 | sieve = '''
54 | stop "foo";
55 | '''
56 | self.assertTrue(checksieve.parse_string(sieve, True))
57 |
58 | if __name__ == '__main__':
59 | unittest.main()
60 |
--------------------------------------------------------------------------------
/test/3028/strings_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestStrings(unittest.TestCase):
5 |
6 | def test_multiline_strings(self):
7 | sieve = '''
8 | require "vacation";
9 | vacation :mime
10 | "Content-Type: multipart/alternative; boundary=foo
11 |
12 | --foo
13 |
14 | I'm at the beach relaxing. Mmmm, surf...
15 |
16 | --foo
17 | Content-Type: text/html; charset=us-ascii
18 |
19 |
21 | How to relax
22 |
23 | I'm at the beach relaxing.
24 | Mmmm, surf...
25 |
26 |
27 | --foo--
28 | ";
29 | '''
30 | self.assertFalse(checksieve.parse_string(sieve, False))
31 |
32 | if __name__ == '__main__':
33 | unittest.main()
34 |
--------------------------------------------------------------------------------
/test/3894/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/3894/__init__.py
--------------------------------------------------------------------------------
/test/3894/basic_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestBasic(unittest.TestCase):
5 |
6 | def test_copy_fileinto (self):
7 | sieve = '''
8 | require ["copy", "fileinto"];
9 |
10 | if header :matches "Subject" "*" {
11 | fileinto :copy "All Mail";
12 | }
13 |
14 | keep;
15 | stop;
16 | '''
17 | self.assertFalse(checksieve.parse_string(sieve, False))
18 |
19 | def test_copy_redirect (self):
20 | sieve = '''
21 | require ["copy"];
22 |
23 | if header :matches "Subject" "*" {
24 | redirect :copy "foo@example.com";
25 | }
26 |
27 | keep;
28 | stop;
29 | '''
30 | self.assertFalse(checksieve.parse_string(sieve, False))
31 |
32 | def test_copy_no_require (self):
33 | sieve = '''
34 | require ["fileinto"];
35 |
36 | if header :matches "Subject" "*" {
37 | fileinto :copy "All Mail";
38 | }
39 |
40 | keep;
41 | stop;
42 | '''
43 | self.assertTrue(checksieve.parse_string(sieve, True))
44 |
45 | if __name__ == '__main__':
46 | unittest.main()
--------------------------------------------------------------------------------
/test/5173/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5173/__init__.py
--------------------------------------------------------------------------------
/test/5173/body_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestBody(unittest.TestCase):
5 |
6 | def test_body(self):
7 | sieve = '''
8 | require ["body"];
9 |
10 | if body :raw :contains "MAKE MONEY FAST" {
11 | discard;
12 | }
13 | '''
14 | self.assertFalse(checksieve.parse_string(sieve, False))
15 |
16 | def test_body_no_require(self):
17 | sieve = '''
18 | if body :raw :contains "MAKE MONEY FAST" {
19 | discard;
20 | }
21 | '''
22 | self.assertTrue(checksieve.parse_string(sieve, True))
23 |
24 | if __name__ == '__main__':
25 | unittest.main()
26 |
--------------------------------------------------------------------------------
/test/5173/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestExamples(unittest.TestCase):
5 |
6 | def test_example_1(self):
7 | sieve = '''
8 | require ["body", "fileinto"];
9 |
10 | # Save any message with any text MIME part that contains the
11 | # words "missile" or "coordinates" in the "secrets" folder.
12 |
13 | if body :content "text" :contains ["missile", "coordinates"] {
14 | fileinto "secrets";
15 | }
16 |
17 | # Save any message with an audio/mp3 MIME part in
18 | # the "jukebox" folder.
19 |
20 | if body :content "audio/mp3" :contains "" {
21 | fileinto "jukebox";
22 | }
23 | '''
24 | self.assertFalse(checksieve.parse_string(sieve, False))
25 |
26 | if __name__ == '__main__':
27 | unittest.main()
28 |
--------------------------------------------------------------------------------
/test/5183/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5183/__init__.py
--------------------------------------------------------------------------------
/test/5183/environment_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestEnvironment(unittest.TestCase):
5 |
6 | def test_environment_name(self):
7 | sieve = '''
8 | require ["environment"];
9 |
10 | if environment :is "name" "check-sieve" {
11 | discard;
12 | }
13 | '''
14 | self.assertFalse(checksieve.parse_string(sieve, False))
15 |
16 | def test_environment_domain(self):
17 | sieve = '''
18 | require ["environment"];
19 |
20 | if environment :is "domain" ["google.com", "icloud.com"] {
21 | discard;
22 | }
23 | '''
24 | self.assertFalse(checksieve.parse_string(sieve, False))
25 |
26 | def test_environment_host(self):
27 | sieve = '''
28 | require ["environment"];
29 |
30 | if environment :is "host" "moo" {
31 | discard;
32 | }
33 | '''
34 | self.assertFalse(checksieve.parse_string(sieve, False))
35 |
36 | def test_environment_location(self):
37 | sieve = '''
38 | require ["environment"];
39 |
40 | if environment :is "location" "foo" {
41 | discard;
42 | }
43 | '''
44 | self.assertFalse(checksieve.parse_string(sieve, False))
45 |
46 | def test_environment_phase(self):
47 | sieve = '''
48 | require ["environment"];
49 |
50 | if environment :is "phase" "1" {
51 | discard;
52 | }
53 | '''
54 | self.assertFalse(checksieve.parse_string(sieve, False))
55 |
56 | def test_environment_remote_host(self):
57 | sieve = '''
58 | require ["environment"];
59 |
60 | if environment :is "remote-host" "moo" {
61 | discard;
62 | }
63 | '''
64 | self.assertFalse(checksieve.parse_string(sieve, False))
65 |
66 | def test_environment_remote_ip(self):
67 | sieve = '''
68 | require ["environment"];
69 |
70 | if environment :is "remote-ip" "127.0.0.1" {
71 | discard;
72 | }
73 | '''
74 | self.assertFalse(checksieve.parse_string(sieve, False))
75 |
76 | def test_environment_version(self):
77 | sieve = '''
78 | require ["environment"];
79 |
80 | if environment :is "version" "1.2" {
81 | discard;
82 | }
83 | '''
84 | self.assertFalse(checksieve.parse_string(sieve, False))
85 |
86 | def test_environment_bogus(self):
87 | sieve = '''
88 | require ["environment"];
89 |
90 | if environment :is "bogus" "check-sieve" {
91 | discard;
92 | }
93 | '''
94 | self.assertTrue(checksieve.parse_string(sieve, True))
95 |
96 | if __name__ == '__main__':
97 | unittest.main()
98 |
--------------------------------------------------------------------------------
/test/5228/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5228/__init__.py
--------------------------------------------------------------------------------
/test/5228/commands_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestCommands(unittest.TestCase):
5 |
6 | def test_discard(self):
7 | sieve = '''
8 | discard;
9 | '''
10 | self.assertFalse(checksieve.parse_string(sieve, False))
11 |
12 | def test_discard_extra_arg(self):
13 | sieve = '''
14 | discard "foo";
15 | '''
16 | self.assertTrue(checksieve.parse_string(sieve, True))
17 |
18 | def test_redirect(self):
19 | sieve = '''
20 | redirect "foo@example.org";
21 | '''
22 | self.assertFalse(checksieve.parse_string(sieve, False))
23 |
24 | def test_redirect_no_args(self):
25 | sieve = '''
26 | redirect;
27 | '''
28 | self.assertTrue(checksieve.parse_string(sieve, True))
29 |
30 | def test_multiple_is(self):
31 | sieve = '''
32 | if header :is "X-Phabricator-Mail-Tags" :is ""
33 | {
34 | discard;
35 | stop;
36 | }
37 | '''
38 | self.assertTrue(checksieve.parse_string(sieve, True))
39 |
40 | def test_single_test_parens_01(self):
41 | sieve = '''
42 | if anyof (not exists ["From", "Date"]) {
43 | discard;
44 | }
45 | '''
46 | self.assertFalse(checksieve.parse_string(sieve, False))
47 |
48 | def test_single_test_parens_02(self):
49 | sieve = '''
50 | if (address :is true) {
51 | discard;
52 | }
53 | '''
54 | self.assertFalse(checksieve.parse_string(sieve, False))
55 |
56 | def test_single_test_parens_03(self):
57 | sieve = '''
58 | if anyof (not true) {
59 | keep;
60 | } else {
61 | discard;
62 | }
63 | '''
64 | self.assertFalse(checksieve.parse_string(sieve, False))
65 |
66 | if __name__ == '__main__':
67 | unittest.main()
68 |
--------------------------------------------------------------------------------
/test/5228/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestExamples(unittest.TestCase):
5 |
6 | def test_extended_example(self):
7 | sieve = '''
8 | #
9 | # Example Sieve Filter
10 | # Declare any optional features or extension used by the script
11 | #
12 | require ["fileinto"];
13 |
14 | #
15 | # Handle messages from known mailing lists
16 | # Move messages from IETF filter discussion list to filter mailbox
17 | #
18 | if header :is "Sender" "owner-ietf-mta-filters@imc.org"
19 | {
20 | fileinto "filter"; # move to "filter" mailbox
21 | }
22 | #
23 | # Keep all messages to or from people in my company
24 | #
25 | elsif address :DOMAIN :is ["From", "To"] "example.com"
26 | {
27 | keep; # keep in "In" mailbox
28 | }
29 |
30 | #
31 | # Try and catch unsolicited email. If a message is not to me,
32 | # or it contains a subject known to be spam, file it away.
33 | #
34 | elsif anyof (not address :all :contains
35 | ["To", "Cc", "Bcc"] "me@example.com",
36 | header :matches "subject"
37 | ["*make*money*fast*", "*university*dipl*mas*"])
38 | {
39 | fileinto "spam"; # move to "spam" mailbox
40 | }
41 | else
42 | {
43 | # Move all other (non-company) mail to "personal"
44 | # mailbox.
45 | fileinto "personal";
46 | }
47 | '''
48 | self.assertFalse(checksieve.parse_string(sieve, False))
49 |
50 | def test_match_variables(self):
51 | sieve = '''
52 | require ["fileinto", "variables"];
53 |
54 | if header :matches "List-ID" "*<*@*" {
55 | fileinto "INBOX.lists.${2}"; stop;
56 | }
57 |
58 | # Imagine the header
59 | # Subject: [acme-users] [fwd] version 1.0 is out
60 | if header :matches "Subject" "[*] *" {
61 | # ${1} will hold "acme-users",
62 | # ${2} will hold "[fwd] version 1.0 is out"
63 | fileinto "INBOX.lists.${1}"; stop;
64 | }
65 |
66 | # Imagine the header
67 | # To: coyote@ACME.Example.COM
68 | if address :matches ["To", "Cc"] ["coyote@**.com",
69 | "wile@**.com"] {
70 | # ${0} is the matching address
71 | # ${1} is always the empty string
72 | # ${2} is part of the domain name ("ACME.Example")
73 | fileinto "INBOX.business.${2}"; stop;
74 | } else {
75 | # Control wouldn't reach this block if any match was
76 | # successful, so no match variables are set at this
77 | # point.
78 | }
79 |
80 | if anyof (true, address :domain :matches "To" "*.com") {
81 | # The second test is never evaluated, so there are
82 | # still no match variables set.
83 | stop;
84 | }
85 | '''
86 | self.assertFalse(checksieve.parse_string(sieve, False))
87 |
88 | if __name__ == '__main__':
89 | unittest.main()
--------------------------------------------------------------------------------
/test/5228/semicolon_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class SemiColonTest(unittest.TestCase):
5 |
6 | def test_dangling_semicolon(self):
7 | sieve = '''
8 | require ["fileinto"];
9 | if header :matches "Subject" "*Some Subject:*" { ; fileinto "Folder"; stop; }
10 | '''
11 | self.assertTrue(checksieve.parse_string(sieve, True))
12 |
13 | if __name__ == '__main__':
14 | unittest.main()
--------------------------------------------------------------------------------
/test/5228/tests_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestForTestList(unittest.TestCase):
5 |
6 | def test_not_01(self):
7 | sieve = '''
8 | if not (address :is "Foo") {
9 | discard;
10 | }
11 | '''
12 | self.assertTrue(checksieve.parse_string(sieve, True))
13 |
14 | if __name__ == '__main__':
15 | unittest.main()
--------------------------------------------------------------------------------
/test/5229/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5229/__init__.py
--------------------------------------------------------------------------------
/test/5229/tests_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestTests(unittest.TestCase):
5 |
6 | def test_string(self):
7 | sieve = '''
8 | require ["variables"];
9 | if string :matches " ${state} " "* pending *" {
10 | # the above test always succeeds
11 | }
12 | '''
13 | self.assertFalse(checksieve.parse_string(sieve, False))
14 |
15 | def test_string_no_require(self):
16 | sieve = '''
17 | if string :matches " ${state} " "* pending *" {
18 | # the above test always succeeds
19 | }
20 | '''
21 | self.assertTrue(checksieve.parse_string(sieve, True))
22 |
23 |
24 | if __name__ == '__main__':
25 | unittest.main()
--------------------------------------------------------------------------------
/test/5229/variables_test.py:
--------------------------------------------------------------------------------
1 | from sys import platform
2 |
3 | import unittest
4 | import checksieve
5 |
6 | class TestVariables(unittest.TestCase):
7 |
8 | def test_set(self):
9 | sieve = '''
10 | require "variables";
11 | set "honorific" "Mr";
12 | '''
13 | self.assertFalse(checksieve.parse_string(sieve, False))
14 |
15 | def test_mod_length(self):
16 | sieve = '''
17 | require "variables";
18 | set :length "b" "${a}";
19 | '''
20 | self.assertFalse(checksieve.parse_string(sieve, False))
21 |
22 | def test_wrong_tag(self):
23 | sieve = '''
24 | require "variables";
25 | set :mime "b" "c";
26 | '''
27 | self.assertTrue(checksieve.parse_string(sieve, True))
28 |
29 | def test_set_wrong_arg(self):
30 | sieve = '''
31 | require "variables";
32 | set "a" "b" "c";
33 | '''
34 | self.assertTrue(checksieve.parse_string(sieve, True))
35 |
36 | def test_too_many_args(self):
37 | sieve = '''
38 | require "variables";
39 | set "a" "b" "c" "d";
40 | '''
41 | self.assertTrue(checksieve.parse_string(sieve, True))
42 |
43 | def test_test_string(self):
44 | sieve = '''
45 | require "variables";
46 | set "state" "${state} pending";
47 | if string :matches " ${state} " "* pending *" {
48 | # the above test always succeeds
49 | stop;
50 | }
51 | '''
52 | self.assertFalse(checksieve.parse_string(sieve, False))
53 |
54 | def test_numeral_varname(self):
55 | sieve = '''
56 | require "variables";
57 | set "1" "${state} pending";
58 | '''
59 | self.assertFalse(checksieve.parse_string(sieve, False))
60 |
61 | def test_bad_varname(self):
62 | sieve = '''
63 | require "variables";
64 | set "bad-variable" "no dashes allowed!";
65 | '''
66 | self.assertTrue(checksieve.parse_string(sieve, True))
67 |
68 |
69 | if __name__ == '__main__':
70 | unittest.main()
71 |
--------------------------------------------------------------------------------
/test/5230/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5230/__init__.py
--------------------------------------------------------------------------------
/test/5230/commands_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestCommands(unittest.TestCase):
5 |
6 | def test_vacation_no_args(self):
7 | sieve = '''
8 | require "vacation";
9 | vacation;
10 | '''
11 | self.assertTrue(checksieve.parse_string(sieve, True))
12 |
13 | def test_vacation_bad_tag(self):
14 | sieve = '''
15 | require ["vacation", "copy"];
16 | vacation :copy "I'm out";
17 | '''
18 | self.assertTrue(checksieve.parse_string(sieve, True))
19 |
20 |
21 | if __name__ == '__main__':
22 | unittest.main()
23 |
--------------------------------------------------------------------------------
/test/5230/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestExamples(unittest.TestCase):
5 |
6 | def test_example_1(self):
7 | sieve = '''
8 | require "vacation";
9 | if header :contains "subject" "cyrus" {
10 | vacation "I'm out -- send mail to cyrus-bugs";
11 | } else {
12 | vacation "I'm out -- call me at +1 304 555 0123";
13 | }
14 | '''
15 | self.assertFalse(checksieve.parse_string(sieve, False))
16 |
17 | def test_example_2(self):
18 | sieve = '''
19 | require ["vacation", "variables"];
20 | if header :matches "subject" "*" {
21 | vacation :subject "Automatic response to: ${1}"
22 | "I'm away -- send mail to foo in my absence";
23 | }
24 | '''
25 | self.assertFalse(checksieve.parse_string(sieve, False))
26 |
27 | def test_example_3(self):
28 | sieve = '''
29 | require "vacation";
30 | vacation :days 23 :addresses ["tjs@example.edu",
31 | "ts4z@landru.example.edu"]
32 | "I'm away until October 19.
33 | If it's an emergency, call 911, I guess." ;
34 | '''
35 | self.assertFalse(checksieve.parse_string(sieve, False))
36 |
37 | def test_example_4(self):
38 | sieve = '''
39 | require "vacation";
40 | if header :contains "from" "boss@example.edu" {
41 | redirect "pleeb@isp.example.org";
42 | } else {
43 | vacation "Sorry, I'm away, I'll read your
44 | message when I get around to it.";
45 | }
46 | '''
47 | self.assertFalse(checksieve.parse_string(sieve, False))
48 |
49 | def test_example_5(self):
50 | sieve = '''
51 | require "vacation";
52 | if header :contains ["accept-language", "content-language"] "en"
53 | {
54 | vacation "I am away this week.";
55 | } else {
56 | vacation "Estoy ausente esta semana.";
57 | }
58 | '''
59 | self.assertFalse(checksieve.parse_string(sieve, False))
60 |
61 | def test_example_mime(self):
62 | sieve = '''
63 | require "vacation";
64 | vacation :mime text:
65 | Content-Type: multipart/alternative; boundary=foo
66 |
67 | --foo
68 |
69 | I'm at the beach relaxing. Mmmm, surf...
70 |
71 | --foo
72 | Content-Type: text/html; charset=us-ascii
73 |
74 |
76 | How to relax
77 |
78 | I'm at the beach relaxing.
79 | Mmmm, surf...
80 |
81 |
82 | --foo--
83 | .
84 | ;
85 | '''
86 | self.assertFalse(checksieve.parse_string(sieve, False))
87 |
88 | if __name__ == '__main__':
89 | unittest.main()
90 |
--------------------------------------------------------------------------------
/test/5231/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5231/__init__.py
--------------------------------------------------------------------------------
/test/5231/relational_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestRelational(unittest.TestCase):
5 |
6 | def test_count(self):
7 | sieve = '''
8 | require ["relational", "fileinto", "comparator-i;ascii-numeric"];
9 | if address :count "gt" :comparator "i;ascii-numeric"
10 | ["to"] ["5"]
11 | {
12 | # everything with more than 5 recipients in the "to" field
13 | # is considered SPAM
14 | fileinto "SPAM";
15 | }
16 | '''
17 | self.assertFalse(checksieve.parse_string(sieve, False))
18 |
19 | def test_count_no_require(self):
20 | sieve = '''
21 | require ["fileinto"];
22 | if address :count "gt" :comparator "i;ascii-numeric"
23 | ["to"] ["5"]
24 | {
25 | # everything with more than 5 recipients in the "to" field
26 | # is considered SPAM
27 | fileinto "SPAM";
28 | }
29 | '''
30 | self.assertTrue(checksieve.parse_string(sieve, True))
31 |
32 | def test_value(self):
33 | sieve = '''
34 | require ["relational", "fileinto", "comparator-i;ascii-casemap"];
35 | if address :value "gt" :all :comparator "i;ascii-casemap"
36 | ["from"] ["M"]
37 | {
38 | fileinto "From N-Z";
39 | }
40 | '''
41 | self.assertFalse(checksieve.parse_string(sieve, False))
42 |
43 | def test_header_test_value(self):
44 | sieve = '''
45 | require ["relational", "comparator-i;ascii-numeric", "fileinto"];
46 | if header :value "lt" :comparator "i;ascii-numeric"
47 | ["x-priority"] ["3"]
48 | {
49 | fileinto "Priority";
50 | }
51 | '''
52 | self.assertFalse(checksieve.parse_string(sieve, False))
53 |
54 | def test_value_no_require(self):
55 | sieve = '''
56 | require ["fileinto"];
57 | if address :value "gt" :all :comparator "i;ascii-casemap"
58 | ["from"] ["M"]
59 | {
60 | fileinto "From N-Z";
61 | }
62 | '''
63 | self.assertTrue(checksieve.parse_string(sieve, True))
64 |
65 | # TODO: Re-enable this test when it passes
66 | # def test_value_no_comparator_require(self):
67 | # sieve = '''
68 | # require ["fileinto", "relational"];
69 | # if address :value "gt" :all :comparator "i;ascii-numeric"
70 | # ["from"] ["M"]
71 | # {
72 | # fileinto "From N-Z";
73 | # }
74 | # '''
75 | # self.assertTrue(checksieve.parse_string(sieve, True))
76 |
77 |
78 | if __name__ == '__main__':
79 | unittest.main()
80 |
--------------------------------------------------------------------------------
/test/5232/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5232/__init__.py
--------------------------------------------------------------------------------
/test/5232/actions_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestSetFlag(unittest.TestCase):
5 |
6 | def test_setflag(self):
7 | sieve = '''
8 | require ["imap4flags"];
9 | setflag "\\Seen";
10 | '''
11 | self.assertFalse(checksieve.parse_string(sieve, False))
12 |
13 | def test_setflag_with_variable(self):
14 | sieve = '''
15 | require ["imap4flags", "fileinto"];
16 | if header :contains "from" "boss@frobnitzm.example.edu" {
17 | setflag "flagvar" "\\Flagged";
18 | fileinto :flags "${flagvar}" "INBOX.From Boss";
19 | }
20 | '''
21 | self.assertFalse(checksieve.parse_string(sieve, False))
22 |
23 | def test_setflag_no_args(self):
24 | sieve = '''
25 | require ["imap4flags"];
26 | setflag;
27 | '''
28 | self.assertTrue(checksieve.parse_string(sieve, True))
29 |
30 |
31 | class TestAddFlag(unittest.TestCase):
32 |
33 | def test_addflag(self):
34 | sieve = '''
35 | require ["imap4flags"];
36 | addflag "\\Seen";
37 | '''
38 | self.assertFalse(checksieve.parse_string(sieve, False))
39 |
40 | def test_addflag_with_var(self):
41 | sieve = '''
42 | require ["imap4flags"];
43 | addflag "flagvar" ["\\Deleted", "\\Answered"];
44 | '''
45 | self.assertFalse(checksieve.parse_string(sieve, False))
46 |
47 | def test_addflag_no_args(self):
48 | sieve = '''
49 | require ["imap4flags"];
50 | addflag;
51 | '''
52 | self.assertTrue(checksieve.parse_string(sieve, True))
53 |
54 |
55 | class TestRemoveFlag(unittest.TestCase):
56 |
57 | def test_removeflag(self):
58 | sieve = '''
59 | require ["imap4flags"];
60 | removeflag "\\Seen";
61 | '''
62 | self.assertFalse(checksieve.parse_string(sieve, False))
63 |
64 | def test_removeflag_with_var(self):
65 | sieve = '''
66 | require ["imap4flags"];
67 | removeflag "flagvar" ["\\Deleted", "\\Answered"];
68 | '''
69 | self.assertFalse(checksieve.parse_string(sieve, False))
70 |
71 | def test_removeflag_no_args(self):
72 | sieve = '''
73 | require ["imap4flags"];
74 | removeflag;
75 | '''
76 | self.assertTrue(checksieve.parse_string(sieve, True))
77 |
78 | if __name__ == '__main__':
79 | unittest.main()
--------------------------------------------------------------------------------
/test/5232/fileinto_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestFileinto(unittest.TestCase):
5 |
6 | def test_fileinto_with_flags(self):
7 | sieve = '''
8 | require ["fileinto", "imap4flags"];
9 | fileinto :flags "\\\\Seen" "Mailbox";
10 | '''
11 | self.assertFalse(checksieve.parse_string(sieve, False))
12 |
13 | def test_fileinto_with_flags_list(self):
14 | sieve = '''
15 | require ["fileinto", "imap4flags"];
16 | fileinto :flags ["\\\\Seen", "\\\\Deleted"] "Mailbox";
17 | '''
18 | self.assertFalse(checksieve.parse_string(sieve, False))
19 |
20 | def test_fileinto_with_flags_without_arguments(self):
21 | sieve = '''
22 | require ["fileinto", "imap4flags"];
23 | fileinto :flags "Mailbox";
24 | '''
25 | self.assertTrue(checksieve.parse_string(sieve, True))
26 |
27 | def test_fileinto_with_flag_and_copy(self):
28 | sieve = '''
29 | require ["fileinto", "imap4flags", "copy"];
30 | fileinto :flags "\\\\Seen" :copy "Mailbox";
31 | '''
32 | self.assertFalse(checksieve.parse_string(sieve, False))
33 |
34 | def test_fileinto_with_copy_and_flag(self):
35 | sieve = '''
36 | require ["fileinto", "imap4flags", "copy"];
37 | fileinto :copy :flags "\\\\Seen" "Mailbox";
38 | '''
39 | self.assertFalse(checksieve.parse_string(sieve, False))
40 |
41 | def test_fileinto_with_flag_without_arguments_and_copy(self):
42 | sieve = '''
43 | require ["fileinto", "imap4flags", "copy"];
44 | fileinto :flags :copy "Mailbox";
45 | '''
46 | self.assertTrue(checksieve.parse_string(sieve, True))
47 |
48 | def test_fileinto_with_copy_and_flag_without_arguments(self):
49 | sieve = '''
50 | require ["fileinto", "imap4flags", "copy"];
51 | fileinto :copy :flags "Mailbox";
52 | '''
53 | self.assertTrue(checksieve.parse_string(sieve, True))
54 |
55 |
56 |
57 | if __name__ == '__main__':
58 | unittest.main()
--------------------------------------------------------------------------------
/test/5232/keep_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestKeep(unittest.TestCase):
5 |
6 | def test_hasflag(self):
7 | sieve = '''
8 | require ["imap4flags"];
9 | if hasflag :contains "MyVar" "Junk" {
10 | keep :flags "\\\\Junk";
11 | stop;
12 | }
13 | '''
14 | self.assertFalse(checksieve.parse_string(sieve, False))
15 |
16 |
17 |
18 | if __name__ == '__main__':
19 | unittest.main()
--------------------------------------------------------------------------------
/test/5232/tests_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestTests(unittest.TestCase):
5 |
6 | def test_hasflag(self):
7 | sieve = '''
8 | require ["imap4flags"];
9 | if hasflag :contains "MyVar" "Junk" {
10 | discard;
11 | stop;
12 | }
13 | '''
14 | self.assertFalse(checksieve.parse_string(sieve, False))
15 |
16 | def test_hasflag_no_require(self):
17 | sieve = '''
18 | if hasflag :contains "MyVar" "Junk" {
19 | discard;
20 | stop;
21 | }
22 | '''
23 | self.assertTrue(checksieve.parse_string(sieve, True))
24 |
25 |
26 | if __name__ == '__main__':
27 | unittest.main()
--------------------------------------------------------------------------------
/test/5233/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5233/__init__.py
--------------------------------------------------------------------------------
/test/5233/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class ExamplesTest(unittest.TestCase):
5 |
6 | def test_example1(self):
7 | sieve = '''
8 | require ["envelope", "subaddress", "fileinto"];
9 |
10 | # In this example the same user account receives mail for both
11 | # "ken@example.com" and "postmaster@example.com"
12 |
13 | # File all messages to postmaster into a single mailbox,
14 | # ignoring the :detail part.
15 | if envelope :user "to" "postmaster" {
16 | fileinto "inbox.postmaster";
17 | stop;
18 | }
19 |
20 | # File mailing list messages (subscribed as "ken+mta-filters").
21 | if envelope :detail "to" "mta-filters" {
22 | fileinto "inbox.ietf-mta-filters";
23 | }
24 |
25 | # Redirect all mail sent to "ken+foo".
26 | if envelope :detail "to" "foo" {
27 | redirect "ken@example.net";
28 | }
29 | '''
30 | self.assertFalse(checksieve.parse_string(sieve, False))
31 |
32 |
33 | if __name__ == '__main__':
34 | unittest.main()
--------------------------------------------------------------------------------
/test/5235/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5235/__init__.py
--------------------------------------------------------------------------------
/test/5235/spamtest_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestSpamtest(unittest.TestCase):
5 |
6 | def test_without_percent(self):
7 | sieve = '''
8 | require ["spamtest", "fileinto", "relational", "comparator-
9 | i;ascii-numeric"];
10 | if spamtest :value "eq" :comparator "i;ascii-numeric" "0"
11 | {
12 | fileinto "INBOX.unclassified";
13 | }
14 | elsif spamtest :value "ge" :comparator "i;ascii-numeric" "3"
15 | {
16 | fileinto "INBOX.spam-trap";
17 | }
18 | '''
19 | self.assertFalse(checksieve.parse_string(sieve, False))
20 |
21 | def test_with_percent(self):
22 | sieve = '''
23 | require ["spamtestplus", "fileinto", "relational",
24 | "comparator-i;ascii-numeric"];
25 |
26 | if spamtest :value "eq"
27 | :comparator "i;ascii-numeric" "0"
28 | {
29 | fileinto "INBOX.unclassified";
30 | }
31 | elsif spamtest :percent :value "eq"
32 | :comparator "i;ascii-numeric" "0"
33 | {
34 | fileinto "INBOX.not-spam";
35 | }
36 | elsif spamtest :percent :value "lt"
37 | :comparator "i;ascii-numeric" "37"
38 | {
39 | fileinto "INBOX.spam-trap";
40 | }
41 | else
42 | {
43 | discard;
44 | }
45 | '''
46 | self.assertFalse(checksieve.parse_string(sieve, False))
47 |
48 | def test_with_count(self):
49 | sieve = '''
50 | require ["spamtestplus", "fileinto", "relational",
51 | "comparator-i;ascii-numeric"];
52 | if spamtest :percent :count "eq"
53 | :comparator "i;ascii-numeric" "0"
54 | {
55 | fileinto "INBOX.unclassified";
56 | }
57 | elsif spamtest :percent :value "eq"
58 | :comparator "i;ascii-numeric" "0"
59 | {
60 | fileinto "INBOX.not-spam";
61 | }
62 | elsif spamtest :percent :value "lt"
63 | :comparator "i;ascii-numeric" "37"
64 | {
65 | fileinto "INBOX.spam-trap";
66 | }
67 | else
68 | {
69 | discard;
70 | }
71 | '''
72 | self.assertFalse(checksieve.parse_string(sieve, False))
73 |
74 |
75 | if __name__ == '__main__':
76 | unittest.main()
--------------------------------------------------------------------------------
/test/5235/virustest_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestVirustest(unittest.TestCase):
5 |
6 | def test_virustest(self):
7 | sieve = '''
8 | require ["virustest", "fileinto", "relational", "comparator-
9 | i;ascii-numeric"];
10 |
11 | if virustest :value "eq" :comparator "i;ascii-numeric" "0"
12 | {
13 | fileinto "INBOX.unclassified";
14 | }
15 | if virustest :value "eq" :comparator "i;ascii-numeric" "4"
16 | {
17 | fileinto "INBOX.quarantine";
18 | }
19 | elsif virustest :value "eq" :comparator "i;ascii-numeric" "5"
20 | {
21 | discard;
22 | }
23 | '''
24 | self.assertFalse(checksieve.parse_string(sieve, False))
25 |
26 |
27 | if __name__ == '__main__':
28 | unittest.main()
--------------------------------------------------------------------------------
/test/5260/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5260/__init__.py
--------------------------------------------------------------------------------
/test/5260/currentdate_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestCurrentDate(unittest.TestCase):
5 |
6 | def test_current_date(self):
7 | sieve = '''
8 | require ["date", "relational"];
9 | if anyof(currentdate :is "weekday" "0",
10 | currentdate :is "weekday" "6",
11 | currentdate :value "lt" "hour" "09",
12 | currentdate :value "ge" "hour" "17")
13 | { redirect "pager@example.com"; }
14 | '''
15 | self.assertFalse(checksieve.parse_string(sieve, False))
16 |
17 | def test_current_date_no_require(self):
18 | sieve = '''
19 | require ["relational"];
20 | if anyof(currentdate :is "weekday" "0",
21 | currentdate :is "weekday" "6",
22 | currentdate :value "lt" "hour" "09",
23 | currentdate :value "ge" "hour" "17")
24 | { redirect "pager@example.com"; }
25 | '''
26 | self.assertTrue(checksieve.parse_string(sieve, True))
27 |
28 |
29 | if __name__ == '__main__':
30 | unittest.main()
--------------------------------------------------------------------------------
/test/5260/date_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestDate(unittest.TestCase):
5 |
6 | def test_date_pass(self):
7 | sieve = '''
8 | require ["date", "relational", "fileinto"];
9 | if anyof(date :is "received" "weekday" "0",
10 | date :is "received" "weekday" "6")
11 | { fileinto "weekend"; }
12 | '''
13 | self.assertFalse(checksieve.parse_string(sieve, False))
14 |
15 | def test_date_no_require(self):
16 | sieve = '''
17 | require ["relational", "fileinto"];
18 | if anyof(date :is "received" "weekday" "0",
19 | date :is "received" "weekday" "6")
20 | { fileinto "weekend"; }
21 | '''
22 | self.assertTrue(checksieve.parse_string(sieve, True))
23 |
24 | def test_date_2(self):
25 | sieve = '''
26 | require ["date", "relational", "fileinto"];
27 | if allof(header :is "from" "boss@example.com",
28 | date :value "ge" :originalzone "date" "hour" "09",
29 | date :value "lt" :originalzone "date" "hour" "17")
30 | { fileinto "urgent"; }
31 | '''
32 | self.assertFalse(checksieve.parse_string(sieve, False))
33 |
34 |
35 | if __name__ == '__main__':
36 | unittest.main()
--------------------------------------------------------------------------------
/test/5260/index_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestIndex(unittest.TestCase):
5 |
6 | def test_index(self):
7 | sieve = '''
8 | # Implement the Internet-Draft cutoff date check assuming the
9 | # second Received: field specifies when the message first
10 | # entered the local email infrastructure.
11 | require ["date", "relational", "index"];
12 | if date :value "gt" :index 2 :zone "-0500" "received"
13 | "iso8601" "2007-02-26T09:00:00-05:00"
14 | { redirect "aftercutoff@example.org"; }
15 | '''
16 | self.assertFalse(checksieve.parse_string(sieve, False))
17 |
18 | def test_index_no_require(self):
19 | sieve = '''
20 | # Implement the Internet-Draft cutoff date check assuming the
21 | # second Received: field specifies when the message first
22 | # entered the local email infrastructure.
23 | require ["date", "relational"];
24 | if date :value "gt" :index 2 :zone "-0500" "received"
25 | "iso8601" "2007-02-26T09:00:00-05:00"
26 | { redirect "aftercutoff@example.org"; }
27 | '''
28 | self.assertTrue(checksieve.parse_string(sieve, True))
29 |
30 |
31 | if __name__ == '__main__':
32 | unittest.main()
--------------------------------------------------------------------------------
/test/5293/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5293/__init__.py
--------------------------------------------------------------------------------
/test/5293/actions_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestAddHeader(unittest.TestCase):
5 |
6 | def test_addheader_correct(self):
7 | sieve = '''
8 | if not header :contains "X-Sieve-Filtered"
9 | ["", ""]
10 | {
11 | addheader "X-Sieve-Filtered" "";
12 | redirect "kim@home.example.com";
13 | }
14 | '''
15 | self.assertFalse(checksieve.parse_string(sieve, False))
16 |
17 | def test_addheader_correct_lasttag(self):
18 | sieve = '''
19 | if not header :contains "X-Sieve-Filtered"
20 | ["", ""]
21 | {
22 | addheader :last "X-Sieve-Filtered" "";
23 | redirect "kim@home.example.com";
24 | }
25 | '''
26 | self.assertFalse(checksieve.parse_string(sieve, False))
27 |
28 | def test_addheader_incorrect_tag(self):
29 | sieve = '''
30 | if not header :contains "X-Sieve-Filtered"
31 | ["", ""]
32 | {
33 | addheader :is "X-Sieve-Filtered" "";
34 | redirect "kim@home.example.com";
35 | }
36 | '''
37 | self.assertTrue(checksieve.parse_string(sieve, True))
38 |
39 | def test_addheader_incorrect_number_of_args(self):
40 | sieve = '''
41 | if not header :contains "X-Sieve-Filtered"
42 | ["", ""]
43 | {
44 | addheader :is "X-Sieve-Filtered";
45 | redirect "kim@home.example.com";
46 | }
47 | '''
48 | self.assertTrue(checksieve.parse_string(sieve, True))
49 |
50 | def test_addheader_incorrect_type(self):
51 | sieve = '''
52 | if not header :contains "X-Sieve-Filtered"
53 | ["", ""]
54 | {
55 | addheader :last :is "X-Sieve-Filtered";
56 | redirect "kim@home.example.com";
57 | }
58 | '''
59 | self.assertTrue(checksieve.parse_string(sieve, True))
60 |
61 | def test_add_and_delete_1(self):
62 | sieve = '''
63 | require ["index"];
64 | addheader "X-Hello" "World";
65 | deleteheader :index 1 "X-Hello";
66 | '''
67 | self.assertFalse(checksieve.parse_string(sieve, False))
68 |
69 | def test_delete_header(self):
70 | sieve = '''
71 | require ["index"];
72 | deleteheader :index 1 :last "X-Hello";
73 | '''
74 | self.assertFalse(checksieve.parse_string(sieve, False))
75 |
76 | def test_delete_header_incorrect_last(self):
77 | sieve = '''
78 | require "index";
79 | deleteheader :index 1 "X-Hello" :last;
80 | '''
81 | self.assertTrue(checksieve.parse_string(sieve, True))
82 |
83 |
84 | if __name__ == '__main__':
85 | unittest.main()
86 |
--------------------------------------------------------------------------------
/test/5429/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5429/__init__.py
--------------------------------------------------------------------------------
/test/5429/basic_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestBasic(unittest.TestCase):
5 |
6 | def test_reject(self):
7 | sieve = '''
8 | require ["reject"];
9 | reject "I don't like mail";
10 | '''
11 | self.assertFalse(checksieve.parse_string(sieve, False))
12 |
13 | def test_reject_no_arg(self):
14 | sieve = '''
15 | require ["reject"];
16 | reject;
17 | '''
18 | self.assertTrue(checksieve.parse_string(sieve, True))
19 |
20 | def test_reject_no_require(self):
21 | sieve = '''
22 | reject "I don't like mail";
23 | '''
24 | self.assertTrue(checksieve.parse_string(sieve, True))
25 |
26 | def test_ereject(self):
27 | sieve = '''
28 | require ["ereject"];
29 | ereject "I don't like mail";
30 | '''
31 | self.assertFalse(checksieve.parse_string(sieve, False))
32 |
33 | def test_ereject_no_arg(self):
34 | sieve = '''
35 | require ["ereject"];
36 | ereject;
37 | '''
38 | self.assertTrue(checksieve.parse_string(sieve, True))
39 |
40 | def test_ereject_no_require(self):
41 | sieve = '''
42 | ereject "I don't like mail";
43 | '''
44 | self.assertTrue(checksieve.parse_string(sieve, True))
45 |
46 | def test_with_multiline_reason(self):
47 | sieve = '''
48 | require ["reject"];
49 |
50 | if size :over 100K {
51 | reject text:
52 | Your message is too big. If you want to send me a big attachment,
53 | put it on a public web site and send me a URL.
54 | .
55 | ;
56 | }
57 | '''
58 | self.assertFalse(checksieve.parse_string(sieve, False))
59 |
60 | if __name__ == '__main__':
61 | unittest.main()
--------------------------------------------------------------------------------
/test/5435/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5435/__init__.py
--------------------------------------------------------------------------------
/test/5435/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestNotify(unittest.TestCase):
5 |
6 | def test_example1(self):
7 | sieve = '''
8 | require ["enotify", "fileinto", "variables"];
9 |
10 | if header :contains "from" "boss@example.org" {
11 | notify :importance "1"
12 | :message "This is probably very important"
13 | "mailto:alm@example.com";
14 | # Don't send any further notifications
15 | stop;
16 | }
17 |
18 | if header :contains "to" "sievemailinglist@example.org" {
19 | # :matches is used to get the value of the Subject header
20 | if header :matches "Subject" "*" {
21 | set "subject" "${1}";
22 | }
23 |
24 | # :matches is used to get the value of the From header
25 | if header :matches "From" "*" {
26 | set "from" "${1}";
27 | }
28 |
29 | notify :importance "3"
30 | :message "[SIEVE] ${from}: ${subject}"
31 | "mailto:alm@example.com";
32 | fileinto "INBOX.sieve";
33 | }
34 | '''
35 | self.assertFalse(checksieve.parse_string(sieve, False))
36 |
37 | def test_example2(self):
38 | sieve = '''
39 | require ["enotify", "fileinto", "variables", "envelope"];
40 |
41 | if header :matches "from" "*@*.example.org" {
42 | # :matches is used to get the MAIL FROM address
43 | if envelope :all :matches "from" "*" {
44 | set "env_from" " [really: ${1}]";
45 | }
46 |
47 | # :matches is used to get the value of the Subject header
48 | if header :matches "Subject" "*" {
49 | set "subject" "${1}";
50 | }
51 |
52 | # :matches is used to get the address from the From header
53 | if address :matches :all "from" "*" {
54 | set "from_addr" "${1}";
55 | }
56 |
57 | notify :message "${from_addr}${env_from}: ${subject}"
58 | "mailto:alm@example.com";
59 | }
60 | '''
61 | self.assertFalse(checksieve.parse_string(sieve, False))
62 |
63 | def test_example3(self):
64 | sieve = '''
65 | require ["enotify", "variables"];
66 |
67 | set "notif_method"
68 | "xmpp:tim@example.com?message;subject=SIEVE;body=You%20got%20mail";
69 |
70 | if header :contains "subject" "Your dog" {
71 | set "notif_method" "tel:+14085551212";
72 | }
73 |
74 | if header :contains "to" "sievemailinglist@example.org" {
75 | set "notif_method" "";
76 | }
77 |
78 | if not string :is "${notif_method}" "" {
79 | notify "${notif_method}";
80 | }
81 |
82 | if header :contains "from" "boss@example.org" {
83 | # :matches is used to get the value of the Subject header
84 | if header :matches "Subject" "*" {
85 | set "subject" "${1}";
86 | }
87 |
88 | # don't need high importance notification for
89 | # a 'for your information'
90 | if not header :contains "subject" "FYI:" {
91 | notify :importance "1" :message "BOSS: ${subject}"
92 | "tel:+14085551212";
93 | }
94 | }
95 | '''
96 | self.assertFalse(checksieve.parse_string(sieve, False))
97 |
98 | def test_example4(self):
99 | sieve = '''
100 | require ["enotify"];
101 | if not valid_notify_method ["mailto:",
102 | "http://gw.example.net/notify?test"] {
103 | stop;
104 | }
105 | '''
106 | self.assertFalse(checksieve.parse_string(sieve, False))
107 |
108 | def test_example5(self):
109 | sieve = '''
110 | require ["enotify"];
111 |
112 | if notify_method_capability
113 | "xmpp:tim@example.com?message;subject=SIEVE"
114 | "Online"
115 | "yes" {
116 | notify :importance "1" :message "You got mail"
117 | "xmpp:tim@example.com?message;subject=SIEVE";
118 | } else {
119 | notify :message "You got mail" "tel:+14085551212";
120 | }
121 | '''
122 | self.assertFalse(checksieve.parse_string(sieve, False))
123 |
124 | def test_example6(self):
125 | sieve = '''
126 | require ["enotify", "variables"];
127 |
128 | set :encodeurl "body_param" "Safe body&evil=evilbody";
129 |
130 | notify "mailto:tim@example.com?body=${body_param}";
131 | '''
132 | self.assertFalse(checksieve.parse_string(sieve, False))
133 |
134 | def test_example6_no_variables(self):
135 | sieve = '''
136 | require ["enotify"];
137 |
138 | set :encodeurl "body_param" "Safe body&evil=evilbody";
139 |
140 | notify "mailto:tim@example.com?body=${body_param}";
141 | '''
142 | self.assertTrue(checksieve.parse_string(sieve, True))
143 |
144 | if __name__ == '__main__':
145 | unittest.main()
--------------------------------------------------------------------------------
/test/5436/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5436/__init__.py
--------------------------------------------------------------------------------
/test/5436/notify_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestMailto(unittest.TestCase):
5 |
6 | def test_example1(self):
7 | sieve = '''
8 | require ["enotify", "variables"];
9 |
10 | if header :contains "list-id" "knitting.example.com" {
11 | if header :matches "Subject" "[*] *" {
12 | notify :message "From ${1} list: ${2}"
13 | :importance "3"
14 | "mailto:0123456789@sms.example.net?to=backup@example.com";
15 | }
16 | }
17 | '''
18 | self.assertFalse(checksieve.parse_string(sieve, False))
19 |
20 | if __name__ == '__main__':
21 | unittest.main()
--------------------------------------------------------------------------------
/test/5463/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5463/__init__.py
--------------------------------------------------------------------------------
/test/5463/error_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestError(unittest.TestCase):
5 |
6 | def test_error(self):
7 | sieve = '''
8 | require "ihave";
9 |
10 | addheader "X-Hello" "World";
11 | if ihave "index" {
12 | deleteheader :index 1 "X-Hello";
13 | } else {
14 | error "Abort!";
15 | }
16 | '''
17 | self.assertFalse(checksieve.parse_string(sieve, False))
18 |
19 | def test_error_no_message(self):
20 | sieve = '''
21 | require "ihave";
22 |
23 | addheader "X-Hello" "World";
24 | if ihave "index" {
25 | deleteheader :index 1 "X-Hello";
26 | } else {
27 | error;
28 | }
29 | '''
30 | self.assertTrue(checksieve.parse_string(sieve, True))
31 |
32 | if __name__ == '__main__':
33 | unittest.main()
--------------------------------------------------------------------------------
/test/5463/ihave_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestIHave(unittest.TestCase):
5 |
6 | def test_ihave_index(self):
7 | sieve = '''
8 | require "ihave";
9 |
10 | addheader "X-Hello" "World";
11 | if ihave "index" {
12 | deleteheader :index 1 "X-Hello";
13 | }
14 | '''
15 | self.assertFalse(checksieve.parse_string(sieve, False))
16 |
17 |
18 |
19 | if __name__ == '__main__':
20 | unittest.main()
21 |
--------------------------------------------------------------------------------
/test/5490/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5490/__init__.py
--------------------------------------------------------------------------------
/test/5490/fileinto_create_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestCreateTag(unittest.TestCase):
5 |
6 | def test_create_tag(self):
7 | sieve = '''
8 | require ["fileinto", "reject", "mailbox"];
9 | if mailboxexists "Partners" {
10 | fileinto :create "Partners";
11 | } else {
12 | reject "This message was not accepted by the Mailstore";
13 | }
14 | '''
15 | self.assertFalse(checksieve.parse_string(sieve, False))
16 |
17 |
18 | if __name__ == '__main__':
19 | unittest.main()
--------------------------------------------------------------------------------
/test/5490/mailboxexists_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestMailboxexists(unittest.TestCase):
5 |
6 | def test_mailboxexists(self):
7 | sieve = '''
8 | require ["fileinto", "reject", "mailbox"];
9 | if mailboxexists "Partners" {
10 | fileinto "Partners";
11 | } else {
12 | reject "This message was not accepted by the Mailstore";
13 | }
14 | '''
15 | self.assertFalse(checksieve.parse_string(sieve, False))
16 |
17 |
18 | if __name__ == '__main__':
19 | unittest.main()
--------------------------------------------------------------------------------
/test/5490/metadata_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestMetadata(unittest.TestCase):
5 |
6 | def test_metadata(self):
7 | sieve = '''
8 | require ["mboxmetadata", "vacation"];
9 |
10 | if metadata :is "INBOX"
11 | "/private/vendor/vendor.isode/auto-replies" "on" {
12 |
13 | vacation text:
14 | I'm away on holidays till March 2009.
15 | Expect a delay.
16 | .
17 | ;
18 |
19 | }
20 | '''
21 | self.assertFalse(checksieve.parse_string(sieve, False))
22 |
23 | def test_metadataexists(self):
24 | sieve = '''
25 | require ["mboxmetadata", "vacation"];
26 |
27 | if metadataexists "INBOX"
28 | "/private/vendor/vendor.isode/auto-replies" {
29 |
30 | stop;
31 |
32 | }
33 | '''
34 | self.assertFalse(checksieve.parse_string(sieve, False))
35 |
36 |
37 | if __name__ == '__main__':
38 | unittest.main()
--------------------------------------------------------------------------------
/test/5490/servermetadata_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestServermetadata(unittest.TestCase):
5 |
6 | def test_servermetadata(self):
7 | sieve = '''
8 | require ["servermetadata", "variables", "envelope"];
9 |
10 | if servermetadata :matches
11 | "/private/vendor/vendor.isode/notification-uri" "*" {
12 | set "notif_uri" "${0}";
13 | }
14 |
15 | if not string :is "${notif_uri}" "none" {
16 | # :matches is used to get the MAIL FROM address
17 | if envelope :all :matches "from" "*" {
18 | set "env_from" " [really: ${1}]";
19 | }
20 |
21 | # :matches is used to get the value of the Subject header
22 | if header :matches "Subject" "*" {
23 | set "subject" "${1}";
24 | }
25 | # :matches is used to get the address from the From header
26 | if address :matches :all "from" "*" {
27 | set "from_addr" "${1}";
28 | }
29 |
30 | # notify :message "${from_addr}${env_from}: ${subject}"
31 | # "${notif_uri}";
32 | stop;
33 | }
34 | '''
35 | self.assertFalse(checksieve.parse_string(sieve, False))
36 |
37 |
38 | if __name__ == '__main__':
39 | unittest.main()
--------------------------------------------------------------------------------
/test/5703/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/5703/__init__.py
--------------------------------------------------------------------------------
/test/5703/tests_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestTests(unittest.TestCase):
5 |
6 | def test_address(self):
7 | sieve = '''
8 | require ["mime", "fileinto"];
9 |
10 | if address :mime :is :all "content-from" "tim@example.com"
11 | {
12 | fileinto "INBOX.part-from-tim";
13 | }
14 | '''
15 | self.assertFalse(checksieve.parse_string(sieve, False))
16 |
17 | def test_exists(self):
18 | sieve = '''
19 | require ["mime", "fileinto"];
20 |
21 | if exists :mime :anychild "content-md5"
22 | {
23 | fileinto "INBOX.md5";
24 | }
25 | '''
26 | self.assertFalse(checksieve.parse_string(sieve, False))
27 |
28 |
29 | if __name__ == '__main__':
30 | unittest.main()
31 |
--------------------------------------------------------------------------------
/test/6009/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/6009/__init__.py
--------------------------------------------------------------------------------
/test/6009/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class ExamplesTest(unittest.TestCase):
5 |
6 | def test_notify_dsn_01(self):
7 | sieve = '''
8 | require ["envelope", "envelope-dsn"];
9 |
10 | # Check whether SUCCESS notifications were requested,
11 | # irrespective of any other requests that were made
12 | if envelope "notify" "SUCCESS"
13 | {
14 | # do whatever
15 | }
16 | '''
17 | self.assertFalse(checksieve.parse_string(sieve, False))
18 |
19 | def test_notify_dsn_02(self):
20 | sieve = '''
21 | require ["envelope", "envelope-dsn", "relational",
22 | "comparator-i;ascii-numeric"];
23 |
24 | # Check whether only FAILURE notifications were requested
25 | if allof ( envelope "notify" "FAILURE",
26 | envelope :comparator "i;ascii-numeric"
27 | :count "eq" "notify" "1"
28 | )
29 | {
30 | # do whatever
31 | }
32 | '''
33 | self.assertFalse(checksieve.parse_string(sieve, False))
34 |
35 | def test_notify_dsn_03(self):
36 | sieve = '''
37 | require ["envelope", "envelope-dsn"];
38 |
39 | # See if the orcpt is an RFC822 address in the example.com
40 | # domain
41 | if envelope :matches "orcpt" "rfc822;*@example.com"
42 | {
43 | # do whatever
44 | }
45 | '''
46 | self.assertFalse(checksieve.parse_string(sieve, False))
47 |
48 | def test_notify_deliverby_01(self):
49 | sieve = '''
50 | require ["envelope", "envelope-deliverby", "relational",
51 | "comparator-i;ascii-numeric"];
52 |
53 | # Check to see if this message didn't make it in the time allotted by
54 | # the originator.
55 | if anyof (envelope :contains "bytimerelative" "-",
56 | envelope :value "eq" :comparator "i;ascii-numeric"
57 | "bytimerelative" "0")
58 | {
59 | # do whatever
60 | }
61 | '''
62 | self.assertFalse(checksieve.parse_string(sieve, False))
63 |
64 | def test_notify_deliverby_02(self):
65 | sieve = '''
66 | require ["envelope", "envelope-deliverby", "relational", "date",
67 | "variables"];
68 | # Check to see if this message didn't make it in the time allotted by
69 | # the originator.
70 | if currentdate :matches "iso8601" "*" {
71 | set "cdate" "${0}";
72 | if envelope :value "ge" "bytimeabsolute" "${cdate}" {
73 | # do whatever
74 | }
75 | }
76 | '''
77 | self.assertFalse(checksieve.parse_string(sieve, False))
78 |
79 | def test_notify_deliverby_03(self):
80 | sieve = '''
81 | require ["envelope", "envelope-deliverby", "relational", "date",
82 | "variables", "fileinto"];
83 |
84 | # If the message didn't make it in time, file it according to when it
85 | # should have been received
86 | if envelope :matches :zone "+0000" "bytimeabsolute" "*T*:*:*" {
87 | set "bdate" "${0}";
88 | set "bhour" "${2}";
89 | if currentdate :zone "+0000" :value "lt" "iso8601" "${bdate}" {
90 | fileinto "missed-${bhour}";
91 | }
92 | }
93 | '''
94 | self.assertFalse(checksieve.parse_string(sieve, False))
95 |
96 | def test_notify_deliverby_04(self):
97 | sieve = '''
98 | require ["envelope", "relational", "date",
99 | "variables", "fileinto"];
100 |
101 | # If the message didn't make it in time, file it according to when it
102 | # should have been received
103 | if envelope :matches :zone "+0000" "from" "*T*:*:*" {
104 | set "bdate" "${0}";
105 | set "bhour" "${2}";
106 | if currentdate :zone "+0000" :value "lt" "iso8601" "${bdate}" {
107 | fileinto "missed-${bhour}";
108 | }
109 | }
110 | '''
111 | self.assertTrue(checksieve.parse_string(sieve, True))
112 |
113 | def test_redirect_dsn_01(self):
114 | sieve = '''
115 | require ["copy", "redirect-dsn"];
116 |
117 | # Make a private copy of messages from user@example.com
118 | if address "from" "user@example.com"
119 | {
120 | redirect :copy :notify "NEVER" "elsewhere@example.com";
121 | }
122 | '''
123 | self.assertFalse(checksieve.parse_string(sieve, False))
124 |
125 | def test_redirect_deliverby_01(self):
126 | sieve = '''
127 | require ["copy", "redirect-deliverby"];
128 |
129 | # Send a copy to my cell phone, time out after 10 minutes
130 | if address "from" "user@example.com"
131 | {
132 | redirect :copy :bytimerelative 600 "cellphone@example.com";
133 | }
134 | '''
135 | self.assertFalse(checksieve.parse_string(sieve, False))
136 |
137 | def test_redirect_deliverby_02(self):
138 | sieve = '''
139 | require ["copy", "redirect-deliverby", "date", "variables",
140 | "relational", "comparator-i;ascii-numeric"];
141 |
142 | # Send a copy to my cell phone to be delivered before 10PM
143 | if currentdate :value "lt"
144 | :comparator "i;ascii-numeric" "hour" "22"
145 | {
146 | if currentdate :matches "date" "*" {set "date" "${0}";}
147 | if currentdate :matches "zone" "*" {set "zone" "${0}";}
148 | redirect :copy :bytimeabsolute "${date}T20:00:00${zone}"
149 | :bymode "return" "cellphone@example.com";
150 | }
151 | '''
152 | self.assertFalse(checksieve.parse_string(sieve, False))
153 |
154 |
155 | if __name__ == '__main__':
156 | unittest.main()
157 |
--------------------------------------------------------------------------------
/test/6134/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/6134/__init__.py
--------------------------------------------------------------------------------
/test/6134/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 |
5 | class TestExamples(unittest.TestCase):
6 | def test_example_1a(self):
7 | sieve = """
8 | require ["envelope", "extlists", "fileinto", "spamtest",
9 | "relational", "comparator-i;ascii-numeric"];
10 | if envelope :list "from" ":addrbook:default"
11 | { /* Known: allow high spam score */
12 | if spamtest :value "ge" :comparator "i;ascii-numeric" "8"
13 | {
14 | fileinto "spam";
15 | }
16 | }
17 | elsif spamtest :value "ge" :comparator "i;ascii-numeric" "3"
18 | { /* Unknown: less tolerance in spam score */
19 | fileinto "spam";
20 | }
21 | """
22 | self.assertFalse(checksieve.parse_string(sieve, False))
23 |
24 | def test_example_1b(self):
25 | sieve = """
26 | require ["envelope", "extlists", "fileinto", "spamtest",
27 | "variables", "relational", "comparator-i;ascii-numeric"];
28 | if envelope :list "from" ":addrbook:default" {
29 | set "lim" "8"; /* Known: allow high spam score */
30 | } else {
31 | set "lim" "3"; /* Unknown: less tolerance in spam score */
32 | }
33 | if spamtest :value "ge" :comparator "i;ascii-numeric" "${lim}" {
34 | fileinto "spam";
35 | }
36 | """
37 | self.assertFalse(checksieve.parse_string(sieve, False))
38 |
39 | def test_example_2(self):
40 | sieve = """
41 | require ["extlists", "date", "enotify"];
42 | if currentdate :list "date"
43 | "tag:example.com,2011-01-01:localHolidays" {
44 | notify "xmpp:romeo@im.example.com";
45 | }
46 | """
47 | self.assertFalse(checksieve.parse_string(sieve, False))
48 |
49 | def test_example_3(self):
50 | sieve = """
51 | require ["extlists", "envelope", "subaddress"];
52 |
53 | # Submission from list members is sent to all members
54 | if allof (envelope :detail "to" "mylist",
55 | header :list "from"
56 | "tag:example.com,2010-05-28:mylist") {
57 | redirect :list "tag:example.com,2010-05-28:mylist";
58 | }
59 | """
60 | self.assertFalse(checksieve.parse_string(sieve, False))
61 |
62 | def test_example_4(self):
63 | sieve = """
64 | require ["variables", "extlists", "index", "reject"];
65 | if header :index 1 :matches "received" "*(* [*.*.*.*])*" {
66 | set "ip" "${3}.${4}.${5}.${6}";
67 | if string :list "${ip}"
68 | "tag:example.com,2011-04-10:DisallowedIPs" {
69 | reject "Message not allowed from this IP address";
70 | }
71 | }
72 | """
73 | self.assertFalse(checksieve.parse_string(sieve, False))
74 |
75 | def test_example_5(self):
76 | sieve = """
77 | require [ "extlists", "foreverypart", "mime", "enclose" ];
78 |
79 | foreverypart
80 | {
81 | if header :mime :param "filename"
82 | :list ["Content-Type", "Content-Disposition"]
83 | "tag:example.com,2011-04-10:BadFileNameExts"
84 | {
85 | # these attachment types are executable
86 | enclose :subject "Warning" text:
87 | WARNING! The enclosed message has attachments that might be unsafe.
88 | These attachment types may contain a computer virus program
89 | that can infect your computer and potentially damage your data.
90 |
91 | Before clicking on these message attachments, you should verify
92 | with the sender that this message was sent intentionally, and
93 | that the attachments are safe to open.
94 | .
95 | ;
96 | break;
97 | }
98 | }
99 | """
100 | self.assertFalse(checksieve.parse_string(sieve, False))
101 |
102 |
103 | if __name__ == "__main__":
104 | unittest.main()
105 |
--------------------------------------------------------------------------------
/test/6134/valid_ext_lists_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 |
5 | class TestValidExtList(unittest.TestCase):
6 | def test_valid_ext_list(self):
7 | sieve = """
8 | require ["extlists", "reject"];
9 | if valid_ext_list ":addrbook:default"
10 | {
11 | reject "Sorry, only friends and work!";
12 | }
13 | elsif valid_ext_list [":addrbook:frens", ":addrbook:work"]
14 | {
15 | stop;
16 | }
17 | """
18 | self.assertFalse(checksieve.parse_string(sieve, False))
19 |
20 |
21 | if __name__ == "__main__":
22 | unittest.main()
23 |
--------------------------------------------------------------------------------
/test/6558/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/6558/__init__.py
--------------------------------------------------------------------------------
/test/6558/bogus_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestBogus(unittest.TestCase):
5 |
6 | def test_bogus_argument(self):
7 | sieve = '''
8 | require ["convert"];
9 | convert "image/tiff" 2 ["pix-x=320","pix-y=240"];
10 | '''
11 | self.assertTrue(checksieve.parse_string(sieve, True))
12 |
13 | def test_unquoted_strings(self):
14 | sieve = '''
15 | require ["convert"];
16 | convert image/tiff image/jpeg ["pix-x=320","pix-y=240"];
17 | '''
18 | self.assertTrue(checksieve.parse_string(sieve, True))
19 |
20 |
21 | if __name__ == '__main__':
22 | unittest.main()
23 |
--------------------------------------------------------------------------------
/test/6558/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestExamples(unittest.TestCase):
5 |
6 | def test_example_1(self):
7 | sieve = '''
8 | require ["convert"];
9 | convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"];
10 | '''
11 | self.assertFalse(checksieve.parse_string(sieve, False))
12 |
13 | def test_example_2(self):
14 | sieve = '''
15 | require ["mime", "fileinto", "convert"];
16 | if header :mime :anychild :contenttype
17 | "Content-Type" "image/tiff"
18 | {
19 | if (convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"]) {
20 | fileinto "INBOX.pics";
21 | }
22 | }
23 | '''
24 | self.assertFalse(checksieve.parse_string(sieve, False))
25 |
26 | def test_example_3(self):
27 | sieve = '''
28 | require ["mime", "foreverypart", "fileinto", "convert"];
29 | foreverypart
30 | {
31 | if header :mime :param "filename" :contains
32 | "Content-Disposition" "inline"
33 | {
34 | if size :over "500K"
35 | {
36 | convert "image/tiff" "image/jpeg" ["pix-x=640","pix-y=480"];
37 | } else {
38 | convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"];
39 | }
40 | }
41 | }
42 | '''
43 | self.assertFalse(checksieve.parse_string(sieve, False))
44 |
45 | def test_example_4(self):
46 | sieve = '''
47 | require ["mime", "foreverypart",
48 | "fileinto", "redirect", "convert"];
49 |
50 | # The first "if" block will convert all image/tiff body parts
51 | # to 640x480 jpegs and will file the message
52 | # into the "INBOX.pics" mailbox as converted at this point.
53 | if header :mime :anychild :contenttype
54 | "Content-Type" "image/tiff"
55 | {
56 | convert "image/tiff" "image/jpeg" ["pix-x=640","pix-y=480"];
57 | fileinto "INBOX.pics";
58 | }
59 |
60 | # The second block, the "foreverypart" loop, will convert all
61 | # inline jpegs to 320x240 resolution... including any tiff body
62 | # parts that had been converted in the first block, above.
63 | # Therefore, any tiff that had been converted to a 640x480 jpeg
64 | # will be re-converted to a 320x240 jpeg here if its
65 | # Content-Disposition is specified as "inline".
66 | foreverypart
67 | {
68 | if header :mime :param "filename" :contains
69 | "Content-Disposition" "inline"
70 | {
71 | convert "image/jpeg" "image/jpeg" ["pix-x=320","pix-y=240"];
72 | }
73 | }
74 |
75 | # The third block will take any message that contains a header
76 | # field called "Mobile-Link" and redirect it to the user's
77 | # mobile address. The redirected message will include both
78 | # conversions above, from block one and block two.
79 | if exists "Mobile-Link"
80 | {
81 | redirect "joe@mobile.example.com";
82 | }
83 |
84 | # The fourth block will file the message into "Tiff" if it
85 | # contains any tiff body parts. But because of the earlier
86 | # conversion (in the first block), there will never be any
87 | # tiff body parts, so this "fileinto" will never happen.
88 | if header :mime :anychild :contenttype
89 | "Content-Type" "image/tiff"
90 | {
91 | fileinto "Tiff";
92 | }
93 |
94 | # Now, at the end of the script processing, the Sieve
95 | # processor will perform an implicit keep if none of
96 | # the "fileinto" and "redirect" actions were taken.
97 | # The kept message will include any conversions that
98 | # were done (that is, any from the second block).
99 | '''
100 | self.assertFalse(checksieve.parse_string(sieve, False))
101 |
102 |
103 | if __name__ == '__main__':
104 | unittest.main()
105 |
--------------------------------------------------------------------------------
/test/6609/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/6609/__init__.py
--------------------------------------------------------------------------------
/test/6609/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestExamples(unittest.TestCase):
5 |
6 | def test_example_1(self):
7 | sieve = '''
8 | require ["include"];
9 |
10 | include :personal "always_allow";
11 | include :global "spam_tests";
12 | include :personal "spam_tests";
13 | include :personal "mailing_lists";
14 | '''
15 | self.assertFalse(checksieve.parse_string(sieve, False))
16 |
17 | def test_example_2(self):
18 | sieve = '''
19 | require ["variables", "include"];
20 |
21 | set "global.i_am_on_vacation" "1";
22 | '''
23 | self.assertFalse(checksieve.parse_string(sieve, False))
24 |
25 | def test_return_command_no_require(self):
26 | sieve = '''
27 | return;
28 | '''
29 | self.assertTrue(checksieve.parse_string(sieve, True))
30 |
31 | def test_return_command(self):
32 | sieve = '''
33 | require ["include"];
34 | return;
35 | '''
36 | self.assertFalse(checksieve.parse_string(sieve, False))
37 |
38 | def test_include_no_arguments(self):
39 | sieve = '''
40 | require ["include"];
41 | include;
42 | '''
43 | self.assertTrue(checksieve.parse_string(sieve, True))
44 |
45 |
46 | if __name__ == '__main__':
47 | unittest.main()
48 |
--------------------------------------------------------------------------------
/test/6609/global_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class GlobalTest(unittest.TestCase):
5 |
6 | def test_global(self):
7 | sieve = '''
8 | require ["include", "variables"];
9 |
10 | global "test";
11 | '''
12 | self.assertFalse(checksieve.parse_string(sieve, False))
13 |
14 | def test_global_no_require(self):
15 | sieve = '''
16 | global "test";
17 | '''
18 | self.assertTrue(checksieve.parse_string(sieve, True))
19 |
20 | def test_global_no_include_require(self):
21 | sieve = '''
22 | require ["variables"];
23 |
24 | global "test";
25 | '''
26 | self.assertTrue(checksieve.parse_string(sieve, True))
27 |
28 | def test_global_no_variables_require(self):
29 | sieve = '''
30 | require ["include"];
31 |
32 | global "test";
33 | '''
34 | self.assertTrue(checksieve.parse_string(sieve, True))
35 |
36 | def test_global_list(self):
37 | sieve = '''
38 | require ["include", "variables"];
39 |
40 | global ["foo", "bar", "baz"];
41 | '''
42 | self.assertFalse(checksieve.parse_string(sieve, False))
43 |
44 | def test_global_no_args(self):
45 | sieve = '''
46 | require ["include", "variables"];
47 |
48 | global;
49 | '''
50 | self.assertTrue(checksieve.parse_string(sieve, True))
51 |
52 | if __name__ == '__main__':
53 | unittest.main()
54 |
--------------------------------------------------------------------------------
/test/6609/return_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class ReturnTest(unittest.TestCase):
5 |
6 | def test_return(self):
7 | sieve = '''
8 | require ["include"];
9 |
10 | return;
11 | '''
12 | self.assertFalse(checksieve.parse_string(sieve, False))
13 |
14 | def test_return_extra_arg(self):
15 | sieve = '''
16 | require ["include"];
17 |
18 | return "foo";
19 | '''
20 | self.assertTrue(checksieve.parse_string(sieve, True))
21 |
22 | if __name__ == '__main__':
23 | unittest.main()
24 |
--------------------------------------------------------------------------------
/test/6785/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/6785/__init__.py
--------------------------------------------------------------------------------
/test/6785/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestExamples(unittest.TestCase):
5 |
6 | def test_example_1(self):
7 | sieve = '''
8 | require ["copy", "environment", "imapsieve"];
9 |
10 | if anyof (environment :is "imap.cause" "APPEND",
11 | environment :is "imap.cause" "COPY") {
12 | if environment :is "imap.mailbox" "ActionItems" {
13 | redirect :copy "actionitems@example.com";
14 | }
15 | }
16 | '''
17 | self.assertFalse(checksieve.parse_string(sieve, False))
18 |
19 | def test_example_2(self):
20 | sieve = '''
21 | require ["enotify", "imap4flags", "variables",
22 | "environment", "imapsieve"];
23 |
24 | if environment :matches "imap.mailbox" "*" {
25 | set "mailbox" "${1}";
26 | }
27 |
28 | if allof (hasflag "\\Flagged",
29 | environment :contains "imap.changedflags" "\\Flagged") {
30 | notify :message "Important message in ${mailbox}"
31 | "xmpp:tim@example.com?message;subject=SIEVE";
32 | }
33 | '''
34 | self.assertFalse(checksieve.parse_string(sieve, False))
35 |
36 |
37 | if __name__ == '__main__':
38 | unittest.main()
39 |
--------------------------------------------------------------------------------
/test/6785/norequire_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestNoRequire(unittest.TestCase):
5 |
6 | def test_no_require(self):
7 | sieve = '''
8 | require ["copy", "environment"];
9 |
10 | if anyof (environment :is "imap.cause" "APPEND",
11 | environment :is "imap.cause" "COPY") {
12 | if environment :is "imap.mailbox" "ActionItems" {
13 | redirect :copy "actionitems@example.com";
14 | }
15 | }
16 | '''
17 | self.assertTrue(checksieve.parse_string(sieve, True))
18 |
19 |
20 | if __name__ == '__main__':
21 | unittest.main()
22 |
--------------------------------------------------------------------------------
/test/7352/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/7352/__init__.py
--------------------------------------------------------------------------------
/test/7352/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestExamples(unittest.TestCase):
5 |
6 | def test_example_1(self):
7 | sieve = '''
8 | require ["duplicate", "fileinto", "mailbox"];
9 |
10 | if duplicate {
11 | fileinto :create "Trash/Duplicate";
12 | }
13 | '''
14 | self.assertFalse(checksieve.parse_string(sieve, False))
15 |
16 | def test_example_2(self):
17 | sieve = '''
18 | require ["duplicate", "variables", "imap4flags", "fileinto"];
19 |
20 | if header :matches "subject" "ALERT: *" {
21 | if duplicate :seconds 60 :uniqueid "${1}" {
22 | setflag "\\seen";
23 | }
24 | fileinto "Alerts";
25 | }
26 | '''
27 | self.assertFalse(checksieve.parse_string(sieve, False))
28 |
29 | def test_example_3(self):
30 | sieve = '''
31 | require ["variables", "envelope", "enotify", "duplicate"];
32 |
33 | if envelope :matches "from" "*" { set "sender" "${1}"; }
34 | if header :matches "subject" "*" { set "subject" "${1}"; }
35 |
36 | if not duplicate :seconds 1800 :uniqueid "${sender}"
37 | {
38 | notify :message "[SIEVE] ${sender}: ${subject}"
39 | "xmpp:user@im.example.com";
40 | }
41 | '''
42 | self.assertFalse(checksieve.parse_string(sieve, False))
43 |
44 | def test_example_4(self):
45 | sieve = '''
46 | require ["variables", "envelope", "enotify", "duplicate"];
47 |
48 | if envelope :matches "from" "*" { set "sender" "${1}"; }
49 | if header :matches "subject" "*" { set "subject" "${1}"; }
50 |
51 | # account for 'Re:' prefix
52 | if string :comparator "i;ascii-casemap"
53 | :matches "${subject}" "Re:*"
54 | {
55 | set "subject" "${1}";
56 | }
57 | if not duplicate :seconds 1800
58 | :uniqueid "${sender} ${subject}"
59 | {
60 | notify :message "[SIEVE] ${sender}: ${subject}"
61 | "xmpp:user@im.example.com";
62 | }
63 | '''
64 | self.assertFalse(checksieve.parse_string(sieve, False))
65 |
66 | def test_example_5(self):
67 | sieve = '''
68 | require ["duplicate", "imap4flags"];
69 |
70 | if duplicate :header "X-Event-ID" :handle "notifier" {
71 | discard;
72 | }
73 | if allof (
74 | duplicate :header "X-Ticket-ID" :handle "support",
75 | address "to" "support@example.com",
76 | header :contains "subject" "fileserver")
77 | {
78 | setflag "\\seen";
79 | }
80 | '''
81 | self.assertFalse(checksieve.parse_string(sieve, False))
82 |
83 |
84 | if __name__ == '__main__':
85 | unittest.main()
86 |
--------------------------------------------------------------------------------
/test/7352/failure_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestFailures(unittest.TestCase):
5 |
6 | def test_failure_1(self):
7 | sieve = '''
8 | require ["duplicate", "fileinto", "mailbox"];
9 |
10 | if duplicate :header "foo" :uniqueid "bar" {
11 | fileinto :create "Trash/Duplicate";
12 | }
13 | '''
14 | self.assertTrue(checksieve.parse_string(sieve, True))
15 |
16 | def test_failure_2(self):
17 | sieve = '''
18 | require ["duplicate", "fileinto", "mailbox"];
19 |
20 | if duplicate :index 2 {
21 | fileinto :create "Trash/Duplicate";
22 | }
23 | '''
24 | self.assertTrue(checksieve.parse_string(sieve, True))
25 |
26 |
27 |
28 | if __name__ == '__main__':
29 | unittest.main()
30 |
--------------------------------------------------------------------------------
/test/8579/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/8579/__init__.py
--------------------------------------------------------------------------------
/test/8579/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestExamples(unittest.TestCase):
5 |
6 | def test_example_1(self):
7 | sieve = '''
8 | require "imapsieve";
9 | require "special-use";
10 | require "environment";
11 | require "variables";
12 |
13 | if environment :contains "imap.mailbox" "*" {
14 | set "mailbox" "${1}";
15 | }
16 |
17 | if allof(
18 | environment "imap.cause" "COPY",
19 | specialuse_exists "${mailbox}" "\\Junk") {
20 | redirect "spam-report@example.org";
21 | }
22 | '''
23 | self.assertFalse(checksieve.parse_string(sieve, False))
24 |
25 | def test_example_2(self):
26 | sieve = '''
27 | require "fileinto";
28 | require "special-use";
29 |
30 | fileinto :specialuse "\\Junk" "Spam";
31 | '''
32 | self.assertFalse(checksieve.parse_string(sieve, False))
33 |
34 | def test_example_3(self):
35 | sieve = '''
36 | require "fileinto";
37 | require "special-use";
38 | require "mailbox";
39 |
40 | fileinto :specialuse "\\Junk" :create "Spam";
41 | '''
42 | self.assertFalse(checksieve.parse_string(sieve, False))
43 |
44 | def test_example_4(self):
45 | sieve = '''
46 | require "special-use";
47 |
48 | if (address :specialuse "foo") {
49 | discard;
50 | }
51 | '''
52 | self.assertTrue(checksieve.parse_string(sieve, True))
53 |
--------------------------------------------------------------------------------
/test/8580/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/8580/__init__.py
--------------------------------------------------------------------------------
/test/8580/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestExamples(unittest.TestCase):
5 |
6 | def test_example_1(self):
7 | sieve = '''
8 | require ["vacation", "fcc", "mailbox", "imap4flags"];
9 |
10 | vacation :days 7
11 | :from "hemingway@example.com" "Gone Fishin'"
12 | :fcc "INBOX.Sent";
13 | '''
14 | self.assertFalse(checksieve.parse_string(sieve, False))
15 |
16 | def test_example_2(self):
17 | sieve = '''
18 |
19 | require ["enotify", "fcc"];
20 |
21 | notify :fcc "INBOX.Sent"
22 | :message "You got mail!"
23 | "mailto:ken@example.com";
24 |
25 | '''
26 | self.assertFalse(checksieve.parse_string(sieve, False))
27 |
28 | def test_example_3(self):
29 | sieve = '''
30 |
31 | require ["enotify", "fcc"];
32 |
33 | if notify_method_capability "xmpp:" "fcc" "yes" {
34 | notify :fcc "INBOX.Sent"
35 | :message "You got mail"
36 | "xmpp:ken@example.com?message;subject=SIEVE";
37 | } else {
38 | notify :fcc "INBOX.Sent"
39 | :message "You got mail!"
40 | "mailto:ken@example.com";
41 | }
42 | '''
43 | self.assertFalse(checksieve.parse_string(sieve, False))
44 |
45 | def test_no_reject(self):
46 | sieve = '''
47 | require ["reject", "fcc"];
48 |
49 | if size :over 100K {
50 | reject :fcc "foo" text:
51 | Your message is too big. If you want to send me a big attachment,
52 | put it on a public web site and send me a URL.
53 | .
54 | ;
55 | }
56 | '''
57 | self.assertTrue(checksieve.parse_string(sieve, True))
--------------------------------------------------------------------------------
/test/9042/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/9042/__init__.py
--------------------------------------------------------------------------------
/test/9042/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class TestExamples(unittest.TestCase):
5 |
6 | def test_example_1(self):
7 | sieve = '''
8 | require "fileinto";
9 | require "mailboxid";
10 |
11 | if header :contains ["from"] "coyote" {
12 | fileinto :mailboxid "F6352ae03-b7f5-463c-896f-d8b48ee3"
13 | "INBOX.harassment";
14 | }
15 | '''
16 | self.assertFalse(checksieve.parse_string(sieve, False))
17 |
18 | def test_example_2(self):
19 | sieve = '''
20 | require "fileinto";
21 | require "mailboxid";
22 | require "mailbox";
23 |
24 | fileinto :mailboxid "Fnosuch"
25 | :create
26 | "INBOX.no-such-folder";
27 | # creates INBOX.no-such-folder, but it doesn't
28 | # get the "Fnosuch" mailboxid.
29 | '''
30 | self.assertFalse(checksieve.parse_string(sieve, False))
31 |
32 | def test_example_3(self):
33 | sieve = '''
34 | require "fileinto";
35 | require "mailboxid";
36 |
37 | if header :contains ["from"] "coyote" {
38 | if mailboxidexists "F6352ae03-b7f5-463c-896f-d8b48ee3" {
39 | fileinto :mailboxid "F6352ae03-b7f5-463c-896f-d8b48ee3"
40 | "INBOX.name.will.not.be.used";
41 | } else {
42 | fileinto "INBOX.harassment";
43 | }
44 | }
45 | '''
46 | self.assertFalse(checksieve.parse_string(sieve, False))
47 |
48 | def test_specialuse_interaction(self):
49 | sieve = '''
50 | require "fileinto";
51 | require "special-use";
52 | require "mailboxid";
53 |
54 | fileinto :mailboxid "blah" :specialuse "\\Junk" "Spam";
55 | '''
56 | self.assertTrue(checksieve.parse_string(sieve, True))
57 |
--------------------------------------------------------------------------------
/test/9671/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/9671/__init__.py
--------------------------------------------------------------------------------
/test/9671/cross_requires_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class CrossRequiresTest(unittest.TestCase):
5 |
6 | def test_extlists_organizers_no(self):
7 | sieve = '''
8 | require [ "processcalendar" ];
9 |
10 | processcalendar :addresses [ "me@example.com", "alsome@example.com" ]
11 | :calendarid "1ea6d86b-6c7f-48a2-bed3-2a4c40ec281a"
12 | :organizers "foo@example.com";
13 | '''
14 | self.assertTrue(checksieve.parse_string(sieve, True))
15 |
16 | def test_extlists_organizers_yes(self):
17 | sieve = '''
18 | require [ "processcalendar", "extlists" ];
19 |
20 | processcalendar :addresses [ "me@example.com", "alsome@example.com" ]
21 | :calendarid "1ea6d86b-6c7f-48a2-bed3-2a4c40ec281a"
22 | :organizers "foo@example.com";
23 | '''
24 | self.assertFalse(checksieve.parse_string(sieve, False))
25 |
26 | def test_variables_outcome_no(self):
27 | sieve = '''
28 | require [ "processcalendar" ];
29 |
30 | processcalendar :addresses [ "me@example.com", "alsome@example.com" ]
31 | :calendarid "1ea6d86b-6c7f-48a2-bed3-2a4c40ec281a"
32 | :outcome "process_outcome";
33 | '''
34 | self.assertTrue(checksieve.parse_string(sieve, True))
35 |
36 | def test_variables_outcome_yes(self):
37 | sieve = '''
38 | require [ "processcalendar", "variables" ];
39 |
40 | processcalendar :addresses [ "me@example.com", "alsome@example.com" ]
41 | :calendarid "1ea6d86b-6c7f-48a2-bed3-2a4c40ec281a"
42 | :outcome "process_outcome";
43 | '''
44 | self.assertFalse(checksieve.parse_string(sieve, False))
45 |
46 | def test_variables_reason_no(self):
47 | sieve = '''
48 | require [ "processcalendar" ];
49 |
50 | processcalendar :addresses [ "me@example.com", "alsome@example.com" ]
51 | :calendarid "1ea6d86b-6c7f-48a2-bed3-2a4c40ec281a"
52 | :reason "process_reason";
53 | '''
54 | self.assertTrue(checksieve.parse_string(sieve, True))
55 |
56 | def test_variables_reason_yes(self):
57 | sieve = '''
58 | require [ "processcalendar", "variables" ];
59 |
60 | processcalendar :addresses [ "me@example.com", "alsome@example.com" ]
61 | :calendarid "1ea6d86b-6c7f-48a2-bed3-2a4c40ec281a"
62 | :reason "process_reason";
63 | '''
64 | self.assertFalse(checksieve.parse_string(sieve, False))
65 |
--------------------------------------------------------------------------------
/test/9671/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 | class ExamplesTest(unittest.TestCase):
5 |
6 | def test_example_01(self):
7 | sieve = '''
8 | require [ "processcalendar" ];
9 |
10 | processcalendar :addresses [ "me@example.com", "alsome@example.com" ]
11 | :calendarid "1ea6d86b-6c7f-48a2-bed3-2a4c40ec281a";
12 | '''
13 | self.assertFalse(checksieve.parse_string(sieve, False))
14 |
15 | def test_example_02(self):
16 | sieve = '''
17 | require [ "processcalendar" ];
18 |
19 | if allof (address ["from", "sender"] "airline@example.com",
20 | header :contains "subject" "itinerary") {
21 | processcalendar :allowpublic;
22 | }
23 | '''
24 | self.assertFalse(checksieve.parse_string(sieve, False))
25 |
26 | def test_example_03(self):
27 | sieve = '''
28 | require [ "processcalendar", "variables", "editheader" ];
29 |
30 | set "processcal_outcome" "no_action";
31 | set "processcal_reason" "";
32 |
33 | processcalendar :outcome "processcal_outcome"
34 | :reason "processcal_reason";
35 |
36 | if not string :is "${processcal_outcome}" ["added", "updated"] {
37 | addheader "X-ProcessCal-Outcome" "${processcal_outcome}";
38 | addheader "X-ProcessCal-Reason" "${processcal_reason}";
39 | }
40 | '''
41 | self.assertFalse(checksieve.parse_string(sieve, False))
--------------------------------------------------------------------------------
/test/AST/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/AST/__init__.py
--------------------------------------------------------------------------------
/test/AST/commands_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 | from . import util
4 |
5 | class TestCommandsAST(util.DiffTestCase):
6 |
7 | def test_require(self):
8 | self.assertNoDiff(util.diff(util.run_mock('commands/require_single.sieve'), 'commands/require_single.out'))
9 |
10 | def test_require_list(self):
11 | self.assertNoDiff(util.diff(util.run_mock('commands/require_list.sieve'), 'commands/require_list.out'))
12 |
13 | def test_stop(self):
14 | self.assertNoDiff(util.diff(util.run_mock('commands/stop.sieve'), 'commands/stop.out'))
15 |
16 |
17 | if __name__ == '__main__':
18 | unittest.main()
19 |
--------------------------------------------------------------------------------
/test/AST/control_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 | from . import util
4 |
5 | class TestControlAST(util.DiffTestCase):
6 |
7 | def test_simple_if(self):
8 | self.assertNoDiff(util.diff(util.run_mock('control/if_1.sieve'), 'control/if_1.out'))
9 |
10 | def test_if_else(self):
11 | self.assertNoDiff(util.diff(util.run_mock('control/if_2.sieve'), 'control/if_2.out'))
12 |
13 | def test_if_elsif_else(self):
14 | self.assertNoDiff(util.diff(util.run_mock('control/if_3.sieve'), 'control/if_3.out'))
15 |
16 |
17 | if __name__ == '__main__':
18 | unittest.main()
19 |
--------------------------------------------------------------------------------
/test/AST/mock/commands/require_list.out:
--------------------------------------------------------------------------------
1 | Mail Sieve
2 | Require
3 | String List
4 | String ("fileinto")
5 | String ("imap4flags")
6 |
--------------------------------------------------------------------------------
/test/AST/mock/commands/require_list.sieve:
--------------------------------------------------------------------------------
1 | require ["fileinto", "imap4flags"];
2 |
--------------------------------------------------------------------------------
/test/AST/mock/commands/require_single.out:
--------------------------------------------------------------------------------
1 | Mail Sieve
2 | Require
3 | String ("fileinto")
4 |
--------------------------------------------------------------------------------
/test/AST/mock/commands/require_single.sieve:
--------------------------------------------------------------------------------
1 | require "fileinto";
2 |
--------------------------------------------------------------------------------
/test/AST/mock/commands/stop.out:
--------------------------------------------------------------------------------
1 | Mail Sieve
2 | Command (stop)
3 |
--------------------------------------------------------------------------------
/test/AST/mock/commands/stop.sieve:
--------------------------------------------------------------------------------
1 | stop;
--------------------------------------------------------------------------------
/test/AST/mock/control/if_1.out:
--------------------------------------------------------------------------------
1 | Mail Sieve
2 | Branch
3 | Condition
4 | True
5 | Block
6 | Command (keep)
7 | Command (stop)
8 |
--------------------------------------------------------------------------------
/test/AST/mock/control/if_1.sieve:
--------------------------------------------------------------------------------
1 | if true {
2 | keep;
3 | stop;
4 | }
--------------------------------------------------------------------------------
/test/AST/mock/control/if_2.out:
--------------------------------------------------------------------------------
1 | Mail Sieve
2 | Branch
3 | Condition
4 | True
5 | Block
6 | Command (keep)
7 | Command (stop)
8 | Block
9 | Command (stop)
10 |
--------------------------------------------------------------------------------
/test/AST/mock/control/if_2.sieve:
--------------------------------------------------------------------------------
1 | if true {
2 | keep;
3 | stop;
4 | } else {
5 | stop;
6 | }
--------------------------------------------------------------------------------
/test/AST/mock/control/if_3.out:
--------------------------------------------------------------------------------
1 | Mail Sieve
2 | Require
3 | String ("fileinto")
4 | Branch
5 | Condition
6 | True
7 | Block
8 | Command (keep)
9 | Command (stop)
10 | Condition
11 | False
12 | Block
13 | Command (fileinto)
14 | String ("\\Seen")
15 | Command (stop)
16 | Block
17 | Command (stop)
18 |
--------------------------------------------------------------------------------
/test/AST/mock/control/if_3.sieve:
--------------------------------------------------------------------------------
1 | require "fileinto";
2 |
3 | if true {
4 | keep;
5 | stop;
6 | } elsif false {
7 | fileinto "\\Seen";
8 | stop;
9 | } else {
10 | stop;
11 | }
--------------------------------------------------------------------------------
/test/AST/util.py:
--------------------------------------------------------------------------------
1 | import os
2 | import subprocess
3 | import unittest
4 | from tempfile import NamedTemporaryFile
5 |
6 |
7 | class DiffTestCase(unittest.TestCase):
8 | def assertNoDiff(self, diff):
9 | self.assertFalse(diff, msg='\n{}'.format(diff))
10 |
11 |
12 | def run_mock(filename):
13 | current_dir = os.path.dirname(os.path.realpath(__file__))
14 | test_path = os.path.join(current_dir, 'mock', filename)
15 | check_sieve_path = os.path.join(current_dir, '../..', 'check-sieve')
16 |
17 | return subprocess.check_output([check_sieve_path, '--trace-tree', test_path])
18 |
19 | def diff(output, filename):
20 | current_dir = os.path.dirname(os.path.realpath(__file__))
21 | out_path = os.path.join(current_dir, 'mock', filename)
22 | check_sieve_path = os.path.join(current_dir, '../..', 'check-sieve')
23 |
24 | diff = False
25 |
26 | temp = NamedTemporaryFile(delete=False)
27 | temp.write(output)
28 | temp.close()
29 |
30 | diff = subprocess.Popen(["/usr/bin/diff", "-ru", temp.name, out_path], stdout=subprocess.PIPE).communicate()[0]
31 |
32 | return diff
33 |
--------------------------------------------------------------------------------
/test/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/__init__.py
--------------------------------------------------------------------------------
/test/drafts/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/drafts/__init__.py
--------------------------------------------------------------------------------
/test/drafts/regex/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/drafts/regex/__init__.py
--------------------------------------------------------------------------------
/test/drafts/regex/tag_test.py:
--------------------------------------------------------------------------------
1 | import sys
2 | sys.path.append('./')
3 |
4 | import unittest
5 | import checksieve
6 |
7 | class TestIndex(unittest.TestCase):
8 |
9 | def test_regex(self):
10 | sieve = '''
11 | require ["fileinto", "regex", "variables"];
12 |
13 | if header :regex "List-ID" "<(.*)@" {
14 | fileinto "lists.${1}"; stop;
15 | }
16 |
17 | # Imagine the header
18 | # Subject: [acme-users] [fwd] version 1.0 is out
19 | if header :regex "Subject" "^[(.*)] (.*)$" {
20 | # ${1} will hold "acme-users] [fwd"
21 | stop;
22 | }
23 | '''
24 | self.assertFalse(checksieve.parse_string(sieve, False))
25 |
26 | def test_regex_no_require(self):
27 | sieve = '''
28 | require ["fileinto", "variables"];
29 |
30 | if header :regex "List-ID" "<(.*)@" {
31 | fileinto "lists.${1}"; stop;
32 | }
33 |
34 | # Imagine the header
35 | # Subject: [acme-users] [fwd] version 1.0 is out
36 | if header :regex "Subject" "^[(.*)] (.*)$" {
37 | # ${1} will hold "acme-users] [fwd"
38 | stop;
39 | }
40 | '''
41 | self.assertTrue(checksieve.parse_string(sieve, True))
42 |
43 | def test_regex_2(self):
44 | sieve = '''
45 | require "regex";
46 |
47 | # Try to catch unsolicited email.
48 | if anyof (
49 | # if a message is not to me (with optional +detail),
50 | not address :regex ["to", "cc", "bcc"]
51 | "me(\\\\+.*)?@company\\\\.com",
52 |
53 | # or the subject is all uppercase (no lowercase)
54 | header :regex :comparator "i;octet" "subject"
55 | "^[^[:lower:]]+$" ) {
56 |
57 | discard; # junk it
58 | }
59 | '''
60 | self.assertFalse(checksieve.parse_string(sieve, False))
61 |
62 | def test_quoteregex(self):
63 | sieve = '''
64 | require ["regex", "variables"];
65 | set :quoteregex "b" "[a-zA-Z]*";
66 | '''
67 | self.assertFalse(checksieve.parse_string(sieve, False))
68 |
69 | def test_quoteregex_no_require(self):
70 | sieve = '''
71 | require ["variables"];
72 | set :quoteregex "b" "[a-zA-Z]*";
73 | '''
74 | self.assertTrue(checksieve.parse_string(sieve, True))
75 |
76 | if __name__ == '__main__':
77 | unittest.main()
78 |
--------------------------------------------------------------------------------
/test/other/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/other/__init__.py
--------------------------------------------------------------------------------
/test/other/options_test.py:
--------------------------------------------------------------------------------
1 | import sys
2 | sys.path.append('./')
3 |
4 | import unittest
5 | import checksieve
6 |
7 | class OptionsTest(unittest.TestCase):
8 |
9 | def test_max_list_length(self):
10 | sieve = '''
11 | require ["include", "variables"];
12 |
13 | global "test";
14 | '''
15 | self.assertFalse(checksieve.parse_string_with_options(sieve, {"string_list_max_length": 2}))
16 |
17 | def test_max_list_length(self):
18 | sieve = '''
19 | require ["include", "variables", "imap4flags"];
20 |
21 | global "test";
22 | '''
23 | self.assertTrue(checksieve.parse_string_with_options(sieve, {"string_list_max_length": 2}))
24 |
25 | if __name__ == '__main__':
26 | unittest.main()
27 |
--------------------------------------------------------------------------------
/test/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import Extension, setup
2 |
3 | module = Extension('checksieve',
4 | extra_compile_args = ['-std=c++17'],
5 | sources = ['src/python.cc'],
6 | include_dirs = ['src', 'src/AST', 'gen'],
7 | libraries = ['checksieve'],
8 | library_dirs = ['./'] );
9 |
10 | setup (name = 'CheckSieve',
11 | version = '0.11-dev',
12 | description = 'Python interface to libchecksieve',
13 | author = 'Dana Burkart',
14 | author_email = 'dana.burkart@gmail.com',
15 | ext_modules = [module] );
16 |
--------------------------------------------------------------------------------
/test/vendor/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/vendor/__init__.py
--------------------------------------------------------------------------------
/test/vendor/dovecot/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/vendor/dovecot/__init__.py
--------------------------------------------------------------------------------
/test/vendor/dovecot/examples_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 |
5 | class TestExamples(unittest.TestCase):
6 | def test_pipe_01(self):
7 | sieve = '''
8 | require [ "vnd.dovecot.pipe", "subaddress", "envelope" ];
9 |
10 | if envelope :detail "to" "request"
11 | {
12 | pipe "request-handler";
13 | }
14 |
15 | '''
16 | self.assertFalse(checksieve.parse_string(sieve, False))
17 |
18 | def test_pipe_02(self):
19 | sieve = '''require [ "vnd.dovecot.pipe", "copy" ];
20 |
21 | if address "to" "snailmail@example.com"
22 | {
23 | pipe :copy "printer" ["A4", "draft"];
24 | }'''
25 | self.assertFalse(checksieve.parse_string(sieve, False))
26 |
27 | def test_filter_01(self):
28 | sieve = '''require [ "vnd.dovecot.filter", "fileinto" ];
29 |
30 | if header "content-language" "nl"
31 | {
32 | filter "translator" ["nl", "en"];
33 | fileinto "Translated";
34 | stop;
35 | }'''
36 | self.assertFalse(checksieve.parse_string(sieve, False))
37 |
38 | def test_filter_02(self):
39 | sieve = '''require [ "vnd.dovecot.filter", "fileinto" ];
40 |
41 | if header "content-language" "nl"
42 | {
43 | if filter "translator" ["nl", "en"]
44 | {
45 | fileinto "Translated";
46 | stop;
47 | }
48 | }'''
49 | self.assertFalse(checksieve.parse_string(sieve, False))
50 |
51 | def test_execute_01(self):
52 | sieve = '''require [ "vnd.dovecot.execute", "vacation", "variables",
53 | "envelope" ];
54 |
55 | if envelope :localpart :matches "to" "*"
56 | {
57 | set "recipient" "${1}";
58 | }
59 |
60 | if execute :output "vacation_message" "onvacation" "${recipient}"
61 | {
62 | vacation "${vacation_message}";
63 | }'''
64 | self.assertFalse(checksieve.parse_string(sieve, False))
65 |
66 | if __name__ == '__main__':
67 | unittest.main()
68 |
--------------------------------------------------------------------------------
/test/vendor/proton/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dburkart/check-sieve/6fef71e4d5b983d3ee6955c627aa3b5f738b195d/test/vendor/proton/__init__.py
--------------------------------------------------------------------------------
/test/vendor/proton/eval_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 |
5 | class TestProtonEval(unittest.TestCase):
6 | def test_eval(self):
7 | sieve = '''
8 | require "variables";
9 | require "fileinto";
10 | require "vnd.proton.eval";
11 | # do a match test on the sender address
12 | if header :matches "from" "*" {
13 | # create a variable called length, containing the length of the first
14 | # matching variable
15 | set :length "length" "${1}";
16 | # Create a variable called fileintovar containing the result of the expression written below
17 | set :eval "fileintovar" "${length} * 25 - 1 / 8+3";
18 | fileinto "${fileintovar}";
19 | }
20 | '''
21 | self.assertFalse(checksieve.parse_string(sieve, False))
22 |
23 | def test_eval_no_require(self):
24 | sieve = '''
25 | require "variables";
26 | require "fileinto";
27 | # do a match test on the sender address
28 | if header :matches "from" "*" {
29 | # create a variable called length, containing the length of the first
30 | # matching variable
31 | set :length "length" "${1}";
32 | # Create a variable called fileintovar containing the result of the expression written below
33 | set :eval "fileintovar" "${length} * 25 - 1 / 8+3";
34 | fileinto "${fileintovar}";
35 | }
36 | '''
37 | self.assertTrue(checksieve.parse_string(sieve, True))
38 |
39 | def test_eval_no_variables_require(self):
40 | sieve = '''
41 | require "fileinto";
42 | require "vnd.proton.eval";
43 | # do a match test on the sender address
44 | if header :matches "from" "*" {
45 | # create a variable called length, containing the length of the first
46 | # matching variable
47 | set :length "length" "${1}";
48 | # Create a variable called fileintovar containing the result of the expression written below
49 | set :eval "fileintovar" "${length} * 25 - 1 / 8+3";
50 | fileinto "${fileintovar}";
51 | }
52 | '''
53 | self.assertTrue(checksieve.parse_string(sieve, True))
54 |
55 |
56 | if __name__ == '__main__':
57 | unittest.main()
58 |
--------------------------------------------------------------------------------
/test/vendor/proton/expire_test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import checksieve
3 |
4 |
5 | class TestProtonExpire(unittest.TestCase):
6 | def test_expire(self):
7 | sieve = '''
8 | require "vnd.proton.expire";
9 | # permanently delete all incoming and outgoing emails after 10 days
10 | expire "day" "10";
11 | '''
12 | self.assertFalse(checksieve.parse_string(sieve, False))
13 |
14 | def test_expire_no_require(self):
15 | sieve = '''
16 | # permanently delete all incoming and outgoing emails after 10 days
17 | expire "day" "10";
18 | '''
19 | self.assertTrue(checksieve.parse_string(sieve, True))
20 |
21 | def test_hasexpiration(self):
22 | sieve = '''
23 | require "vnd.proton.expire";
24 |
25 | if hasexpiration {
26 | stop;
27 | }
28 | '''
29 | self.assertFalse(checksieve.parse_string(sieve, False))
30 |
31 | def test_hasexpiration_no_require(self):
32 | sieve = '''
33 | if hasexpiration {
34 | stop;
35 | }
36 | '''
37 | self.assertTrue(checksieve.parse_string(sieve, True))
38 |
39 | def test_expiration(self):
40 | sieve = '''
41 | require "comparator-i;ascii-numeric";
42 | require "vnd.proton.expire";
43 |
44 | if expiration :comparator "i;ascii-numeric" "ge" "day" "5" {
45 | stop;
46 | }
47 | '''
48 | self.assertFalse(checksieve.parse_string(sieve, False))
49 |
50 |
51 | if __name__ == '__main__':
52 | unittest.main()
53 |
--------------------------------------------------------------------------------