diff options
Diffstat (limited to 'pigeonhole/tests/deprecated/notify')
9 files changed, 740 insertions, 0 deletions
diff --git a/pigeonhole/tests/deprecated/notify/basic.svtest b/pigeonhole/tests/deprecated/notify/basic.svtest new file mode 100644 index 0000000..974f8ca --- /dev/null +++ b/pigeonhole/tests/deprecated/notify/basic.svtest @@ -0,0 +1,59 @@ +require "vnd.dovecot.testsuite"; +require "notify"; +require "body"; + +test "Execute" { + /* Test to catch runtime segfaults */ + notify + :message "This is probably very important" + :low + :method "mailto" + :options ["stephan@example.com", "stephan@example.org"]; + + if not test_result_execute { + test_fail "Execute failed"; + } +} + +test_result_reset; + +test_set "message" text: +To: user@example.com +From: stephan@example.org +Subject: Mail + +Test! +. +; + +test "Substitutions" { + notify + :message "$from$: $subject$" + :options "stephan@example.com"; + if not test_result_execute { + test_fail "Execute failed"; + } + test_message :smtp 0; + if not body :contains "stephan@example.org: Mail" { + test_fail "Substitution failed"; + } +} + +test_result_reset; + +test_set "message" text: +To: user@example.com + +Test! +. +; + +test "Empty substitutions" { + notify + :message "$from$: $subject$" + :options "stephan@example.com"; + if not test_result_execute { + test_fail "Execute failed"; + } +} + diff --git a/pigeonhole/tests/deprecated/notify/denotify.svtest b/pigeonhole/tests/deprecated/notify/denotify.svtest new file mode 100644 index 0000000..9f752e1 --- /dev/null +++ b/pigeonhole/tests/deprecated/notify/denotify.svtest @@ -0,0 +1,279 @@ +require "vnd.dovecot.testsuite"; +require "notify"; +require "envelope"; + +/* + * Denotify all + */ + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test "Denotify All" { + notify :options "timo@example.com"; + notify :options "stephan@dovecot.example.net"; + notify :options "postmaster@frop.example.org"; + denotify; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + if test_message :smtp 0 { + test_fail "no notifications should have been sent"; + } +} + +/* + * Denotify First + */ + +test_result_reset; + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test "Denotify ID First" { + /* #1 */ + notify :options "timo@example.com" :id "aap"; + + /* #2 */ + notify :options "stephan@dovecot.example.net" :id "noot"; + + /* #3 */ + notify :options "postmaster@frop.example.org" :id "mies"; + + denotify :is "aap"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + if not test_message :smtp 0 { + test_fail "two notifications should have been sent (#2 missing)"; + } + + if not envelope "to" "stephan@dovecot.example.net" { + test_fail "message #2 unexpectedly missing from output"; + } + + if not test_message :smtp 1 { + test_fail "two notifications should have been sent (#3 missing)"; + } + + if not envelope "to" "postmaster@frop.example.org" { + test_fail "message #3 unexpectedly missing from output"; + } + + if test_message :smtp 2 { + test_fail "too many notifications sent"; + } +} + +/* + * Denotify Middle + */ + +test_result_reset; + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test "Denotify ID Middle" { + /* #1 */ + notify :options "timo@example.com" :id "aap"; + + /* #2 */ + notify :options "stephan@dovecot.example.net" :id "noot"; + + /* #3 */ + notify :options "postmaster@frop.example.org" :id "mies"; + + denotify :is "noot"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + if not test_message :smtp 0 { + test_fail "two notifications should have been sent (#1 missing)"; + } + + if not envelope "to" "timo@example.com" { + test_fail "message #1 unexpectedly missing from output"; + } + + if not test_message :smtp 1 { + test_fail "two notifications should have been sent (#3 missing)"; + } + + if not envelope "to" "postmaster@frop.example.org" { + test_fail "message #3 unexpectedly missing from output"; + } + + if test_message :smtp 2 { + test_fail "too many notifications sent"; + } +} + +/* + * Denotify Last + */ + +test_result_reset; + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test "Denotify ID Last" { + /* #1 */ + notify :options "timo@example.com" :id "aap"; + + /* #2 */ + notify :options "stephan@dovecot.example.net" :id "noot"; + + /* #3 */ + notify :options "postmaster@frop.example.org" :id "mies"; + + denotify :is "mies"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + if not test_message :smtp 0 { + test_fail "two notifications should have been sent (#1 missing)"; + } + + if not envelope "to" "timo@example.com" { + test_fail "message #1 unexpectedly missing from output"; + } + + if not test_message :smtp 1 { + test_fail "two notifications should have been sent (#2 missing)"; + } + + if not envelope "to" "stephan@dovecot.example.net" { + test_fail "message #2 unexpectedly missing from output"; + } + + if test_message :smtp 2 { + test_fail "too many notifications sent"; + } +} + + +/* + * Denotify Matching + */ + +test_result_reset; + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test "Denotify Matching" { + /* #1 */ + notify :options "timo@example.com" :id "frop"; + + /* #2 */ + notify :options "stephan@dovecot.example.net" :id "noot"; + + /* #3 */ + notify :options "postmaster@frop.example.org" :id "friep"; + + denotify :matches "fr*"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + if not test_message :smtp 0 { + test_fail "one notification should have been sent"; + } + + if not envelope "to" "stephan@dovecot.example.net" { + test_fail "message #2 unexpectedly missing from output"; + } + + if test_message :smtp 1 { + test_fail "too many notifications sent"; + } +} + + +/* + * Denotify Matching + */ + +test_result_reset; + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test "Denotify Matching Importance" { + /* #1 */ + notify :options "timo@example.com" :id "frop" :low; + + /* #2 */ + notify :options "stephan@dovecot.example.net" :id "frml" :high; + + /* #3 */ + notify :options "postmaster@frop.example.org" :id "friep" :low; + + denotify :matches "fr*" :low; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + if not test_message :smtp 0 { + test_fail "one notification should have been sent"; + } + + if not envelope "to" "stephan@dovecot.example.net" { + test_fail "message #2 unexpectedly missing from output"; + } + + if test_message :smtp 1 { + test_fail "too many notifications sent"; + } +} + + diff --git a/pigeonhole/tests/deprecated/notify/errors.svtest b/pigeonhole/tests/deprecated/notify/errors.svtest new file mode 100644 index 0000000..549cb6b --- /dev/null +++ b/pigeonhole/tests/deprecated/notify/errors.svtest @@ -0,0 +1,33 @@ +require "vnd.dovecot.testsuite"; +require "comparator-i;ascii-numeric"; +require "relational"; + +test "Invalid :options argument (FIXME: count only)" { + if test_script_compile "errors/options.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"; + } +} + +test "Deprecated notify extension used with enotify" { + if test_script_compile "errors/conflict.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"; + } +} + +test "Deprecated notify extension used with enotify (ihave)" { + if test_script_compile "errors/conflict-ihave.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/deprecated/notify/errors/conflict-ihave.sieve b/pigeonhole/tests/deprecated/notify/errors/conflict-ihave.sieve new file mode 100644 index 0000000..9686f03 --- /dev/null +++ b/pigeonhole/tests/deprecated/notify/errors/conflict-ihave.sieve @@ -0,0 +1,8 @@ +require "enotify"; +require "ihave"; + +# 1: Conflict +if ihave "notify" { + # 2: Syntax wrong for enotify (and not skipped in compile) + notify :options "frop@frop.example.org"; +} diff --git a/pigeonhole/tests/deprecated/notify/errors/conflict.sieve b/pigeonhole/tests/deprecated/notify/errors/conflict.sieve new file mode 100644 index 0000000..46a6283 --- /dev/null +++ b/pigeonhole/tests/deprecated/notify/errors/conflict.sieve @@ -0,0 +1,4 @@ +require "enotify"; +require "notify"; + +notify :options "frop@frop.example.org"; diff --git a/pigeonhole/tests/deprecated/notify/errors/options.sieve b/pigeonhole/tests/deprecated/notify/errors/options.sieve new file mode 100644 index 0000000..c86fea0 --- /dev/null +++ b/pigeonhole/tests/deprecated/notify/errors/options.sieve @@ -0,0 +1,11 @@ +require "notify"; + +# 1: empty option +notify :options ""; + +# 2: invalid address syntax +notify :options "frop#frop.example.org"; + +# Valid +notify :options "frop@frop.example.org"; + diff --git a/pigeonhole/tests/deprecated/notify/execute.svtest b/pigeonhole/tests/deprecated/notify/execute.svtest new file mode 100644 index 0000000..90fde47 --- /dev/null +++ b/pigeonhole/tests/deprecated/notify/execute.svtest @@ -0,0 +1,25 @@ +require "vnd.dovecot.testsuite"; +require "relational"; + + +/* + * Execution testing (currently just meant to trigger any segfaults) + */ + +test "Duplicate recipients" { + if not test_script_compile "execute/duplicates.sieve" { + test_fail "script compile failed"; + } + + if not test_script_run { + test_fail "script execute failed"; + } + + if test_result_action :count "ne" "2" { + test_fail "second notify action was discarded entirely"; + } + + if not test_result_execute { + test_fail "result execute failed"; + } +} diff --git a/pigeonhole/tests/deprecated/notify/execute/duplicates.sieve b/pigeonhole/tests/deprecated/notify/execute/duplicates.sieve new file mode 100644 index 0000000..ef3fa5f --- /dev/null +++ b/pigeonhole/tests/deprecated/notify/execute/duplicates.sieve @@ -0,0 +1,4 @@ +require "notify"; + +notify :message "Incoming stupidity." :options ["stephan@example.org", "stephan@friep.example.com", "idiot@example.org"]; +notify :message "There it is." :options ["tss@example.net", "stephan@example.org", "idiot@example.org", "nico@frop.example.org", "stephan@friep.example.com"]; diff --git a/pigeonhole/tests/deprecated/notify/mailto.svtest b/pigeonhole/tests/deprecated/notify/mailto.svtest new file mode 100644 index 0000000..1724339 --- /dev/null +++ b/pigeonhole/tests/deprecated/notify/mailto.svtest @@ -0,0 +1,317 @@ +require "vnd.dovecot.testsuite"; + +require "notify"; +require "body"; +require "relational"; +require "comparator-i;ascii-numeric"; + +/* + * Simple test + */ + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test "Simple" { + notify :method "mailto" :options "stephan@example.org"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not header :matches "Auto-Submitted" "auto-generated*" { + test_fail "auto-submitted header set inappropriately"; + } + + if not exists "X-Sieve" { + test_fail "x-sieve header missing from outgoing message"; + } +} + +/* + * Multiple recipients + */ + +test_result_reset; + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test "Multiple recipients" { + notify :options ["timo@example.com","stephan@dovecot.example.net","postmaster@frop.example.org"]; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not address :is "to" "timo@example.com" { + test_fail "first To address missing"; + } + + test_message :smtp 1; + + if not address :is "to" "stephan@dovecot.example.net" { + test_fail "second To address missing"; + } + + if not header :matches "Auto-Submitted" "auto-generated*" { + test_fail "auto-submitted header not found for second message"; + } + + test_message :smtp 2; + + if not address :is "to" "postmaster@frop.example.org" { + test_fail "third To address missing"; + } + + if not header :matches "Auto-Submitted" "auto-generated*" { + test_fail "auto-submitted header not found for third message"; + } + + if not address :count "eq" :comparator "i;ascii-numeric" "to" "3" { + test_fail "wrong number of recipients in To header"; + } + + if not address :count "eq" :comparator "i;ascii-numeric" "cc" "0" { + test_fail "too many recipients in Cc header"; + } +} + +/* + * Duplicate recipients + */ + +test_result_reset; + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test "Duplicate recipients" { + notify :options ["timo@example.com", "stephan@dovecot.example.net", "stephan@dovecot.example.net"]; + notify :options ["timo@example.com", "stephan@example.org"]; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 2; + + if address "To" "stephan@dovecot.example.net" { + test_fail "duplicate recipient not removed from first message"; + } + + if address "To" "timo@example.com" { + test_fail "duplicate recipient not removed from second message"; + } +} + +/* + * Notifying on automated messages + */ + +test_result_reset; + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Auto-submitted: auto-notify +Subject: Frop! + +Klutsefluts. +. +; + +test "Notifying on automated messages" { + notify :options "stephan@example.org"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + if test_message :smtp 0 { + test_fail "notified of auto-submitted message"; + } +} + +test_result_reset; + +test_set "message" text: +To: nico@frop.example.org +From: stephan@example.org +Subject: Test + +Test. Test +Frop! +. +; + +test "Body; Singular Message" { + notify :low :id "frop" :options "stephan@example.org" + :message text: +Received interesting message: + +$text$ + +You have been notified. +. +; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not body :raw :contains "Received interesting message" { + test_fail "notification has no heading"; + } + + if not body :raw :contains "You have been notified" { + test_fail "notification has no footer"; + } + + if not allof( + body :raw :contains "Test. Test", + body :raw :contains "Frop" ) { + test_fail "notification has no original message"; + } +} + +test_result_reset; + +test_set "message" text: +To: nico@frop.example.org +From: stephan@example.org +Subject: Test + +Test. Test +Frop! +. +; + +test "Body; $text[maxsize]$" { + notify :low :id "frop" :options "sirius@example.org" + :message text: +Received interesting message: + +$text[5]$ + +You have been notified. +. +; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not body :raw :contains "Received interesting message" { + test_fail "notification has no heading"; + } + + if not body :raw :contains "You have been notified" { + test_fail "notification has no footer"; + } + + if anyof( + body :raw :contains "Test. Test", + body :raw :contains "Frop" ) { + test_fail "original message in notification is not truncated"; + } + + if not body :raw :contains "Test." { + test_fail "notification does not contain the required message"; + } +} + +test_result_reset; + +test_set "message" text: +From: Whomever <whoever@example.com> +To: Someone <someone@example.com> +Date: Sat, 10 Oct 2009 00:30:04 +0200 +Subject: whatever +Content-Type: multipart/mixed; boundary=outer + +This is a multi-part message in MIME format. + +--outer +Content-Type: multipart/alternative; boundary=inner + +This is a nested multi-part message in MIME format. + +--inner +Content-Type: application/sieve; charset="us-ascii" + +keep; + +--inner +Content-Type: text/plain; charset="us-ascii" + +Friep! + +--inner-- + +This is the end of the inner MIME multipart. + +--outer +Content-Type: message/rfc822 + +From: Someone Else +Subject: hello request + +Please say Hello + +--outer-- + +This is the end of the outer MIME multipart. +. +; + +test "Body; Multipart Message" { + notify :low :id "frop" :options "stephan@example.org" + :message text: +Received interesting message: + +$text$ + +You have been notified. +. +; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not body :raw :contains "Friep!" { + test_fail "notification has incorrect content"; + } +} + + + |