summaryrefslogtreecommitdiffstats
path: root/pigeonhole/tests/extensions/imap4flags
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
commitf7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch)
treea3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /pigeonhole/tests/extensions/imap4flags
parentInitial commit. (diff)
downloaddovecot-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/imap4flags')
-rw-r--r--pigeonhole/tests/extensions/imap4flags/basic.svtest332
-rw-r--r--pigeonhole/tests/extensions/imap4flags/execute.svtest68
-rw-r--r--pigeonhole/tests/extensions/imap4flags/execute/flags-side-effect.sieve18
-rw-r--r--pigeonhole/tests/extensions/imap4flags/flagstore.svtest146
-rw-r--r--pigeonhole/tests/extensions/imap4flags/flagstring.svtest82
-rw-r--r--pigeonhole/tests/extensions/imap4flags/hasflag.svtest91
-rw-r--r--pigeonhole/tests/extensions/imap4flags/multiscript.svtest55
-rw-r--r--pigeonhole/tests/extensions/imap4flags/multiscript/fileinto.sieve4
-rw-r--r--pigeonhole/tests/extensions/imap4flags/multiscript/group-spam.sieve14
-rw-r--r--pigeonhole/tests/extensions/imap4flags/multiscript/sent-store.sieve7
-rw-r--r--pigeonhole/tests/extensions/imap4flags/multiscript/setflag.sieve3
-rw-r--r--pigeonhole/tests/extensions/imap4flags/multiscript/spam.sieve8
12 files changed, 828 insertions, 0 deletions
diff --git a/pigeonhole/tests/extensions/imap4flags/basic.svtest b/pigeonhole/tests/extensions/imap4flags/basic.svtest
new file mode 100644
index 0000000..d6af444
--- /dev/null
+++ b/pigeonhole/tests/extensions/imap4flags/basic.svtest
@@ -0,0 +1,332 @@
+require "vnd.dovecot.testsuite";
+
+require "imap4flags";
+require "relational";
+require "variables";
+require "comparator-i;ascii-numeric";
+
+/*
+ * Basic functionality tests
+ */
+
+test "Hasflag empty" {
+ if hasflag "\\Seen" {
+ test_fail "hasflag sees initial \\seen flag were there should be none";
+ }
+ if hasflag "\\draft" {
+ test_fail "hasflag sees initial \\draft flag were there should be none";
+ }
+ if hasflag "\\recent" {
+ test_fail "hasflag sees initial \\recent flag were there should be none";
+ }
+ if hasflag "\\flagged" {
+ test_fail "hasflag sees initial \\flagged flag were there should be none";
+ }
+ if hasflag "\\answered" {
+ test_fail "hasflag sees initial \\answered flag were there should be none";
+ }
+ if hasflag "\\deleted" {
+ test_fail "hasflag sees initial \\deleted flag were there should be none";
+ }
+
+ if hasflag :comparator "i;ascii-numeric" :count "ge" "1" {
+ test_fail "hasflag sees initial flags were there should be none";
+ }
+}
+
+test "Setflag; Hasflag one" {
+ setflag "\\seen";
+
+ if not hasflag "\\Seen" {
+ test_fail "flag not set of hasflag fails to see it";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "1" {
+ test_fail "flag not set of hasflag fails to see it";
+ }
+
+ if hasflag "$Nonsense" {
+ test_fail "hasflag sees other flag that the one set";
+ }
+}
+
+test "Hasflag; duplicates" {
+ set "Flags" "A B C D E F A B C D E F";
+
+ if hasflag :comparator "i;ascii-numeric" :count "gt" "Flags" "6" {
+ test_fail "hasflag must ignore duplicates";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "Flags" "6" {
+ test_fail "hasflag :count gives strange results";
+ }
+}
+
+test "Flag operations" {
+ setflag "A";
+
+ if not hasflag "A" {
+ test_fail "hasflag misses set flag";
+ }
+
+ if hasflag :comparator "i;ascii-numeric" :count "gt" "1" {
+ test_fail "hasflag sees more than one flag";
+ }
+
+ addflag "B";
+
+ if not hasflag "B" {
+ test_fail "flag \"B\" not added";
+ }
+
+ if not hasflag "A" {
+ test_fail "flag \"A\" not retained";
+ }
+
+ if hasflag :comparator "i;ascii-numeric" :count "gt" "2" {
+ test_fail "hasflag sees more than two flags";
+ }
+
+ addflag ["C", "D", "E F"];
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "6" {
+ test_fail "hasflag sees more than two flags";
+ }
+
+ removeflag ["D"];
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "5" {
+ test_fail "hasflag sees more than two flags";
+ }
+
+ if hasflag "D" {
+ test_fail "removed flag still present";
+ }
+
+ set "var" "G";
+ addflag "${var}";
+
+ if not hasflag "G" {
+ test_fail "flag \"G\" not added";
+ }
+
+ if not hasflag "A" {
+ test_fail "flag \"A\" not retained";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "6" {
+ test_fail "hasflag sees something other than six flags";
+ }
+}
+
+test "Variable flag operations" {
+ setflag "frop" "A";
+
+ if not hasflag "frop" "A" {
+ test_fail "hasflag misses set flag";
+ }
+
+ if hasflag :comparator "i;ascii-numeric" :count "gt" "frop" "1" {
+ test_fail "hasflag sees more than one flag";
+ }
+
+ addflag "frop" "B";
+
+ if not hasflag "frop" "B" {
+ test_fail "flag \"B\" not added";
+ }
+
+ if not hasflag "frop" "A" {
+ test_fail "flag \"A\" not retained";
+ }
+
+ if hasflag :comparator "i;ascii-numeric" :count "gt" "frop" "2" {
+ test_fail "hasflag sees more than two flags";
+ }
+
+ addflag "frop" ["C", "D", "E F"];
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "frop" "6" {
+ test_fail "hasflag sees something other than six flags";
+ }
+
+ removeflag "frop" ["D"];
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "frop" "5" {
+ test_fail "hasflag sees something other than five flags";
+ }
+
+ if hasflag "frop" "D" {
+ test_fail "removed flag still present";
+ }
+
+ set "var" "G";
+ addflag "frop" "${var}";
+
+ if not hasflag "frop" "G" {
+ test_fail "flag \"G\" not added";
+ }
+
+ if not hasflag "frop" "A" {
+ test_fail "flag \"A\" not retained";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "frop" "6" {
+ test_fail "hasflag sees something other than six flags";
+ }
+}
+
+test "Setflag; string list" {
+ setflag ["A B", "C D"];
+
+ if not hasflag "A" {
+ test_fail "hasflag misses A flag";
+ }
+
+ if not hasflag "B" {
+ test_fail "hasflag misses B flag";
+ }
+
+ if not hasflag "C" {
+ test_fail "hasflag misses C flag";
+ }
+
+ if not hasflag "D" {
+ test_fail "hasflag misses D flag";
+ }
+
+ if hasflag :comparator "i;ascii-numeric" :count "ne" "4" {
+ test_fail "hasflag sees incorrect number of flags";
+ }
+}
+
+test "Removal: one" {
+ setflag "\\seen";
+
+ if not hasflag "\\seen" {
+ test_fail "hasflag misses set flag";
+ }
+
+ removeflag "\\seen";
+
+ if hasflag "\\seen" {
+ test_fail "flag not removed";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "0" {
+ test_fail "flags are still set";
+ }
+}
+
+test "Removal: first" {
+ setflag "$frop \\seen";
+
+ if not allof ( hasflag "\\seen", hasflag "$frop" ) {
+ test_fail "hasflag misses set flags";
+ }
+
+ removeflag "$frop";
+
+ if not hasflag "\\seen" {
+ test_fail "wrong flag removed";
+ }
+
+ if hasflag "$frop" {
+ test_fail "flag not removed";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "1" {
+ test_fail "more than one flag remains set";
+ }
+}
+
+test "Removal: last" {
+ setflag "\\seen $friep";
+
+ if not allof ( hasflag "\\seen", hasflag "$friep" ) {
+ test_fail "hasflag misses set flags";
+ }
+
+ removeflag "$friep";
+
+ if not hasflag "\\seen" {
+ test_fail "wrong flag removed";
+ }
+
+ if hasflag "$friep" {
+ test_fail "flag not removed";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "1" {
+ test_fail "more than one flag remains set";
+ }
+}
+
+test "Removal: middle" {
+ setflag "\\seen $friep \\flagged";
+
+ if not allof ( hasflag "\\flagged", hasflag "\\seen", hasflag "$friep" ) {
+ test_fail "hasflag misses set flags";
+ }
+
+ removeflag "$friep";
+
+ if not allof ( hasflag "\\seen", hasflag "\\flagged" ) {
+ test_fail "wrong flag removed";
+ }
+
+ if hasflag "$friep" {
+ test_fail "flag not removed";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "2" {
+ test_fail "more than two flags remain set";
+ }
+}
+
+test "Removal: duplicates" {
+ setflag "\\seen $friep $friep \\flagged $friep";
+
+ if not allof ( hasflag "\\flagged", hasflag "\\seen", hasflag "$friep" ) {
+ test_fail "hasflag misses set flags";
+ }
+
+ removeflag "$friep";
+
+ if not allof ( hasflag "\\seen", hasflag "\\flagged" ) {
+ test_fail "wrong flag removed";
+ }
+
+ if hasflag "$friep" {
+ test_fail "flag not removed";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "2" {
+ test_fail "more than two flags remain set";
+ }
+}
+
+test "Removal: whitespace" {
+ setflag " \\seen $friep $friep \\flagged $friep ";
+
+ if not allof ( hasflag "\\flagged", hasflag "\\seen", hasflag "$friep" ) {
+ test_fail "hasflag misses set flags";
+ }
+
+ removeflag "$friep";
+
+ if not allof ( hasflag "\\seen", hasflag "\\flagged" ) {
+ test_fail "wrong flag removed";
+ }
+
+ if hasflag "$friep" {
+ test_fail "flag not removed";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "2" {
+ test_fail "more than two flags remain set";
+ }
+}
+
+
+
diff --git a/pigeonhole/tests/extensions/imap4flags/execute.svtest b/pigeonhole/tests/extensions/imap4flags/execute.svtest
new file mode 100644
index 0000000..1ee1906
--- /dev/null
+++ b/pigeonhole/tests/extensions/imap4flags/execute.svtest
@@ -0,0 +1,68 @@
+require "vnd.dovecot.testsuite";
+require "imap4flags";
+require "relational";
+
+
+/*
+ * Execution testing
+ */
+
+test_mailbox_create "INBOX.Junk";
+test_mailbox_create "INBOX.Nonsense";
+
+test "Flags Side Effect" {
+ if not test_script_compile "execute/flags-side-effect.sieve" {
+ test_fail "script compile failed";
+ }
+
+ if not test_script_run {
+ test_fail "script execute failed";
+ }
+
+ if not test_result_execute {
+ test_fail "result execute failed";
+ }
+
+ test_result_reset;
+
+ if not test_message :folder "INBOX.Junk" 0 {
+ test_fail "message not stored in INBOX.Junk";
+ }
+
+ if not hasflag :count "eq" "1" {
+ test_fail "invalid number of flags for message in INBOX.Junk";
+ }
+
+ if not hasflag :is "NONSENSE" {
+ test_fail "invalid flag set for message in INBOX.Junk";
+ }
+
+ test_result_reset;
+
+ if not test_message :folder "INBOX" 0 {
+ test_fail "message not stored in INBOX";
+ }
+
+ if not hasflag :count "eq" "1" {
+ test_fail "invalid number of flags for message in INBOX";
+ }
+
+ if not hasflag :is "\\seen" {
+ test_fail "invalid flag set for message in INBOX";
+ }
+
+ test_result_reset;
+
+ if not test_message :folder "INBOX.Nonsense" 0 {
+ test_fail "message not stored in INBOX.Nonsense";
+ }
+
+ if not hasflag :count "eq" "1" {
+ test_fail "invalid number of flags for message in Inbox.Nonsense";
+ }
+
+ if not hasflag :is "IMPLICIT" {
+ test_fail "invalid flag set for message in Inbox.Nonsene";
+ }
+
+}
diff --git a/pigeonhole/tests/extensions/imap4flags/execute/flags-side-effect.sieve b/pigeonhole/tests/extensions/imap4flags/execute/flags-side-effect.sieve
new file mode 100644
index 0000000..17de0ad
--- /dev/null
+++ b/pigeonhole/tests/extensions/imap4flags/execute/flags-side-effect.sieve
@@ -0,0 +1,18 @@
+require "imap4flags";
+require "fileinto";
+
+/*
+ * When keep/fileinto is used multiple times in a script and duplicate
+ * message elimination is performed, the last flag list value MUST win.
+ */
+
+setflag "IMPLICIT";
+
+fileinto :flags "\\Seen \\Draft" "INBOX.Junk";
+fileinto :flags "NONSENSE" "INBOX.Junk";
+
+keep;
+keep :flags "\\Seen";
+
+fileinto :flags "\\Seen" "Inbox.Nonsense";
+fileinto "Inbox.Nonsense";
diff --git a/pigeonhole/tests/extensions/imap4flags/flagstore.svtest b/pigeonhole/tests/extensions/imap4flags/flagstore.svtest
new file mode 100644
index 0000000..bf11402
--- /dev/null
+++ b/pigeonhole/tests/extensions/imap4flags/flagstore.svtest
@@ -0,0 +1,146 @@
+require "vnd.dovecot.testsuite";
+require "fileinto";
+require "imap4flags";
+require "relational";
+require "comparator-i;ascii-numeric";
+require "mailbox";
+
+test_set "message" text:
+From: Henry von Flockenstoffen <henry@example.com>
+To: Dieter von Ausburg <dieter@example.com>
+Subject: Test message.
+
+Test message.
+.
+;
+
+test "Basic" {
+ if hasflag :comparator "i;ascii-numeric" :count "ge" "1" {
+ test_fail "some flags or keywords are already set";
+ }
+
+ setflag "$label1 \\answered";
+
+ fileinto :create "Uninteresting";
+
+ if not test_result_execute {
+ test_fail "failed to execute first result";
+ }
+
+ test_result_reset;
+
+ setflag "\\draft \\seen Junk";
+
+ fileinto "Uninteresting";
+
+ if not test_result_execute {
+ test_fail "failed to execute second result";
+ }
+
+ test_result_reset;
+
+ fileinto :flags "\\flagged" "Uninteresting";
+
+ if not test_result_execute {
+ test_fail "failed to execute third result";
+ }
+
+ test_result_reset;
+
+ test_message :folder "Uninteresting" 0;
+
+ if not hasflag "$label1 \\answered" {
+ test_fail "flags not stored for first message";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "2" {
+ test_fail "invalid number of flags set for first message";
+ }
+
+ test_result_reset;
+
+ test_message :folder "Uninteresting" 1;
+
+ if not hasflag "\\draft \\seen Junk" {
+ test_fail "flags not stored for second message";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "3" {
+ test_fail "invalid number of flags set for second message";
+ }
+
+ test_result_reset;
+
+ test_message :folder "Uninteresting" 2;
+
+ if not hasflag "\\flagged" {
+ test_fail "flags not stored for third message";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "1" {
+ test_fail "invalid number of flags set for third message";
+ }
+}
+
+test_result_reset;
+test_set "message" text:
+From: Henry von Flockenstoffen <henry@example.com>
+To: Dieter von Ausburg <dieter@example.com>
+Subject: Test message.
+
+Test message.
+.
+;
+
+test "Flag changes between stores" {
+ if hasflag :comparator "i;ascii-numeric" :count "ge" "1" {
+ test_fail "some flags or keywords are already set";
+ }
+
+ setflag "$label1 \\answered";
+ fileinto :create "FolderA";
+
+ setflag "$label2";
+ fileinto :create "FolderB";
+
+ fileinto :create :flags "\\seen \\draft \\flagged" "FolderC";
+
+ if not test_result_execute {
+ test_fail "failed to execute first result";
+ }
+
+ test_result_reset;
+ test_message :folder "FolderA" 0;
+
+ if not hasflag "\\answered $label1" {
+ test_fail "flags not stored for first message";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "2" {
+ test_fail "invalid number of flags set for first message";
+ }
+
+ test_result_reset;
+ test_message :folder "FolderB" 0;
+
+ if not hasflag "$label2" {
+ test_fail "flag not stored for second message";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "1" {
+ test_fail "invalid number of flags set for second message";
+ }
+
+ test_result_reset;
+ test_message :folder "FolderC" 0;
+
+ if not hasflag "\\seen \\flagged \\draft" {
+ test_fail "flags not stored for third message";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "3" {
+ test_fail "invalid number of flags set for third message";
+ }
+}
+
+
diff --git a/pigeonhole/tests/extensions/imap4flags/flagstring.svtest b/pigeonhole/tests/extensions/imap4flags/flagstring.svtest
new file mode 100644
index 0000000..23b6b34
--- /dev/null
+++ b/pigeonhole/tests/extensions/imap4flags/flagstring.svtest
@@ -0,0 +1,82 @@
+require "vnd.dovecot.testsuite";
+require "imap4flags";
+require "variables";
+
+test "Duplicates: setflag" {
+ setflag "flags" "\\seen \\seen";
+
+ if not string "${flags}" "\\seen" {
+ test_fail "duplicate \\seen flag item not removed (1)";
+ }
+
+ setflag "flags" "\\seen $frop \\seen";
+
+ if not string "${flags}" "\\seen $frop" {
+ test_fail "duplicate \\seen flag item not removed (2)";
+ }
+
+ setflag "flags" "\\seen $frop $frop \\seen";
+
+ if not string "${flags}" "\\seen $frop" {
+ test_fail "duplicate \\seen flag item not removed (3)";
+ }
+
+ setflag "flags" "$frop \\seen $frop \\seen";
+
+ if not string "${flags}" "$frop \\seen" {
+ test_fail "duplicate \\seen flag item not removed (4)";
+ }
+
+ setflag "flags" "$frop \\seen \\seen \\seen \\seen $frop $frop $frop \\seen";
+
+ if not string "${flags}" "$frop \\seen" {
+ test_fail "duplicate \\seen flag item not removed (5)";
+ }
+}
+
+test "Duplicates: addflag" {
+ setflag "flags" "";
+ addflag "flags" "\\seen \\seen";
+
+ if not string "${flags}" "\\seen" {
+ test_fail "duplicate \\seen flag item not removed (1)";
+ }
+
+ setflag "flags" "";
+ addflag "flags" "\\seen $frop \\seen";
+
+ if not string "${flags}" "\\seen $frop" {
+ test_fail "duplicate \\seen flag item not removed (2)";
+ }
+
+ setflag "flags" "";
+ addflag "flags" "\\seen $frop $frop \\seen";
+
+ if not string "${flags}" "\\seen $frop" {
+ test_fail "duplicate \\seen flag item not removed (3)";
+ }
+
+ setflag "flags" "";
+ addflag "flags" "$frop \\seen $frop \\seen";
+
+ if not string "${flags}" "$frop \\seen" {
+ test_fail "duplicate \\seen flag item not removed (4)";
+ }
+
+ setflag "flags" "";
+ addflag "flags" "$frop \\seen \\seen \\seen \\seen $frop $frop $frop \\seen";
+
+ if not string "${flags}" "$frop \\seen" {
+ test_fail "duplicate \\seen flag item not removed (5)";
+ }
+
+ setflag "flags" "$frop \\seen";
+ addflag "flags" "\\seen \\seen \\seen $frop $frop $frop \\seen";
+
+ if not string "${flags}" "$frop \\seen" {
+ test_fail "duplicate \\seen flag item not removed (6)";
+ }
+}
+
+
+
diff --git a/pigeonhole/tests/extensions/imap4flags/hasflag.svtest b/pigeonhole/tests/extensions/imap4flags/hasflag.svtest
new file mode 100644
index 0000000..1088190
--- /dev/null
+++ b/pigeonhole/tests/extensions/imap4flags/hasflag.svtest
@@ -0,0 +1,91 @@
+require "vnd.dovecot.testsuite";
+
+require "imap4flags";
+require "relational";
+require "variables";
+require "comparator-i;ascii-numeric";
+
+/*
+ * Generic tests
+ */
+
+test "Ignoring \"\"" {
+ setflag "";
+
+ if hasflag "" {
+ test_fail "hasflag fails to ignore empty string";
+ }
+}
+
+/*
+ * Variables
+ */
+
+test "Multiple variables" {
+ setflag "A" "Aflag";
+ setflag "B" "Bflag";
+ setflag "C" "Cflag";
+
+ if not hasflag ["a", "b", "c"] ["Bflag"] {
+ test_fail "hasflag failed to match multiple flags variables";
+ }
+}
+
+/*
+ * RFC examples
+ */
+
+test "RFC hasflag example - :is" {
+ setflag "A B";
+
+ if not hasflag ["b","A"] {
+ test_fail "list representation did not match";
+ }
+
+ if not hasflag :is "b A" {
+ test_fail "string representation did not match";
+ }
+}
+
+test "RFC hasflag example - :contains variable" {
+ set "MyVar" "NonJunk Junk gnus-forward $Forwarded NotJunk JunkRecorded $Junk $NotJunk";
+
+ if not hasflag :contains "MyVar" "Junk" {
+ test_fail "failed true example 1";
+ }
+
+ if not hasflag :contains "MyVar" "forward" {
+ test_fail "failed true example 2";
+ }
+
+ if not hasflag :contains "MyVar" ["label", "forward"] {
+ test_fail "failed true example 3";
+ }
+
+ if not hasflag :contains "MyVar" ["junk", "forward"] {
+ test_fail "failed true example 4";
+ }
+
+ if not hasflag :contains "MyVar" "junk forward" {
+ test_fail "failed true example 4 (rewrite 1)";
+ }
+
+ if not hasflag :contains "MyVar" "forward junk" {
+ test_fail "failed true example 4 (rewrite 2)";
+ }
+
+ if hasflag :contains "MyVar" "label" {
+ test_fail "failed false example 1";
+ }
+
+ if hasflag :contains "MyVar" ["label1", "label2"] {
+ test_fail "failed false example 2";
+ }
+}
+
+test "RFC hasflag example - :count variable" {
+ set "MyFlags" "A B";
+ if not hasflag :count "ge" :comparator "i;ascii-numeric" "MyFlags" "2" {
+ test_fail "failed count \"ge\" comparison";
+ }
+}
diff --git a/pigeonhole/tests/extensions/imap4flags/multiscript.svtest b/pigeonhole/tests/extensions/imap4flags/multiscript.svtest
new file mode 100644
index 0000000..5080eda
--- /dev/null
+++ b/pigeonhole/tests/extensions/imap4flags/multiscript.svtest
@@ -0,0 +1,55 @@
+require "vnd.dovecot.testsuite";
+require "imap4flags";
+require "relational";
+require "comparator-i;ascii-numeric";
+require "mailbox";
+require "fileinto";
+
+test "Segfault Trigger 1" {
+
+ if not test_multiscript [
+ "multiscript/group-spam.sieve",
+ "multiscript/spam.sieve",
+ "multiscript/sent-store.sieve"]
+ {
+ test_fail "failed multiscript execution";
+ }
+}
+
+test_set "message" text:
+From: Henry von Flockenstoffen <henry@example.com>
+To: Dieter von Ausburg <dieter@example.com>
+Subject: Test message.
+
+Test message.
+.
+;
+
+test "Internal Flags" {
+ if hasflag :comparator "i;ascii-numeric" :count "ge" "1" {
+ test_fail "some flags or keywords are already set";
+ }
+
+ if not test_multiscript [
+ "multiscript/setflag.sieve",
+ "multiscript/fileinto.sieve"]
+ {
+ test_fail "failed multiscript execution";
+ }
+
+ test_result_reset;
+ test_message :folder "folder" 0;
+
+ if not hasflag "\\answered" {
+ test_fail "\\answered flag not stored for message";
+ }
+
+ if not hasflag "$label1" {
+ test_fail "$label1 keyword not stored for message";
+ }
+
+ if not hasflag :comparator "i;ascii-numeric" :count "eq" "2" {
+ test_fail "invalid number of flags set for message";
+ }
+}
+
diff --git a/pigeonhole/tests/extensions/imap4flags/multiscript/fileinto.sieve b/pigeonhole/tests/extensions/imap4flags/multiscript/fileinto.sieve
new file mode 100644
index 0000000..94892a5
--- /dev/null
+++ b/pigeonhole/tests/extensions/imap4flags/multiscript/fileinto.sieve
@@ -0,0 +1,4 @@
+require "fileinto";
+require "mailbox";
+
+fileinto :create "folder";
diff --git a/pigeonhole/tests/extensions/imap4flags/multiscript/group-spam.sieve b/pigeonhole/tests/extensions/imap4flags/multiscript/group-spam.sieve
new file mode 100644
index 0000000..92ea3b9
--- /dev/null
+++ b/pigeonhole/tests/extensions/imap4flags/multiscript/group-spam.sieve
@@ -0,0 +1,14 @@
+require ["fileinto", "variables", "envelope"];
+
+if header :contains "X-Group-Mail" ["Yes", "YES", "1"] {
+ if header :contains "X-Spam-Flag" ["Yes", "YES", "1"] {
+ if envelope :matches :localpart "to" "*" {
+ fileinto "group/${1}/SPAM"; stop;
+ }
+ }
+ if address :is ["To"] "sales@florist.ru" {
+ fileinto "group/info/Orders";
+ }
+ stop;
+}
+keep;
diff --git a/pigeonhole/tests/extensions/imap4flags/multiscript/sent-store.sieve b/pigeonhole/tests/extensions/imap4flags/multiscript/sent-store.sieve
new file mode 100644
index 0000000..cb21daa
--- /dev/null
+++ b/pigeonhole/tests/extensions/imap4flags/multiscript/sent-store.sieve
@@ -0,0 +1,7 @@
+require ["imap4flags"];
+
+if header :contains "X-Set-Seen" ["Yes", "YES", "1"] {
+ setflag "\\Seen";
+}
+
+keep;
diff --git a/pigeonhole/tests/extensions/imap4flags/multiscript/setflag.sieve b/pigeonhole/tests/extensions/imap4flags/multiscript/setflag.sieve
new file mode 100644
index 0000000..c992d19
--- /dev/null
+++ b/pigeonhole/tests/extensions/imap4flags/multiscript/setflag.sieve
@@ -0,0 +1,3 @@
+require "imap4flags";
+
+setflag "$label1 \\answered";
diff --git a/pigeonhole/tests/extensions/imap4flags/multiscript/spam.sieve b/pigeonhole/tests/extensions/imap4flags/multiscript/spam.sieve
new file mode 100644
index 0000000..9e1b6c3
--- /dev/null
+++ b/pigeonhole/tests/extensions/imap4flags/multiscript/spam.sieve
@@ -0,0 +1,8 @@
+require ["fileinto"];
+
+if header :contains "X-Spam-Flag" ["Yes", "YES", "1"] {
+ fileinto "SPAM";
+}
+keep;
+
+