From f7548d6d28c313cf80e6f3ef89aed16a19815df1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:51:24 +0200 Subject: Adding upstream version 1:2.3.19.1+dfsg1. Signed-off-by: Daniel Baumann --- .../tests/extensions/subaddress/basic.svtest | 111 +++++++++++++++++++++ .../tests/extensions/subaddress/config.svtest | 85 ++++++++++++++++ pigeonhole/tests/extensions/subaddress/rfc.svtest | 59 +++++++++++ 3 files changed, 255 insertions(+) create mode 100644 pigeonhole/tests/extensions/subaddress/basic.svtest create mode 100644 pigeonhole/tests/extensions/subaddress/config.svtest create mode 100644 pigeonhole/tests/extensions/subaddress/rfc.svtest (limited to 'pigeonhole/tests/extensions/subaddress') diff --git a/pigeonhole/tests/extensions/subaddress/basic.svtest b/pigeonhole/tests/extensions/subaddress/basic.svtest new file mode 100644 index 0000000..e62d65d --- /dev/null +++ b/pigeonhole/tests/extensions/subaddress/basic.svtest @@ -0,0 +1,111 @@ +require "vnd.dovecot.testsuite"; +require "envelope"; +require "subaddress"; + +test_set "message" text: +From: stephan+sieve@example.org +To: test+failed@example.com +Subject: subaddress test + +Test! +. +; + +test_set "envelope.to" "friep+frop@dovecot.example.net"; +test_set "envelope.from" "list+request@lists.dovecot.example.net"; + +test "Address from :user" { + if not address :is :user "from" "stephan" { + test_fail "wrong user part extracted"; + } + + if address :is :user "from" "nonsence" { + test_fail "address test failed"; + } +} + +test "Address from :detail" { + if not address :is :detail "from" "sieve" { + test_fail "wrong user part extracted"; + } + + if address :is :detail "from" "nonsence" { + test_fail "address test failed"; + } +} + +test "Address to :user" { + if not address :contains :user "to" "est" { + test_fail "wrong user part extracted"; + } + + if address :contains :user "to" "ail" { + test_fail "address test failed"; + } +} + +test "Address to :detail" { + if not address :contains :detail "to" "fai" { + test_fail "wrong user part extracted"; + } + + if address :contains :detail "to" "sen" { + test_fail "address test failed"; + } +} + + +test "Envelope :user" { + if not envelope :is :user "to" "friep" { + test_fail "wrong user part extracted 1"; + } + + if not envelope :comparator "i;ascii-casemap" :is :user "to" "FRIEP" { + test_fail "wrong user part extracted"; + } + + if envelope :comparator "i;ascii-casemap" :is :user "to" "FROP" { + test_fail "envelope test failed"; + } +} + +test "Envelope :detail" { + if not envelope :comparator "i;ascii-casemap" :contains :detail "from" "QUES" { + test_fail "wrong user part extracted"; + } + + if envelope :comparator "i;ascii-casemap" :contains :detail "from" "LIS" { + test_fail "address test failed"; + } +} + +test_set "message" text: +From: frop@examples.com +To: undisclosed-recipients:; +Subject: subaddress test + +Test! +. +; + +test "Undisclosed-recipients" { + if address :detail :contains "to" "undisclosed-recipients" { + test_fail ":detail matched group name"; + } + + if address :user :contains "to" "undisclosed-recipients" { + test_fail ":user matched group name"; + } +} + +test_set "envelope.to" "frop@sieve.example.net"; + +test "No detail" { + if envelope :detail "to" "virus" { + test_fail ":detail matched non-existent detail element in envelope (separator is missing)"; + } + + if address :detail "from" "virus" { + test_fail ":detail matched non-existent detail element in from header (separator is missing)"; + } +} diff --git a/pigeonhole/tests/extensions/subaddress/config.svtest b/pigeonhole/tests/extensions/subaddress/config.svtest new file mode 100644 index 0000000..071aa12 --- /dev/null +++ b/pigeonhole/tests/extensions/subaddress/config.svtest @@ -0,0 +1,85 @@ +require "vnd.dovecot.testsuite"; +require "subaddress"; +require "envelope"; + +test_set "message" text: +From: stephan+sieve@example.org +To: test-failed@example.com +Subject: subaddress test + +Test! +. +; + +test_set "envelope.to" "friep+-frop@dovecot.example.net"; +test_set "envelope.from" "list_request@lists.dovecot.example.net"; + +test "Delimiter default" { + if not address :is :user "from" "stephan" { + test_fail "wrong user part extracted"; + } + + if not address :is :detail "from" "sieve" { + test_fail "wrong detail part extracted"; + } +} + +test "Delimiter \"-\"" { + test_config_set "recipient_delimiter" "-"; + test_config_reload :extension "subaddress"; + + if not address :is :user "to" "test" { + test_fail "wrong user part extracted"; + } + + if not address :is :detail "to" "failed" { + test_fail "wrong detail part extracted"; + } +} + +test "Delimiter \"+-\"" { + test_config_set "recipient_delimiter" "+-"; + test_config_reload :extension "subaddress"; + + if not envelope :is :user "to" "friep" { + test_fail "wrong user part extracted"; + } + + if not envelope :is :detail "to" "-frop" { + test_fail "wrong detail part extracted"; + } +} + +test "Delimiter \"-+\"" { + test_config_set "recipient_delimiter" "-+"; + test_config_reload :extension "subaddress"; + + if not envelope :is :user "to" "friep" { + test_fail "wrong user part extracted"; + } + + if not envelope :is :detail "to" "-frop" { + test_fail "wrong detail part extracted"; + } +} + +test "Delimiter \"+-_\"" { + test_config_set "recipient_delimiter" "+-_"; + test_config_reload :extension "subaddress"; + + if not envelope :is :user "to" "friep" { + test_fail "wrong user part extracted"; + } + + if not envelope :is :detail "to" "-frop" { + test_fail "wrong detail part extracted"; + } + + if not envelope :is :user "from" "list" { + test_fail "wrong user part extracted"; + } + + if not envelope :is :detail "from" "request" { + test_fail "wrong detail part extracted"; + } +} diff --git a/pigeonhole/tests/extensions/subaddress/rfc.svtest b/pigeonhole/tests/extensions/subaddress/rfc.svtest new file mode 100644 index 0000000..5615c53 --- /dev/null +++ b/pigeonhole/tests/extensions/subaddress/rfc.svtest @@ -0,0 +1,59 @@ +require "vnd.dovecot.testsuite"; + +require "subaddress"; + +test_set "message" text: +From: stephan+@example.org +To: timo+spam@example.net +CC: nico@example.com +Subject: fetch my spam + +Mouhahahaha... Spam! +. +; + + +/* + * The ":user" argument specifies the user sub-part of the local-part of + * an address. If the address is not encoded to contain a detail sub- + * part, then ":user" specifies the entire left side of the address + * (equivalent to ":localpart"). + */ + +test "User sub-part" { + if not address :user "cc" "nico" { + test_fail "wrong :user part extracted (1)"; + } + + if not address :user "to" "timo" { + test_fail "wrong :user part extracted (2)"; + } + + if not address :user "from" "stephan" { + test_fail "wrong :user part extracted (3)"; + } +} + +/* The ":detail" argument specifies the detail sub-part of the local- + * part of an address. If the address is not encoded to contain a + * detail sub-part, then the address fails to match any of the specified + * keys. If a zero-length string is encoded as the detail sub-part, + * then ":detail" resolves to the empty value (""). + */ + +test "Detail sub-part" { + if not address :detail "to" "spam" { + test_fail "wrong :detail part extracted"; + } + + if anyof ( + address :detail :matches "cc" ["*", "?"], + address :detail :contains "cc" "", + address :detail :is "cc" "" ) { + test_fail ":detail inappropriately matched missing detail sub-part"; + } + + if not address :detail "from" "" { + test_fail "wrong empty :detail part extracted"; + } +} -- cgit v1.2.3