From f7548d6d28c313cf80e6f3ef89aed16a19815df1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:51:24 +0200 Subject: Adding upstream version 1:2.3.19.1+dfsg1. Signed-off-by: Daniel Baumann --- pigeonhole/tests/compile/compile.svtest | 16 + pigeonhole/tests/compile/errors.svtest | 395 +++++++++++++++++++++ pigeonhole/tests/compile/errors/address-part.sieve | 17 + pigeonhole/tests/compile/errors/address.sieve | 71 ++++ pigeonhole/tests/compile/errors/comparator.sieve | 21 ++ .../tests/compile/errors/encoded-character.sieve | 23 ++ pigeonhole/tests/compile/errors/envelope.sieve | 23 ++ pigeonhole/tests/compile/errors/fileinto.sieve | 38 ++ pigeonhole/tests/compile/errors/header.sieve | 57 +++ pigeonhole/tests/compile/errors/if.sieve | 78 ++++ pigeonhole/tests/compile/errors/keep.sieve | 14 + pigeonhole/tests/compile/errors/lexer.sieve | 68 ++++ pigeonhole/tests/compile/errors/match-type.sieve | 7 + pigeonhole/tests/compile/errors/out-address.sieve | 33 ++ pigeonhole/tests/compile/errors/parser.sieve | 78 ++++ pigeonhole/tests/compile/errors/require.sieve | 42 +++ pigeonhole/tests/compile/errors/size.sieve | 47 +++ pigeonhole/tests/compile/errors/stop.sieve | 33 ++ pigeonhole/tests/compile/errors/tag.sieve | 16 + pigeonhole/tests/compile/errors/typos.sieve | 29 ++ pigeonhole/tests/compile/errors/unsupported.sieve | 30 ++ pigeonhole/tests/compile/recover.svtest | 50 +++ .../tests/compile/recover/commands-endblock.sieve | 27 ++ .../tests/compile/recover/commands-semicolon.sieve | 16 + .../tests/compile/recover/tests-endcomma.sieve | 17 + pigeonhole/tests/compile/redirect.sieve | 23 ++ pigeonhole/tests/compile/trivial.sieve | 17 + pigeonhole/tests/compile/warnings.svtest | 8 + pigeonhole/tests/compile/warnings/eof.sieve | 2 + .../tests/compile/warnings/invalid-headers.sieve | 14 + 30 files changed, 1310 insertions(+) create mode 100644 pigeonhole/tests/compile/compile.svtest create mode 100644 pigeonhole/tests/compile/errors.svtest create mode 100644 pigeonhole/tests/compile/errors/address-part.sieve create mode 100644 pigeonhole/tests/compile/errors/address.sieve create mode 100644 pigeonhole/tests/compile/errors/comparator.sieve create mode 100644 pigeonhole/tests/compile/errors/encoded-character.sieve create mode 100644 pigeonhole/tests/compile/errors/envelope.sieve create mode 100644 pigeonhole/tests/compile/errors/fileinto.sieve create mode 100644 pigeonhole/tests/compile/errors/header.sieve create mode 100644 pigeonhole/tests/compile/errors/if.sieve create mode 100644 pigeonhole/tests/compile/errors/keep.sieve create mode 100644 pigeonhole/tests/compile/errors/lexer.sieve create mode 100644 pigeonhole/tests/compile/errors/match-type.sieve create mode 100644 pigeonhole/tests/compile/errors/out-address.sieve create mode 100644 pigeonhole/tests/compile/errors/parser.sieve create mode 100644 pigeonhole/tests/compile/errors/require.sieve create mode 100644 pigeonhole/tests/compile/errors/size.sieve create mode 100644 pigeonhole/tests/compile/errors/stop.sieve create mode 100644 pigeonhole/tests/compile/errors/tag.sieve create mode 100644 pigeonhole/tests/compile/errors/typos.sieve create mode 100644 pigeonhole/tests/compile/errors/unsupported.sieve create mode 100644 pigeonhole/tests/compile/recover.svtest create mode 100644 pigeonhole/tests/compile/recover/commands-endblock.sieve create mode 100644 pigeonhole/tests/compile/recover/commands-semicolon.sieve create mode 100644 pigeonhole/tests/compile/recover/tests-endcomma.sieve create mode 100644 pigeonhole/tests/compile/redirect.sieve create mode 100644 pigeonhole/tests/compile/trivial.sieve create mode 100644 pigeonhole/tests/compile/warnings.svtest create mode 100644 pigeonhole/tests/compile/warnings/eof.sieve create mode 100644 pigeonhole/tests/compile/warnings/invalid-headers.sieve (limited to 'pigeonhole/tests/compile') diff --git a/pigeonhole/tests/compile/compile.svtest b/pigeonhole/tests/compile/compile.svtest new file mode 100644 index 0000000..7abda7f --- /dev/null +++ b/pigeonhole/tests/compile/compile.svtest @@ -0,0 +1,16 @@ +require "vnd.dovecot.testsuite"; + +# Just test whether valid scripts will compile without problems + +test "Trivial" { + if not test_script_compile "trivial.sieve" { + test_fail "could not compile"; + } +} + +test "Redirect" { + if not test_script_compile "redirect.sieve" { + test_fail "could not compile"; + } +} + diff --git a/pigeonhole/tests/compile/errors.svtest b/pigeonhole/tests/compile/errors.svtest new file mode 100644 index 0000000..f17ea3f --- /dev/null +++ b/pigeonhole/tests/compile/errors.svtest @@ -0,0 +1,395 @@ +require "vnd.dovecot.testsuite"; + +require "relational"; +require "comparator-i;ascii-numeric"; + +/* + * Errors triggered in the compiled scripts are pretty reduntant over the + * tested commands, but we want to be thorough. + */ + +/* + * Lexer errors + */ + +test "Lexer errors (FIXME: count only)" { + if test_script_compile "errors/lexer.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "9" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Parser errors + */ + +test "Parser errors (FIXME: count only)" { + if test_script_compile "errors/parser.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "9" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Header test + */ + +test "Header errors" { + if test_script_compile "errors/header.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "10" { + test_fail "wrong number of errors reported"; + } + + if not test_error :index 1 :matches + "unknown * ':all' for * header test *" { + test_fail "error 1 is invalid"; + } + + if not test_error :index 2 :matches + "*header test * string list * 1 (header names), but * number *" { + test_fail "error 2 is invalid"; + } + + if not test_error :index 3 :matches + "*header test * string list * 2 (key list), * number *" { + test_fail "error 3 is invalid"; + } + + if not test_error :index 4 :matches + "unknown tagged argument ':tag' for the header test *" { + test_fail "error 4 is invalid"; + } + + if not test_error :index 5 :matches + "* header test requires 2 *, but 1 *" { + test_fail "error 5 is invalid"; + } + + if not test_error :index 6 :matches + "* header test requires 2 *, but 0 *" { + test_fail "error 6 is invalid"; + } + + if not test_error :index 7 :matches + "*header test accepts no sub-tests* specified*" { + test_fail "error 7 is invalid"; + } + + if not test_error :index 8 :matches + "* use test 'header' * command*" { + test_fail "error 8 is invalid"; + } + + if not test_error :index 9 :matches + "* use test 'header' * command*" { + test_fail "error 9 is invalid"; + } + + if test_error :index 4 :contains "radish" { + test_fail "error test matched nonsense"; + } +} + +/* + * Address test + */ + + +test "Address errors" { + if test_script_compile "errors/address.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "9" { + test_fail "wrong number of errors reported"; + } + + if not test_error :index 1 :matches + "*unknown * ':nonsense' * address test*" { + test_fail "error 1 is invalid"; + } + + if not test_error :index 2 :matches + "*address test expects *string list * 1 (header list),* number * found*" { + test_fail "error 2 is invalid"; + } + + if not test_error :index 3 :matches + "*address test expects *string list * 2 (key list),* number * found*" { + test_fail "error 3 is invalid"; + } + + if not test_error :index 4 :matches + "*unexpected *':is' * address test*" { + test_fail "error 4 is invalid"; + } + + if not test_error :index 5 :matches + "*address test * 2 positional arg*, but 1*" { + test_fail "error 5 is invalid"; + } + + if not test_error :index 6 :matches + "*address test * 2 positional arg*, but 0*" { + test_fail "error 6 is invalid"; + } + + if not test_error :index 7 :matches + "*'frop' *not allowed *address test*" { + test_fail "error 7 is invalid"; + } + + if not test_error :index 8 :matches + "*'frop' *not allowed *address test*" { + test_fail "error 8 is invalid"; + } + + if test_error :index 23 :contains "radish" { + test_fail "error test matched nonsense"; + } +} + +/* + * If command + */ + +test "If errors (FIXME: count only)" { + if test_script_compile "errors/if.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "12" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Require command + */ + +test "Require errors (FIXME: count only)" { + if test_script_compile "errors/require.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "15" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Size test + */ + +test "Size errors (FIXME: count only)" { + if test_script_compile "errors/size.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "7" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Envelope test + */ + +test "Envelope errors (FIXME: count only)" { + if test_script_compile "errors/envelope.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "3" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Stop command + */ + +test "Stop errors (FIXME: count only)" { + if test_script_compile "errors/stop.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "9" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Keep command + */ + +test "Keep errors (FIXME: count only)" { + if test_script_compile "errors/keep.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "3" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Fileinto command + */ + +test "Fileinto errors (FIXME: count only)" { + if test_script_compile "errors/fileinto.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "10" { + test_fail "wrong number of errors reported"; + } +} + +/* + * COMPARATOR errors + */ + +test "COMPARATOR errors (FIXME: count only)" { + if test_script_compile "errors/comparator.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "6" { + test_fail "wrong number of errors reported"; + } +} + +/* + * ADDRESS-PART errors + */ + +test "ADDRESS-PART errors (FIXME: count only)" { + if test_script_compile "errors/address-part.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "3" { + test_fail "wrong number of errors reported"; + } +} + +/* + * MATCH-TYPE errors + */ + +test "MATCH-TYPE errors (FIXME: count only)" { + if test_script_compile "errors/match-type.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "2" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Encoded-character errors + */ + +test "Encoded-character errors (FIXME: count only)" { + if test_script_compile "errors/encoded-character.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "3" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Outgoing address errors + */ + +test "Outgoing address errors (FIXME: count only)" { + if test_script_compile "errors/out-address.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "16" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Tagged argument errors + */ + +test "Tagged argument errors (FIXME: count only)" { + if test_script_compile "errors/tag.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "3" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Typos + */ + +test "Typos" { + if test_script_compile "errors/typos.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "6" { + test_fail "wrong number of errors reported"; + } + + if not test_error :index 1 :matches + "missing semicolon * fileinto *" { + test_fail "error 1 is invalid"; + } + + if not test_error :index 2 :matches + "*fileinto command * no *tests* specified*" { + test_fail "error 2 is invalid"; + } + + if not test_error :index 3 :matches + "missing semicolon * fileinto *" { + test_fail "error 3 is invalid"; + } + + if not test_error :index 4 :matches + "*address test requires 2 * 0 * specified" { + test_fail "error 4 is invalid"; + } + + if not test_error :index 5 :matches + "missing colon *matches* tag * address test" { + test_fail "error 5 is invalid"; + } +} + + +/* + * Unsupported language features + */ + +test "Unsupported language features (FIXME: count only)" { + if test_script_compile "errors/unsupported.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "3" { + test_fail "wrong number of errors reported"; + } +} 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 "; +redirect "Error <"; +redirect "Error "; +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}"; + + + diff --git a/pigeonhole/tests/compile/recover.svtest b/pigeonhole/tests/compile/recover.svtest new file mode 100644 index 0000000..9c24c11 --- /dev/null +++ b/pigeonhole/tests/compile/recover.svtest @@ -0,0 +1,50 @@ +require "vnd.dovecot.testsuite"; + +require "relational"; +require "comparator-i;ascii-numeric"; + +/* + * Test parser's recover capability + */ + +/* + * Commands + */ + +/* Missing semicolon */ + +test "Missing semicolons" { + if test_script_compile "recover/commands-semicolon.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "3" { + test_fail "wrong number of errors reported"; + } +} + +/* End of block recovery*/ + +test "Missing semicolon at end of block" { + if test_script_compile "recover/commands-endblock.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "4" { + test_fail "wrong number of errors reported"; + } +} + +/* + * Tests + */ + +test "Spurious comma at end of test list" { + if test_script_compile "recover/tests-endcomma.sieve" { + test_fail "compile should have failed."; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "3" { + test_fail "wrong number of errors reported"; + } +} diff --git a/pigeonhole/tests/compile/recover/commands-endblock.sieve b/pigeonhole/tests/compile/recover/commands-endblock.sieve new file mode 100644 index 0000000..c06e218 --- /dev/null +++ b/pigeonhole/tests/compile/recover/commands-endblock.sieve @@ -0,0 +1,27 @@ +if true { + if true { + # Missing semicolon + keep + } +} + +if true { + # Erroneous syntax + keep, + keep +} + +if true { + if anyof(true,true,false) { + keep; + } +} + +if true { + if anyof(true,true,false) { + keep; + # Missing semicolon + discard + } +} + diff --git a/pigeonhole/tests/compile/recover/commands-semicolon.sieve b/pigeonhole/tests/compile/recover/commands-semicolon.sieve new file mode 100644 index 0000000..effb389 --- /dev/null +++ b/pigeonhole/tests/compile/recover/commands-semicolon.sieve @@ -0,0 +1,16 @@ + +keep; + +discard; + +# Missing semicolon +keep + +redirect "frop@nl.example.com"; + +discard; + +# Missing semicolon +keep + +redirect "frml@nl.example.com"; diff --git a/pigeonhole/tests/compile/recover/tests-endcomma.sieve b/pigeonhole/tests/compile/recover/tests-endcomma.sieve new file mode 100644 index 0000000..54c93ec --- /dev/null +++ b/pigeonhole/tests/compile/recover/tests-endcomma.sieve @@ -0,0 +1,17 @@ +if true { + if true { + # Spurious comma + if anyof(true,true,true,) { + } + } +} + +if true { + if anyof(true,true) { + # Spurious comma + if anyof(true,true,true,) { + if anyof(true,true,true) { + } + } + } +} diff --git a/pigeonhole/tests/compile/redirect.sieve b/pigeonhole/tests/compile/redirect.sieve new file mode 100644 index 0000000..fb9f23d --- /dev/null +++ b/pigeonhole/tests/compile/redirect.sieve @@ -0,0 +1,23 @@ +# Test various white space occurrences +redirect "stephan@example.org"; +redirect " stephan@example.org"; +redirect "stephan @example.org"; +redirect "stephan@ example.org"; +redirect "stephan@example.org "; +redirect " stephan @ example.org "; +redirect "Stephan Bosch"; +redirect " Stephan Bosch"; +redirect "Stephan Bosch "; +redirect "Stephan Bosch< stephan@example.org>"; +redirect "Stephan Bosch"; +redirect "Stephan Bosch"; +redirect "Stephan Bosch"; +redirect "Stephan Bosch "; +redirect " Stephan Bosch < stephan @ example.org > "; + +# Test address syntax +redirect "\"Stephan Bosch\"@example.org"; +redirect "Stephan.Bosch@eXamPle.oRg"; +redirect "Stephan.Bosch@example.org"; +redirect "Stephan Bosch "; + diff --git a/pigeonhole/tests/compile/trivial.sieve b/pigeonhole/tests/compile/trivial.sieve new file mode 100644 index 0000000..a3dcbc1 --- /dev/null +++ b/pigeonhole/tests/compile/trivial.sieve @@ -0,0 +1,17 @@ +# Commands must be case-insensitive +keep; +Keep; +KEEP; +discard; +DisCaRD; + +# Tags must be case-insensitive +if size :UNDER 34 { +} + +if header :Is "from" "tukker@example.com" { +} + +# Numbers must be case-insensitive +if anyof( size :UNDER 34m, size :oVeR 50M ) { +} diff --git a/pigeonhole/tests/compile/warnings.svtest b/pigeonhole/tests/compile/warnings.svtest new file mode 100644 index 0000000..8261551 --- /dev/null +++ b/pigeonhole/tests/compile/warnings.svtest @@ -0,0 +1,8 @@ +require "vnd.dovecot.testsuite"; + +test "EOF Warnings" { + if not test_script_compile "warnings/eof.sieve" { + test_fail "compile should have succeeded."; + } +} + diff --git a/pigeonhole/tests/compile/warnings/eof.sieve b/pigeonhole/tests/compile/warnings/eof.sieve new file mode 100644 index 0000000..cf906dc --- /dev/null +++ b/pigeonhole/tests/compile/warnings/eof.sieve @@ -0,0 +1,2 @@ +keep; +# Final comment without newline diff --git a/pigeonhole/tests/compile/warnings/invalid-headers.sieve b/pigeonhole/tests/compile/warnings/invalid-headers.sieve new file mode 100644 index 0000000..a6b12a8 --- /dev/null +++ b/pigeonhole/tests/compile/warnings/invalid-headers.sieve @@ -0,0 +1,14 @@ +# Header test +if header "from:" "frop@example.org" { + stop; +} + +# Address test +if address "from:" "frop@example.org" { + stop; +} + +# Exists test +if exists "from:" { + stop; +} -- cgit v1.2.3