summaryrefslogtreecommitdiffstats
path: root/pigeonhole/tests/extensions/subaddress/rfc.svtest
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
commitf7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch)
treea3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /pigeonhole/tests/extensions/subaddress/rfc.svtest
parentInitial commit. (diff)
downloaddovecot-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/rfc.svtest')
-rw-r--r--pigeonhole/tests/extensions/subaddress/rfc.svtest59
1 files changed, 59 insertions, 0 deletions
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";
+ }
+}