From dcb93b58342e91e770f05145cfcfa7b09e5bff69 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan.bosch@open-xchange.com> Date: Thu, 11 Jun 2020 22:33:36 +0200 Subject: [PATCH] tests: extensions: metadata: Add tests for bad UTF-8 in mailbox names. --- tests/extensions/metadata/errors.svtest | 38 +++++++++++++++++++ .../metadata/errors/metadata-bad-utf8.sieve | 9 +++++ .../errors/metadataexists-bad-utf8.sieve | 9 +++++ tests/extensions/metadata/errors/syntax.sieve | 17 ++++++--- 4 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 tests/extensions/metadata/errors/metadata-bad-utf8.sieve create mode 100644 tests/extensions/metadata/errors/metadataexists-bad-utf8.sieve diff --git a/tests/extensions/metadata/errors.svtest b/tests/extensions/metadata/errors.svtest index e0cffaafc..360248439 100644 --- a/tests/extensions/metadata/errors.svtest +++ b/tests/extensions/metadata/errors.svtest @@ -16,3 +16,41 @@ test "Invalid Syntax" { test_fail "wrong number of errors reported"; } } + +/* + * Metadataexists - bad UTF-8 in mailbox name + */ + +test "Metadataexists - bad UTF-8 in mailbox name" { + if not test_script_compile "errors/metadataexists-bad-utf8.sieve" { + test_fail "compile failed"; + } + + if not test_script_run { + test_fail "execution failed"; + } + + # FIXME: check warnings + if not test_error :count "eq" :comparator "i;ascii-numeric" "0" { + test_fail "wrong number of runtime errors reported"; + } +} + +/* + * Metadata - bad UTF-8 in mailbox name + */ + +test "Metadata - bad UTF-8 in mailbox name" { + if not test_script_compile "errors/metadata-bad-utf8.sieve" { + test_fail "compile failed"; + } + + if not test_script_run { + test_fail "execution failed"; + } + + # FIXME: check warnings + if not test_error :count "eq" :comparator "i;ascii-numeric" "0" { + test_fail "wrong number of runtime errors reported"; + } +} diff --git a/tests/extensions/metadata/errors/metadata-bad-utf8.sieve b/tests/extensions/metadata/errors/metadata-bad-utf8.sieve new file mode 100644 index 000000000..fd093a3e6 --- /dev/null +++ b/tests/extensions/metadata/errors/metadata-bad-utf8.sieve @@ -0,0 +1,9 @@ +require "mboxmetadata"; +require "variables"; +require "encoded-character"; + +set "mailbox" "${hex:ff}rop"; +if metadata "${mailbox}" "/private/frop" "friep" { + keep; +} + diff --git a/tests/extensions/metadata/errors/metadataexists-bad-utf8.sieve b/tests/extensions/metadata/errors/metadataexists-bad-utf8.sieve new file mode 100644 index 000000000..dbb502397 --- /dev/null +++ b/tests/extensions/metadata/errors/metadataexists-bad-utf8.sieve @@ -0,0 +1,9 @@ +require "mboxmetadata"; +require "variables"; +require "encoded-character"; + +set "mailbox" "${hex:ff}rop"; +if metadataexists "${mailbox}" ["/private/frop", "/shared/friep"] { + keep; +} + diff --git a/tests/extensions/metadata/errors/syntax.sieve b/tests/extensions/metadata/errors/syntax.sieve index 4b488d136..c719d94f8 100644 --- a/tests/extensions/metadata/errors/syntax.sieve +++ b/tests/extensions/metadata/errors/syntax.sieve @@ -1,5 +1,6 @@ require "mboxmetadata"; require "servermetadata"; +require "encoded-character"; # 1-4: Used as a command metadata; @@ -13,36 +14,40 @@ if metadataexists {} if servermetadata {} if servermetadataexists {} -# 9-10: Used with one string argument +# 9-11: Used with one string argument if metadata "frop" { } if servermetadata "frop" { } if metadataexists "frop" { } -# Used with one number argument +# 12-15: Used with one number argument if metadata 13123123 { } if servermetadata 123123 { } if metadataexists 123123 { } if servermetadataexists 123123 {} -# Used with one string list argument +# 16-18: Used with one string list argument if metadata ["frop"] { } if servermetadata ["frop"] { } if metadataexists ["frop"] { } -# Used with unknown tag +# 19-22: Used with unknown tag if metadata :frop "frop" { } if servermetadata :frop "frop" { } if metadataexists :frop "frop" { } if servermetadataexists :frop "frop" {} -# Invalid arguments +# 23-26: Invalid arguments if metadata "/private/frop" "friep" {} if servermetadata "INBOX" "/private/frop" "friep" {} if metadataexists 23 "/private/frop" {} if servermetadataexists "INBOX" "/private/frop" {} -# Invalid annotations +# W1-W4: Invalid annotations if metadata "INBOX" "frop" "friep" {} if servermetadata "frop" "friep" {} if metadataexists "INBOX" ["/private/frop", "/friep"] { } if servermetadataexists ["/private/frop", "/friep", "/private/friep"] { } + +# W5-W6: Invalid mailbox name +if metadata "${hex:ff}rop" "/private/frop" "friep" {} +if metadataexists "${hex:ff}rop" ["/private/frop", "/shared/friep"] { } -- GitLab