diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
commit | f7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch) | |
tree | a3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /pigeonhole/tests/compile/errors | |
parent | Initial commit. (diff) | |
download | dovecot-upstream.tar.xz dovecot-upstream.zip |
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pigeonhole/tests/compile/errors')
19 files changed, 725 insertions, 0 deletions
diff --git a/pigeonhole/tests/compile/errors/address-part.sieve b/pigeonhole/tests/compile/errors/address-part.sieve new file mode 100644 index 0000000..1d10cbf --- /dev/null +++ b/pigeonhole/tests/compile/errors/address-part.sieve @@ -0,0 +1,17 @@ +/* + * Address part errors + * + * Total errors: 2 (+1 = 3) + */ + +# Duplicate address part (1) +if address :all :comparator "i;octet" :domain "from" "STEPHAN" { + + # Duplicate address part (2) + if address :domain :localpart :comparator "i;octet" "from" "friep.example.com" { + keep; + } + + stop; +} + diff --git a/pigeonhole/tests/compile/errors/address.sieve b/pigeonhole/tests/compile/errors/address.sieve new file mode 100644 index 0000000..f7d3b26 --- /dev/null +++ b/pigeonhole/tests/compile/errors/address.sieve @@ -0,0 +1,71 @@ +require "comparator-i;ascii-numeric"; + +/* + * Address test errors + * + * Total count: 8 (+1 = 9) + */ + +/* + * Command structure + */ + +# Invalid tag +if address :nonsense :comparator "i;ascii-casemap" :localpart "From" "nico" { + discard; +} + +# Invalid first argument +if address :is :comparator "i;ascii-numeric" :localpart 45 "nico" { + discard; +} + +# Invalid second argument +if address :is :comparator "i;ascii-numeric" :localpart "From" 45 { + discard; +} + +# Invalid second argument +if address :comparator "i;ascii-numeric" :localpart "From" :is { + discard; +} + +# Missing second argument +if address :is :comparator "i;ascii-numeric" :localpart "From" { + discard; +} + +# Missing arguments +if address :is :comparator "i;ascii-numeric" :localpart { + discard; +} + +# Not an error +if address :localpart :is :comparator "i;ascii-casemap" "from" ["frop", "frop"] { + discard; +} + +/* + * Specified headers must contain addresses + */ + +# Invalid header +if address :is "frop" "frml" { + keep; +} + +# Not an error +if address :is "reply-to" "frml" { + keep; +} + +# Invalid header (#2) +if address :is ["to", "frop"] "frml" { + keep; +} + +# Not an error +if address :is ["to", "reply-to"] "frml" { + keep; +} + diff --git a/pigeonhole/tests/compile/errors/comparator.sieve b/pigeonhole/tests/compile/errors/comparator.sieve new file mode 100644 index 0000000..368b56b --- /dev/null +++ b/pigeonhole/tests/compile/errors/comparator.sieve @@ -0,0 +1,21 @@ +/* + * Address part errors + * + * Total errors: 5 (+1 = 6) + */ + +# 1: No argument +if address :comparator { } + +# 2: Number argument +if address :comparator 1 "from" "frop" { } + +# 3: String list argument +if address :comparator ["a", "b"] "from" "frop" { } + +# 4: Unknown tag +if address :comparator :frop "from" "frop" { } + +# 5: Known tag +if address :comparator :all "from" "frop" { } + diff --git a/pigeonhole/tests/compile/errors/encoded-character.sieve b/pigeonhole/tests/compile/errors/encoded-character.sieve new file mode 100644 index 0000000..04d9de4 --- /dev/null +++ b/pigeonhole/tests/compile/errors/encoded-character.sieve @@ -0,0 +1,23 @@ +/* + * Encoded-character errors + * + * Total errors: 2 (+1 = 3) + */ + +require "encoded-character"; +require "fileinto"; + +# Invalid unicode character (1) +fileinto "INBOX.${unicode:200000}"; + +# Not an error +fileinto "INBOX.${unicode:200000"; + +# Invalid unicode character (2) +fileinto "INBOX.${Unicode:DF01}"; + +# Not an error +fileinto "INBOX.${Unicode:DF01"; + + + diff --git a/pigeonhole/tests/compile/errors/envelope.sieve b/pigeonhole/tests/compile/errors/envelope.sieve new file mode 100644 index 0000000..9639846 --- /dev/null +++ b/pigeonhole/tests/compile/errors/envelope.sieve @@ -0,0 +1,23 @@ +/* + * Envelope test errors + * + * Total errors: 2 (+1 = 3) + */ + +require "envelope"; + +# Not an error +if envelope :is "to" "frop@example.org" { +} + +# Unknown envelope part (1) +if envelope :is "frop" "frop@example.org" { +} + +# Not an error +if envelope :is ["to","from"] "frop@example.org" { +} + +# Unknown envelope part (2) +if envelope :is ["to","frop"] "frop@example.org" { +} diff --git a/pigeonhole/tests/compile/errors/fileinto.sieve b/pigeonhole/tests/compile/errors/fileinto.sieve new file mode 100644 index 0000000..0598557 --- /dev/null +++ b/pigeonhole/tests/compile/errors/fileinto.sieve @@ -0,0 +1,38 @@ +require "fileinto"; +require "encoded-character"; + +/* + * Fileinto errors + * + * Total erors: 9 (+1 = 10) + */ + +# Missing string argument +fileinto; + +# Spurious test +fileinto true; + +# Spurious test +fileinto "Frop" true; + +# Spurious number argument +fileinto 33; + +# Spurious tag argument +fileinto :frop; + +# Spurious additional string argument +fileinto "Frop" "Friep"; + +# Spurious additional number argument +fileinto "Frop" 123; + +# Spurious additional tag argument +fileinto "Frop" :frop; + +# Bad mailbox name +fileinto "${hex:ff}rop"; + +# Not an error +fileinto "Frop"; diff --git a/pigeonhole/tests/compile/errors/header.sieve b/pigeonhole/tests/compile/errors/header.sieve new file mode 100644 index 0000000..1c87f94 --- /dev/null +++ b/pigeonhole/tests/compile/errors/header.sieve @@ -0,0 +1,57 @@ +require "comparator-i;ascii-numeric"; + +/* + * Compile errors for the header test + * + * Total errors: 9 (+1 validation failed msg = 10) + */ + +# Unknown tagged argument +if header :all :comparator "i;ascii-casemap" "From" "nico" { + keep; +} + +# Wrong first argument +if header :is :comparator "i;ascii-numeric" 45 "nico" { + keep; +} + +# Wrong second argument +if header :is :comparator "i;ascii-numeric" "From" 45 { + discard; +} + +# Wrong second argument +if header :is :comparator "i;ascii-numeric" "From" :tag { + stop; +} + +# Missing second argument +if header :is :comparator "i;ascii-numeric" "From" { + stop; +} + +# Missing arguments +if header :is :comparator "i;ascii-numeric" { + keep; +} + +# Not an error +if header :is :comparator "i;ascii-casemap" "frop" ["frop", "frop"] { + discard; +} + +# Spurious sub-test +if header "frop" "frop" true { + discard; +} + +# Test used as command with block +header "frop" "frop" { + discard; +} + +# Test used as command +header "frop" "frop"; + + diff --git a/pigeonhole/tests/compile/errors/if.sieve b/pigeonhole/tests/compile/errors/if.sieve new file mode 100644 index 0000000..6a8537b --- /dev/null +++ b/pigeonhole/tests/compile/errors/if.sieve @@ -0,0 +1,78 @@ +/* + * If command errors + * + * Total errors: 11 (+1 = 12) + */ + +# Spurious argument +if "frop" true {} + +# Spurious argument +elsif "frop" true {} + +# Spurious string list +if [ "false", "false", "false" ] false { + stop; +} + +# No block +if true; + +# No test +if { + keep; +} + +# Spurious test list +if ( false, false, true ) { + keep; +} + +stop; + +# If-less else +else { + keep; +} + +# Not an error +if true { + keep; +} + +stop; + +# If-less if structure (should produce only one error) +elsif true { + keep; +} +elsif true { + keep; +} +else { +} + +# Elsif after else +if true { + keep; +} else { + stop; +} elsif true { + stop; +} + +# If used as test +if if true { +} + +# Else if instead of elsif + +if true { + stop; +} else if false { + keep; +} + + + + diff --git a/pigeonhole/tests/compile/errors/keep.sieve b/pigeonhole/tests/compile/errors/keep.sieve new file mode 100644 index 0000000..7b3397c --- /dev/null +++ b/pigeonhole/tests/compile/errors/keep.sieve @@ -0,0 +1,14 @@ +/* + * Keep errors + * + * Total erors: 2 (+1 = 3) + */ + +# Spurious string argument +keep "frop"; + +# Spurious test +keep true; + +# Not an error +keep; diff --git a/pigeonhole/tests/compile/errors/lexer.sieve b/pigeonhole/tests/compile/errors/lexer.sieve new file mode 100644 index 0000000..9675db1 --- /dev/null +++ b/pigeonhole/tests/compile/errors/lexer.sieve @@ -0,0 +1,68 @@ +/* + * Lexer tests + * + * Total errors: 8 (+1 = 9) + */ + +/* + * Number limits + */ + +# 1: Number too large +if size :under 18446744073709551617 { + stop; +} + +# 2: Number too large +if size :under 18446744073709551616 { + stop; +} + +# 3: Number too large +if size :over 180143985094819840k { + stop; +} + +# 4: Number too large +if size :over 1006622342342296M { + stop; +} + +# 5: Number too large +if size :over 34359738368G { + stop; +} + +# 6: Number far too large +if size :over 49834598293485814273947921734981723971293741923 { + stop; +} + +# Not an error +if size :under 18446744073709551615 { + stop; +} + +# Not an error +if size :under 18446744073709551614 { + stop; +} + +# Not an error +if size :under 800G { + stop; +} + +/* + * Identifier limits + */ + +# 7: Identifier too long +if this_is_a_rediculously_long_test_name { + stop; +} + +# 8: Identifier way too long +if test :this_is_an_even_more_rediculously_long_tagged_argument_name { + stop; +} diff --git a/pigeonhole/tests/compile/errors/match-type.sieve b/pigeonhole/tests/compile/errors/match-type.sieve new file mode 100644 index 0000000..d8e1681 --- /dev/null +++ b/pigeonhole/tests/compile/errors/match-type.sieve @@ -0,0 +1,7 @@ +require "comparator-i;ascii-numeric"; + +if header :contains :comparator "i;ascii-numeric" "from" "friep.example.com" { + keep; +} + +keep; diff --git a/pigeonhole/tests/compile/errors/out-address.sieve b/pigeonhole/tests/compile/errors/out-address.sieve new file mode 100644 index 0000000..3e39599 --- /dev/null +++ b/pigeonhole/tests/compile/errors/out-address.sieve @@ -0,0 +1,33 @@ +require "vacation"; + +# Error + +redirect "@wrong.example.com"; +redirect "error"; +redirect "error@"; +redirect "Stephan Bosch error@example.org"; +redirect "Stephan Bosch <error@example.org"; +redirect " more error @ example.com "; +redirect "@"; +redirect "<>"; +redirect "Error <"; +redirect "Error <stephan"; +redirect "Error <stephan@"; +redirect "stephan@example.org,tss@example.net"; +redirect "stephan@example.org,%&^&!!~"; +redirect "rĂ¼diger@example.com"; + +vacation :from "Error" "Ik ben er niet."; + +# Ok + +redirect "Ok Good <stephan@example.org>"; +redirect "ok@example.com"; +redirect " more @ example.com "; + +redirect ".japanese@example.com"; +redirect "japanese.@example.com"; +redirect "japanese...localpart@example.com"; +redirect "..japanese...localpart..@example.com"; + +vacation :from "good@voorbeeld.nl.example.com" "Ik ben weg!"; diff --git a/pigeonhole/tests/compile/errors/parser.sieve b/pigeonhole/tests/compile/errors/parser.sieve new file mode 100644 index 0000000..26a1e53 --- /dev/null +++ b/pigeonhole/tests/compile/errors/parser.sieve @@ -0,0 +1,78 @@ +/* + * Parser errors + * + * Total errors: 8 (+1 = 9) + */ + +# Too many arguments (1) +frop :this "is" "a" 2 :long "argument" "list" :and :it :should "fail" :during "parsing" :but "it" "should" "be" + "recoverable" "." :this "is" "a" 2 :long "argument" "list" :and :it :should "fail" :during "parsing" :but + "it" "should" "be" "recoverable" { + stop; +} + +# Garbage argument (2) +friep $$$; + +# Deep block nesting (1) +if true { if true { if true { if true { if true { if true { if true { if true { + if true { if true { if true { if true { if true { if true { if true { if true { + if true { if true { if true { if true { if true { if true { if true { if true { + if true { if true { if true { if true { if true { if true { if true { if true { + if true { if true { if true { if true { if true { if true { if true { if true { + stop; + } } } } } } } } + } } } } } } } } + } } } } } } } } + } } } } } } } } +} } } } } } } } + +# Deepest block and too deep test (list) nesting (1) +if true { if true { if true { if true { if true { if true { if true { if true { + if true { if true { if true { if true { if true { if true { if true { if true { + if true { if true { if true { if true { if true { if true { if true { if true { + if true { if true { if true { if true { if true { if true { + if + anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( + anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( + anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( + anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( + anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( anyof ( + true + )))))))) + )))))))) + )))))))) + )))))))) + )))))))) + { + stop; + } + } } } } } } + } } } } } } } } + } } } } } } } } +} } } } } } } } + +# Deepest block and too deep test nesting (1) +if true { if true { if true { if true { if true { if true { if true { if true { + if true { if true { if true { if true { if true { if true { if true { if true { + if true { if true { if true { if true { if true { if true { if true { if true { + if true { if true { if true { if true { if true { if true { + if + not not not not not not not not + not not not not not not not not + not not not not not not not not + not not not not not not not not + not not not not not not not not false + { + stop; + } + } } } } } } + } } } } } } } } + } } } } } } } } +} } } } } } } } + + +# Garbage command; test wether previous errors were resolved (2) +frop $$$$; + + diff --git a/pigeonhole/tests/compile/errors/require.sieve b/pigeonhole/tests/compile/errors/require.sieve new file mode 100644 index 0000000..ecbd7a2 --- /dev/null +++ b/pigeonhole/tests/compile/errors/require.sieve @@ -0,0 +1,42 @@ +/* + * Require errors + * + * Total errors: 11 (+1 = 12) + */ + +# Not an error +require "fileinto"; + +# Missing argument +require; + +# Too many arguments +require "fileinto" "vacation"; + +# Invalid argument +require 45; + +# Invalid extensions (3 errors) +require ["_frop", "_friep", "_frml"]; + +# Core commands required +require ["redirect", "keep", "discard"]; + +# Invalid arguments +require "dovecot.test" true; + +# Invalid extension +require "_frop"; + +# Spurious command block +require "fileinto" { + keep; +} + +# Nested require +if true { + require "relional"; +} + +# Require after other command than require +require "copy"; diff --git a/pigeonhole/tests/compile/errors/size.sieve b/pigeonhole/tests/compile/errors/size.sieve new file mode 100644 index 0000000..14dbee5 --- /dev/null +++ b/pigeonhole/tests/compile/errors/size.sieve @@ -0,0 +1,47 @@ +/* + * Size test errors + * + * Total errors: 6 (+1 = 7) + */ + +# Used as command (1) +size :under 23; + +# Missing argument (2) +if size { +} + +# Missing :over/:under (3) +if size 45 { + discard; +} + +# No error +if size :over 34K { + stop; +} + +# No error +if size :under 34M { + stop; +} + +# Conflicting tags (4) +if size :under :over 34 { + keep; +} + +# Duplicate tags (5) +if size :over :over 45M { + stop; +} + +# Wrong argument order (6) +if size 34M :over { + stop; +} + +# No error; but worthy of a warning +if size :under 0 { + stop; +} diff --git a/pigeonhole/tests/compile/errors/stop.sieve b/pigeonhole/tests/compile/errors/stop.sieve new file mode 100644 index 0000000..75a3d76 --- /dev/null +++ b/pigeonhole/tests/compile/errors/stop.sieve @@ -0,0 +1,33 @@ +/* + * Stop command errors + * + * Total errors: 7 (+1 = 8) + */ + +# Spurious string argument +stop "frop"; + +# Spurious number argument +stop 13; + +# Spurious string list argument +stop [ "frop", "frop" ]; + +# Spurious test +stop true; + +# Spurious test list +stop ( true, false ); + +# Spurious command block +stop { + keep; +} + +# Spurious argument and test +stop "frop" true { + stop; +} + +# Not an error +stop; diff --git a/pigeonhole/tests/compile/errors/tag.sieve b/pigeonhole/tests/compile/errors/tag.sieve new file mode 100644 index 0000000..7fa65e9 --- /dev/null +++ b/pigeonhole/tests/compile/errors/tag.sieve @@ -0,0 +1,16 @@ +/* + * Tag errors + * + * Total errors: 2 (+1 = 3) + */ + +# Unknown tag (1) +if envelope :isnot :comparator "i;ascii-casemap" :localpart "From" "nico" { + discard; +} + +# Spurious tag (1) +if true :comparator "i;ascii-numeric" { + keep; +} + diff --git a/pigeonhole/tests/compile/errors/typos.sieve b/pigeonhole/tests/compile/errors/typos.sieve new file mode 100644 index 0000000..3d65b26 --- /dev/null +++ b/pigeonhole/tests/compile/errors/typos.sieve @@ -0,0 +1,29 @@ +/* + * This test is primarily meant to check the compiler's handling of typos + * at various locations. + */ + +require "fileinto"; + +/* + * Missing semicolon + */ + +fileinto "frop" +keep; + +/* Other situations */ + +fileinto "frup" +true; + +fileinto "friep" +snot; + +/* + * Forgot tag colon + */ + +if address matches "from" "*frop*" { + stop; +} diff --git a/pigeonhole/tests/compile/errors/unsupported.sieve b/pigeonhole/tests/compile/errors/unsupported.sieve new file mode 100644 index 0000000..9943f7b --- /dev/null +++ b/pigeonhole/tests/compile/errors/unsupported.sieve @@ -0,0 +1,30 @@ +/* + * Handling of unsupported language features. + * + * Total errors: 3 (+1 = 4) + */ + +require "variables"; +require "include"; +require "regex"; + +/* + * Unsupported use of variables + */ + +/* Comparator argument */ + +set "comp" "i;ascii-numeric"; + +if address :comparator "${comp}" "from" "stephan@example.org" { + stop; +} + +/* Included script */ + +set "script" "blacklist"; + +include "${blacklist}"; + + + |