diff --git a/Makefile.am b/Makefile.am index 4da531e0658618a4aa2d853c9f8981d215e9ac45..7301d367792fcb7081503b9548369b928e49faaa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -85,7 +85,11 @@ test_cases = \ tests/extensions/enotify/mailto.svtest \ tests/extensions/environment/basic.svtest \ tests/extensions/environment/rfc.svtest \ - tests/multiscript/basic.svtest + tests/multiscript/basic.svtest \ + tests/deprecated/notify/basic.svtest \ + tests/deprecated/notify/mailto.svtest \ + tests/deprecated/notify/errors.svtest \ + tests/deprecated/notify/execute.svtest if HAVE_DOVECOT_LIBS diff --git a/tests/deprecated/notify/basic.svtest b/tests/deprecated/notify/basic.svtest new file mode 100644 index 0000000000000000000000000000000000000000..72eed36822615805b401b24088e1cbe302c8d6e0 --- /dev/null +++ b/tests/deprecated/notify/basic.svtest @@ -0,0 +1,11 @@ +require "vnd.dovecot.testsuite"; +require "notify"; + +test "Execute" { + /* Test to catch runtime segfaults */ + notify + :message "This is probably very important" + :low + :method "mailto" + :options ["stephan@example.com", "stephan@rename-it.nl"]; +} diff --git a/tests/deprecated/notify/errors.svtest b/tests/deprecated/notify/errors.svtest new file mode 100644 index 0000000000000000000000000000000000000000..d1f1325a4e21a99d86b2fee7a25f01b9ffd90ec0 --- /dev/null +++ b/tests/deprecated/notify/errors.svtest @@ -0,0 +1,13 @@ +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"; + } +} diff --git a/tests/deprecated/notify/errors/options.sieve b/tests/deprecated/notify/errors/options.sieve new file mode 100644 index 0000000000000000000000000000000000000000..e93741b39403d1ccddde0165d82534b8d5b7a057 --- /dev/null +++ b/tests/deprecated/notify/errors/options.sieve @@ -0,0 +1,11 @@ +require "notify"; + +# 1: empty option +notify :options ""; + +# 2: invalid address syntax +notify :options "frop#vestingbar.nl"; + +# Valid +notify :options "frop@vestingbar.nl"; + diff --git a/tests/deprecated/notify/execute.svtest b/tests/deprecated/notify/execute.svtest new file mode 100644 index 0000000000000000000000000000000000000000..83ca40141ab8cbd467b8b5671b9b4af7ba076cc7 --- /dev/null +++ b/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 :count "ne" "2" { + test_fail "second notify action was discarded entirely"; + } + + if not test_result_execute { + test_fail "result execute failed"; + } +} diff --git a/tests/deprecated/notify/execute/duplicates.sieve b/tests/deprecated/notify/execute/duplicates.sieve new file mode 100644 index 0000000000000000000000000000000000000000..8f185c3fc7598b99620e748626c135bba901d0f4 --- /dev/null +++ b/tests/deprecated/notify/execute/duplicates.sieve @@ -0,0 +1,4 @@ +require "notify"; + +notify :message "Incoming stupidity." :options ["stephan@rename-it.nl", "stephan@drunksnipers.com", "idiot@rename-it.nl"]; +notify :message "There it is." :options ["tss@iki.fi", "stephan@rename-it.nl", "idiot@rename-it.nl", "nico@vestingbar.nl", "stephan@drunksnipers.com"]; diff --git a/tests/deprecated/notify/mailto.svtest b/tests/deprecated/notify/mailto.svtest new file mode 100644 index 0000000000000000000000000000000000000000..37b83c97578450cbfd4f787b6b48afcdd19173f5 --- /dev/null +++ b/tests/deprecated/notify/mailto.svtest @@ -0,0 +1,155 @@ +require "vnd.dovecot.testsuite"; +require "notify"; +require "relational"; +require "comparator-i;ascii-numeric"; + +/* + * Simple test + */ + +test_set "message" text: +From: stephan@rename-it.nl +To: nico@vestingbar.nl +Subject: Frop! + +Klutsefluts. +. +; + +test "Simple" { + notify :method "mailto" :options "stephan@rename-it.nl"; + + 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@rename-it.nl +To: nico@vestingbar.nl +Subject: Frop! + +Klutsefluts. +. +; + +test "Multiple recipients" { + notify :options ["timo@example.com","stephan@dovecot.org","postmaster@vestingbar.nl"]; + + 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.org" { + 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@vestingbar.nl" { + 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" "1" { + test_fail "too many 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@rename-it.nl +To: nico@vestingbar.nl +Subject: Frop! + +Klutsefluts. +. +; + +test "Duplicate recipients" { + notify :options ["timo@example.com", "stephan@dovecot.org", "stephan@dovecot.org"]; + notify :options ["timo@example.com", "stephan@rename-it.nl"]; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 2; + + if address "To" "stephan@dovecot.org" { + 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@rename-it.nl +To: nico@vestingbar.nl +Auto-submitted: auto-notify +Subject: Frop! + +Klutsefluts. +. +; + +test "Notifying on automated messages" { + notify :options "stephan@rename-it.nl"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + if test_message :smtp 0 { + test_fail "notified of auto-submitted message"; + } +} +