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/vnd.dovecot | |
parent | Initial commit. (diff) | |
download | dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.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/vnd.dovecot')
6 files changed, 363 insertions, 0 deletions
diff --git a/pigeonhole/tests/extensions/vnd.dovecot/debug/execute.svtest b/pigeonhole/tests/extensions/vnd.dovecot/debug/execute.svtest new file mode 100644 index 0000000..6d67024 --- /dev/null +++ b/pigeonhole/tests/extensions/vnd.dovecot/debug/execute.svtest @@ -0,0 +1,6 @@ +require "vnd.dovecot.testsuite"; +require "vnd.dovecot.debug"; + +test "Basic" { + debug_log "logging basic message."; +} diff --git a/pigeonhole/tests/extensions/vnd.dovecot/environment/basic.svtest b/pigeonhole/tests/extensions/vnd.dovecot/environment/basic.svtest new file mode 100644 index 0000000..c58bbc0 --- /dev/null +++ b/pigeonhole/tests/extensions/vnd.dovecot/environment/basic.svtest @@ -0,0 +1,29 @@ +require "vnd.dovecot.testsuite"; +require "vnd.dovecot.environment"; +require "variables"; + +test "default-mailbox" { + if not environment :is "vnd.dovecot.default-mailbox" "INBOX" { + if environment :matches "vnd.dovecot.default-mailbox" "*" { set "env" "${1}"; } + + test_fail "vnd.dovecot.default-mailbox environment returned invalid value(1): `${env}'"; + } +} + +test "username" { + if not environment :contains "vnd.dovecot.username" "" { + test_fail "vnd.dovecot.username environment does not exist"; + } +} + +test_config_set "sieve_env_display_name" "Jan Jansen"; +test_config_reload :extension "vnd.dovecot.environment"; + +test "config" { + if not environment :contains "vnd.dovecot.config.display_name" "" { + test_fail "vnd.dovecot.config.display_name environment does not exist"; + } + if not environment :is "vnd.dovecot.config.display_name" "Jan Jansen" { + test_fail "vnd.dovecot.config.display_name environment has wrong value"; + } +} diff --git a/pigeonhole/tests/extensions/vnd.dovecot/environment/variables.svtest b/pigeonhole/tests/extensions/vnd.dovecot/environment/variables.svtest new file mode 100644 index 0000000..886e75e --- /dev/null +++ b/pigeonhole/tests/extensions/vnd.dovecot/environment/variables.svtest @@ -0,0 +1,18 @@ +require "vnd.dovecot.testsuite"; +require "vnd.dovecot.environment"; +require "variables"; +require "relational"; + +test "default_mailbox" { + if not string "${env.vnd.dovecot.default_mailbox}" "INBOX" { + test_fail "The env.vnd.dovecot.default_mailbox variable returned invalid value: `${env.vnd.dovecot.default_mailbox}'"; + } +} + +test "username" { + set :length "userlen" "${env.vnd.dovecot.username}"; + if not string :value "ge" "${userlen}" "1" { + test_fail "The env.vnd.dovecot.username variable is empty or does not exist"; + } +} + diff --git a/pigeonhole/tests/extensions/vnd.dovecot/report/errors.svtest b/pigeonhole/tests/extensions/vnd.dovecot/report/errors.svtest new file mode 100644 index 0000000..82ab992 --- /dev/null +++ b/pigeonhole/tests/extensions/vnd.dovecot/report/errors.svtest @@ -0,0 +1,13 @@ +require "vnd.dovecot.testsuite"; +require "comparator-i;ascii-numeric"; +require "relational"; + +test "Invalid syntax (FIXME: count only)" { + if test_script_compile "errors/syntax.sieve" { + test_fail "compile should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "9" { + test_fail "wrong number of errors reported"; + } +} diff --git a/pigeonhole/tests/extensions/vnd.dovecot/report/errors/syntax.sieve b/pigeonhole/tests/extensions/vnd.dovecot/report/errors/syntax.sieve new file mode 100644 index 0000000..250ad60 --- /dev/null +++ b/pigeonhole/tests/extensions/vnd.dovecot/report/errors/syntax.sieve @@ -0,0 +1,28 @@ +require "vnd.dovecot.report"; + +# 1: Too few arguments +report; + +# 2: Too few arguments +report "abuse"; + +# 3: Too few arguments +report "abuse" "Message is spam."; + +# Not an error +report "abuse" "Message is spam." "frop@example.com"; + +# 4: Bad arguments +report "abuse" "Message is spam." 1; + +# 5: Bad tag +report :frop "abuse" "Message is spam." "frop@example.com"; + +# 6: Bad sub-test +report "abuse" "Message is spam." "frop@example.com" frop; + +# 7: Bad block +report "abuse" "Message is spam." "frop@example.com" { } + +# 8: Bad feedback type +report "?????" "Message is spam." "frop@example.com"; diff --git a/pigeonhole/tests/extensions/vnd.dovecot/report/execute.svtest b/pigeonhole/tests/extensions/vnd.dovecot/report/execute.svtest new file mode 100644 index 0000000..11a8079 --- /dev/null +++ b/pigeonhole/tests/extensions/vnd.dovecot/report/execute.svtest @@ -0,0 +1,269 @@ +require "vnd.dovecot.testsuite"; +require "vnd.dovecot.report"; +require "relational"; +require "comparator-i;ascii-numeric"; +require "body"; +require "variables"; + +/* + * Simple test + */ + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test "Simple" { + report "abuse" "This message is spam!" "abuse@example.com"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not body :raw :contains "This message is spam!" { + test_fail "report does not contain user text"; + } + + if not body :raw :contains "Klutsefluts" { + test_fail "report does not contain message body"; + } +} + +/* + * Simple - :headers_only test + */ + +test_result_reset; + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test "Simple - :headers_only" { + report :headers_only "abuse" + "This message is spam!" "abuse@example.com"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not body :raw :contains "This message is spam!" { + test_fail "report does not contain user text"; + } + + if body :raw :contains "Klutsefluts" { + test_fail "report contains message body"; + } +} + +/* + * Configuration + */ + +set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +/* default */ + +test_set "message" "${message}"; +test_set "envelope.from" "from@example.com"; +test_set "envelope.to" "to@example.com"; +test_set "envelope.orig_to" "orig_to@example.com"; + +test_result_reset; + +test "Configuration - from default" { + report "abuse" "This message is spam!" "abuse@example.com"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not address :localpart "from" "postmaster" { + test_fail "not sent from postmaster"; + } +} + +/* from sender */ + +test_set "message" "${message}"; +test_set "envelope.from" "from@example.com"; +test_set "envelope.to" "to@example.com"; +test_set "envelope.orig_to" "orig_to@example.com"; + +test_config_set "sieve_report_from" "sender"; +test_config_reload :extension "vnd.dovecot.report"; +test_result_reset; + +test "Configuration - from sender" { + report "abuse" "This message is spam!" "abuse@example.com"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not address :localpart "from" "from" { + test_fail "not sent from sender"; + } +} + +/* from recipient */ + +test_set "message" "${message}"; +test_set "envelope.from" "from@example.com"; +test_set "envelope.to" "to@example.com"; +test_set "envelope.orig_to" "orig_to@example.com"; + +test_config_set "sieve_report_from" "recipient"; +test_config_reload :extension "vnd.dovecot.report"; +test_result_reset; + +test "Configuration - from recipient" { + report "abuse" "This message is spam!" "abuse@example.com"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not address :localpart "from" "to" { + test_fail "not sent from recipient"; + } +} + +/* from original recipient */ + +test_set "message" "${message}"; +test_set "envelope.from" "from@example.com"; +test_set "envelope.to" "to@example.com"; +test_set "envelope.orig_to" "orig_to@example.com"; + +test_config_set "sieve_report_from" "orig_recipient"; +test_config_reload :extension "vnd.dovecot.report"; +test_result_reset; + +test "Configuration - from original recipient" { + report "abuse" "This message is spam!" "abuse@example.com"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not address :localpart "from" "orig_to" { + test_fail "not sent from original recipient"; + } +} + +/* from user email */ + +test_set "message" "${message}"; +test_set "envelope.from" "from@example.com"; +test_set "envelope.to" "to@example.com"; +test_set "envelope.orig_to" "orig_to@example.com"; + +test_config_set "sieve_report_from" "user_email"; +test_config_set "sieve_user_email" "user@example.com"; +test_config_reload; +test_config_reload :extension "vnd.dovecot.report"; +test_result_reset; + +test "Configuration - from user email" { + report "abuse" "This message is spam!" "abuse@example.com"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not address :localpart "from" "user" { + test_fail "not sent from user email"; + } +} + +/* explicit */ + +test_set "message" "${message}"; +test_set "envelope.from" "from@example.com"; +test_set "envelope.to" "to@example.com"; +test_set "envelope.orig_to" "orig_to@example.com"; + +test_config_set "sieve_report_from" "<frop@example.com>"; +test_config_reload :extension "vnd.dovecot.report"; +test_result_reset; + +test "Configuration - explicit" { + report "abuse" "This message is spam!" "abuse@example.com"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not address :localpart "from" "frop" { + test_fail "not sent from explicit address"; + } +} + +/* + * Reporting-User + */ + +/* sieve_user_email */ + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test_set "envelope.orig_to" "orig_to@example.com"; + +test_config_set "sieve_user_email" "newuser@example.com"; +test_config_reload; +test_result_reset; + +test "Reporting-User - sieve_user_email" { + report "abuse" "This message is spam!" "abuse@example.com"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not body :raw :contains "Dovecot-Reporting-User: <newuser@example.com>" { + test_fail "Reporting-User field is wrong."; + } +}
\ No newline at end of file |