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/subaddress | |
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/subaddress')
-rw-r--r-- | pigeonhole/tests/extensions/subaddress/basic.svtest | 111 | ||||
-rw-r--r-- | pigeonhole/tests/extensions/subaddress/config.svtest | 85 | ||||
-rw-r--r-- | pigeonhole/tests/extensions/subaddress/rfc.svtest | 59 |
3 files changed, 255 insertions, 0 deletions
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"; + } +} |