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/extensions/metadata | |
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/extensions/metadata')
5 files changed, 272 insertions, 0 deletions
diff --git a/pigeonhole/tests/extensions/metadata/errors.svtest b/pigeonhole/tests/extensions/metadata/errors.svtest new file mode 100644 index 0000000..3602484 --- /dev/null +++ b/pigeonhole/tests/extensions/metadata/errors.svtest @@ -0,0 +1,56 @@ +require "vnd.dovecot.testsuite"; + +require "relational"; +require "comparator-i;ascii-numeric"; + +/* + * Invalid syntax + */ + +test "Invalid Syntax" { + if test_script_compile "errors/syntax.sieve" { + test_fail "compile should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "27" { + 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/pigeonhole/tests/extensions/metadata/errors/metadata-bad-utf8.sieve b/pigeonhole/tests/extensions/metadata/errors/metadata-bad-utf8.sieve new file mode 100644 index 0000000..fd093a3 --- /dev/null +++ b/pigeonhole/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/pigeonhole/tests/extensions/metadata/errors/metadataexists-bad-utf8.sieve b/pigeonhole/tests/extensions/metadata/errors/metadataexists-bad-utf8.sieve new file mode 100644 index 0000000..dbb5023 --- /dev/null +++ b/pigeonhole/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/pigeonhole/tests/extensions/metadata/errors/syntax.sieve b/pigeonhole/tests/extensions/metadata/errors/syntax.sieve new file mode 100644 index 0000000..c719d94 --- /dev/null +++ b/pigeonhole/tests/extensions/metadata/errors/syntax.sieve @@ -0,0 +1,53 @@ +require "mboxmetadata"; +require "servermetadata"; +require "encoded-character"; + +# 1-4: Used as a command +metadata; +metadataexists; +servermetadata; +servermetadataexists; + +# 5-8: Used with no argument +if metadata {} +if metadataexists {} +if servermetadata {} +if servermetadataexists {} + +# 9-11: Used with one string argument +if metadata "frop" { } +if servermetadata "frop" { } +if metadataexists "frop" { } + +# 12-15: Used with one number argument +if metadata 13123123 { } +if servermetadata 123123 { } +if metadataexists 123123 { } +if servermetadataexists 123123 {} + +# 16-18: Used with one string list argument +if metadata ["frop"] { } +if servermetadata ["frop"] { } +if metadataexists ["frop"] { } + +# 19-22: Used with unknown tag +if metadata :frop "frop" { } +if servermetadata :frop "frop" { } +if metadataexists :frop "frop" { } +if servermetadataexists :frop "frop" {} + +# 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" {} + +# 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"] { } diff --git a/pigeonhole/tests/extensions/metadata/execute.svtest b/pigeonhole/tests/extensions/metadata/execute.svtest new file mode 100644 index 0000000..32aac82 --- /dev/null +++ b/pigeonhole/tests/extensions/metadata/execute.svtest @@ -0,0 +1,145 @@ +require "vnd.dovecot.testsuite"; +require "mboxmetadata"; +require "servermetadata"; +require "fileinto"; + +test "MetadataExists - None exist" { + if metadataexists "INBOX" "/private/frop" { + test_fail "metadataexists confirms existence of unknown annotation"; + } +} + +test_imap_metadata_set :mailbox "INBOX" "/private/frop" "FROP!"; +test_imap_metadata_set :mailbox "INBOX" "/private/friep" "FRIEP!"; + +test "MetadataExists - Not all exist" { + if metadataexists "INBOX" + ["/private/frop", "/private/friep", "/private/frml"] { + test_fail "metadataexists confirms existence of unknown annotation"; + } +} + +test_imap_metadata_set :mailbox "INBOX" "/private/friep" "FRIEP!"; +test_imap_metadata_set :mailbox "INBOX" "/private/frml" "FRML!"; + +test "MetadataExists - One exists" { + if not metadataexists "INBOX" ["/private/frop"] { + test_fail "metadataexists fails to recognize annotation"; + } +} + +test "MetadataExists - All exist" { + if not metadataexists "INBOX" + ["/private/frop", "/private/friep", "/private/frml"] { + test_fail "metadataexists fails to recognize annotations"; + } +} + +test "MetadataExists - Invalid" { + if metadataexists "INBOX" + ["/shared/frop", "/friep", "/private/frml"] { + test_fail "metadataexists accepted invalid annotation name"; + } +} + +test "Metadata" { + if not metadata :is "INBOX" "/private/frop" "FROP!" { + test_fail "invalid metadata value for /private/frop"; + } + if metadata :is "INBOX" "/private/frop" "Hutsefluts" { + test_fail "unexpected match for /private/frop"; + } + + if not metadata :is "INBOX" "/private/friep" "FRIEP!" { + test_fail "invalid metadata value for /private/friep"; + } + if metadata :is "INBOX" "/private/friep" "Hutsefluts" { + test_fail "unexpected match for /private/friep"; + } + + if not metadata :is "INBOX" "/private/frml" "FRML!" { + test_fail "invalid metadata value for /private/frml"; + } + if metadata :is "INBOX" "/private/frml" "Hutsefluts" { + test_fail "unexpected match for /private/frml"; + } +} + +test "Metadata - Invalid" { + if metadata :contains "INBOX" "/frop" "" { + test_fail "erroneously found a value for \"/frop\""; + } +} + +test "ServermetadataExists - None exist" { + if servermetadataexists "/private/frop" { + test_fail "servermetadataexists confirms existence of unknown annotation"; + } +} + +# currently not possible to test servermetadata +if false { + +test_imap_metadata_set "/private/frop" "FROP!"; +test_imap_metadata_set "/private/friep" "FRIEP!"; + +test "ServermetadataExists - Not all exist" { + if servermetadataexists + ["/private/frop", "/private/friep", "/private/frml"] { + test_fail "metadataexists confirms existence of unknown annotation"; + } +} + +test_imap_metadata_set "/private/friep" "FRIEP!"; +test_imap_metadata_set "/private/frml" "FRML!"; + +test "ServermetadataExists - One exists" { + if not servermetadataexists ["/private/frop"] { + test_fail "servermetadataexists fails to recognize annotation"; + } +} + +test "ServermetadataExists - All exist" { + if not servermetadataexists + ["/private/frop", "/private/friep", "/private/frml"] { + test_fail "servermetadataexists fails to recognize annotations"; + } +} + +test "ServermetadataExists - Invalid" { + if servermetadataexists + ["frop", "/private/friep", "/private/frml"] { + test_fail "servermetadataexists accepted invalid annotation name"; + } +} + +test "Servermetadata" { + if not servermetadata :is "/private/frop" "FROP!" { + test_fail "invalid servermetadata value for /private/frop"; + } + if servermetadata :is "/private/frop" "Hutsefluts" { + test_fail "unexpected match for /private/frop"; + } + + if not servermetadata :is "/private/friep" "FRIEP!" { + test_fail "invalid servermetadata value for /private/friep"; + } + if servermetadata :is "/private/friep" "Hutsefluts" { + test_fail "unexpected match for /private/friep"; + } + + if not servermetadata :is "/private/frml" "FRML!" { + test_fail "invalid servermetadata value for /private/frml"; + } + if servermetadata :is "/private/frml" "Hutsefluts" { + test_fail "unexpected match for /private/frml"; + } +} + +test "Servermetadata - Invalid" { + if servermetadata :contains "/frop" "" { + test_fail "erroneously found a value for \"/frop\""; + } +} + +} #disabled |