summaryrefslogtreecommitdiffstats
path: root/pigeonhole/tests/extensions/mailbox
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:36:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:36:47 +0000
commit0441d265f2bb9da249c7abf333f0f771fadb4ab5 (patch)
tree3f3789daa2f6db22da6e55e92bee0062a7d613fe /pigeonhole/tests/extensions/mailbox
parentInitial commit. (diff)
downloaddovecot-0441d265f2bb9da249c7abf333f0f771fadb4ab5.tar.xz
dovecot-0441d265f2bb9da249c7abf333f0f771fadb4ab5.zip
Adding upstream version 1:2.3.21+dfsg1.upstream/1%2.3.21+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pigeonhole/tests/extensions/mailbox')
-rw-r--r--pigeonhole/tests/extensions/mailbox/errors.svtest40
-rw-r--r--pigeonhole/tests/extensions/mailbox/errors/mailboxexists-bad-utf8.sieve9
-rw-r--r--pigeonhole/tests/extensions/mailbox/errors/syntax.sieve41
-rw-r--r--pigeonhole/tests/extensions/mailbox/execute.svtest80
4 files changed, 170 insertions, 0 deletions
diff --git a/pigeonhole/tests/extensions/mailbox/errors.svtest b/pigeonhole/tests/extensions/mailbox/errors.svtest
new file mode 100644
index 0000000..0821f52
--- /dev/null
+++ b/pigeonhole/tests/extensions/mailbox/errors.svtest
@@ -0,0 +1,40 @@
+require "vnd.dovecot.testsuite";
+require "variables";
+require "vnd.dovecot.debug";
+
+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";
+ }
+
+ # FIXME: check warnings
+ if not test_error :count "eq" :comparator "i;ascii-numeric" "12" {
+ test_fail "wrong number of errors reported";
+ }
+}
+
+/*
+ * Mailboxexists - bad UTF-8 in mailbox name
+ */
+
+test "Mailboxexists - bad UTF-8 in mailbox name" {
+ if not test_script_compile "errors/mailboxexists-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/mailbox/errors/mailboxexists-bad-utf8.sieve b/pigeonhole/tests/extensions/mailbox/errors/mailboxexists-bad-utf8.sieve
new file mode 100644
index 0000000..e68e00e
--- /dev/null
+++ b/pigeonhole/tests/extensions/mailbox/errors/mailboxexists-bad-utf8.sieve
@@ -0,0 +1,9 @@
+require "mailbox";
+require "variables";
+require "encoded-character";
+
+set "mailbox" "${hex:ff}rop";
+if mailboxexists "${mailbox}" {
+ keep;
+}
+
diff --git a/pigeonhole/tests/extensions/mailbox/errors/syntax.sieve b/pigeonhole/tests/extensions/mailbox/errors/syntax.sieve
new file mode 100644
index 0000000..727a6e8
--- /dev/null
+++ b/pigeonhole/tests/extensions/mailbox/errors/syntax.sieve
@@ -0,0 +1,41 @@
+require "mailbox";
+require "fileinto";
+require "encoded-character";
+
+# 1
+if mailboxexists {}
+# 2
+if mailboxexists 3423 {}
+# 3
+if mailboxexists :frop {}
+# 4
+if mailboxexists 24234 "\\Sent" {}
+# 5
+if mailboxexists "frop" 32234 {}
+# 6
+if mailboxexists "frop" :friep {}
+
+if mailboxexists "frop" {}
+if mailboxexists ["frop", "friep"] {}
+
+# W:1
+if mailboxexists "${hex:ff}rop" {}
+# W:2
+if mailboxexists ["frop", "${hex:ff}riep"] {}
+
+# 7
+if mailboxexists "frop" ["frop"] {}
+
+# 8
+fileinto :create 343 "frop";
+# 9
+fileinto :create :frop "frop";
+# 10
+fileinto :create 234234;
+
+fileinto :create "frop";
+
+# 11
+fileinto :create "${hex:ff}rop";
+
+
diff --git a/pigeonhole/tests/extensions/mailbox/execute.svtest b/pigeonhole/tests/extensions/mailbox/execute.svtest
new file mode 100644
index 0000000..cba3034
--- /dev/null
+++ b/pigeonhole/tests/extensions/mailbox/execute.svtest
@@ -0,0 +1,80 @@
+require "vnd.dovecot.testsuite";
+require "mailbox";
+require "fileinto";
+
+test "MailboxExists - None exist" {
+ if mailboxexists "frop" {
+ test_fail "mailboxexists confirms existance of unknown folder";
+ }
+}
+
+test_mailbox_create "frop";
+test_mailbox_create "friep";
+
+test "MailboxExists - Not all exist" {
+ if mailboxexists ["frop", "friep", "frml"] {
+ test_fail "mailboxexists confirms existance of unknown folder";
+ }
+}
+
+test_mailbox_create "frml";
+
+test "MailboxExists - One exists" {
+ if not mailboxexists ["frop"] {
+ test_fail "mailboxexists fails to recognize folder";
+ }
+}
+
+test "MailboxExists - All exist" {
+ if not mailboxexists ["frop", "friep", "frml"] {
+ test_fail "mailboxexists fails to recognize folders";
+ }
+}
+
+test ":Create" {
+ if mailboxexists "created" {
+ test_fail "mailbox exists already";
+ }
+
+ test_set "message" text:
+From: stephan@example.org
+To: nico@frop.example.org
+Subject: Frop 1
+
+Frop!
+.
+ ;
+
+ fileinto :create "created";
+
+ if not test_result_execute {
+ test_fail "execution of result failed";
+ }
+
+ if not mailboxexists "created" {
+ test_fail "mailbox somehow not created";
+ }
+
+ test_result_reset;
+
+ test_set "message" text:
+From: stephan@example.org
+To: nico@frop.example.org
+Subject: Frop 2
+
+Frop!
+.
+ ;
+
+ fileinto "created";
+
+ if not test_result_execute {
+ test_fail "execution of result failed second time";
+ }
+
+ test_message :folder "created" 0;
+
+ if not header :is "subject" "Frop 1" {
+ test_fail "incorrect message read back from mail store";
+ }
+}