dovecot-2.2-pigeonhole: test suite: mime extension: Added more t...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Sun Jan 3 21:06:55 UTC 2016


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/2ccde5ca8fd4
changeset: 2199:2ccde5ca8fd4
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sun Jan 03 22:06:50 2016 +0100
description:
test suite: mime extension: Added more test for exists and address tests with :mime tag.

diffstat:

 Makefile.am                          |    2 +
 tests/extensions/mime/address.svtest |  281 +++++++++++++++++++++++++++++++++++
 tests/extensions/mime/exists.svtest  |  237 +++++++++++++++++++++++++++++
 3 files changed, 520 insertions(+), 0 deletions(-)

diffs (truncated from 538 to 300 lines):

diff -r 658ddaa1457f -r 2ccde5ca8fd4 Makefile.am
--- a/Makefile.am	Sun Jan 03 19:39:32 2016 +0100
+++ b/Makefile.am	Sun Jan 03 22:06:50 2016 +0100
@@ -168,6 +168,8 @@
 	tests/extensions/metadata/errors.svtest \
 	tests/extensions/mime/errors.svtest \
 	tests/extensions/mime/header.svtest \
+	tests/extensions/mime/exists.svtest \
+	tests/extensions/mime/address.svtest \
 	tests/extensions/mime/execute.svtest \
 	tests/extensions/mime/content-header.svtest \
 	tests/extensions/mime/foreverypart.svtest \
diff -r 658ddaa1457f -r 2ccde5ca8fd4 tests/extensions/mime/address.svtest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/extensions/mime/address.svtest	Sun Jan 03 22:06:50 2016 +0100
@@ -0,0 +1,281 @@
+require "vnd.dovecot.testsuite";
+require "mime";
+require "foreverypart";
+
+/*
+ * Basic functionionality
+ */
+
+test_set "message" text:
+From: stephan at example.com
+To: nico at nl.example.com, harry at de.example.com
+cc: Timo <tss(no spam)@fi.iki>
+Subject: Frobnitzm
+
+Test.
+.
+;
+
+test "Basic functionality" {
+	/* Must match */
+	if not address :mime :anychild :contains ["to", "from"] "harry" {
+		test_fail "failed to match address (1)";
+	}
+
+	if not address :mime :anychild :contains ["to", "from"] "de.example" {
+		test_fail "failed to match address (2)";
+	}
+
+	if not address :mime :anychild :matches "to" "*@*.example.com" {
+		test_fail "failed to match address (3)";
+	}
+
+	if not address :mime :anychild :is "to" "harry at de.example.com" {
+		test_fail "failed to match address (4)";
+	}
+
+	/* Must not match */
+	if address :mime :anychild :is ["to", "from"] "nonsense at example.com" {
+		test_fail "matches erroneous address";
+	}
+
+	/* Match first key */
+	if not address :mime :anychild :contains ["to"] ["nico", "fred", "henk"] {
+		test_fail "failed to match first key";
+	}
+
+	/* Match second key */
+	if not address :mime :anychild :contains ["to"] ["fred", "nico", "henk"] {
+		test_fail "failed to match second key";
+	}
+
+	/* Match last key */
+	if not address :mime :anychild :contains ["to"] ["fred", "henk", "nico"] {
+		test_fail "failed to match last key";
+	}
+
+	/* First header */
+	if not address :mime :anychild :contains
+		["to", "from"] ["fred", "nico", "henk"] {
+		test_fail "failed to match first header";
+	}
+
+	/* Second header */
+	if not address :mime :anychild :contains
+		["from", "to"] ["fred", "nico", "henk"] {
+		test_fail "failed to match second header";
+	}
+
+	/* Comment */
+	if not address :mime :anychild :is "cc" "tss at fi.iki" {
+		test_fail "failed to ignore comment in address";
+	}
+}
+
+/*
+ * Basic functionionality - foreverypart
+ */
+
+test "Basic functionality - foreverypart" {
+	foreverypart {
+		/* Must match */
+		if not address :mime :anychild :contains ["to", "from"] "harry" {
+			test_fail "failed to match address (1)";
+		}
+
+		if not address :mime :anychild :contains ["to", "from"] "de.example" {
+			test_fail "failed to match address (2)";
+		}
+
+		if not address :mime :anychild :matches "to" "*@*.example.com" {
+			test_fail "failed to match address (3)";
+		}
+
+		if not address :mime :anychild :is "to" "harry at de.example.com" {
+			test_fail "failed to match address (4)";
+		}
+
+		/* Must not match */
+		if address :mime :anychild :is ["to", "from"] "nonsense at example.com" {
+			test_fail "matches erroneous address";
+		}
+
+		/* Match first key */
+		if not address :mime :anychild :contains ["to"] ["nico", "fred", "henk"] {
+			test_fail "failed to match first key";
+		}
+
+		/* Match second key */
+		if not address :mime :anychild :contains ["to"] ["fred", "nico", "henk"] {
+			test_fail "failed to match second key";
+		}
+
+		/* Match last key */
+		if not address :mime :anychild :contains ["to"] ["fred", "henk", "nico"] {
+			test_fail "failed to match last key";
+		}
+
+		/* First header */
+		if not address :mime :anychild :contains
+			["to", "from"] ["fred", "nico", "henk"] {
+			test_fail "failed to match first header";
+		}
+
+		/* Second header */
+		if not address :mime :anychild :contains
+			["from", "to"] ["fred", "nico", "henk"] {
+			test_fail "failed to match second header";
+		}
+
+		/* Comment */
+		if not address :mime :anychild :is "cc" "tss at fi.iki" {
+			test_fail "failed to ignore comment in address";
+		}
+	}
+}
+
+/*
+ * Address headers
+ */
+
+test_set "message" text:
+From: stephan at friep.frop
+To: henk at tukkerland.ex
+CC: ivo at boer.ex
+Bcc: joop at hooibaal.ex
+Sender: s.bosch at friep.frop
+Resent-From: ivo at boer.ex
+Resent-To: idioot at dombo.ex
+Subject: Berichtje
+
+Test.
+.
+;
+
+test "Address headers" {
+	if not address :mime :anychild "from" "stephan at friep.frop" {
+		test_fail "from header not recognized";
+	}
+
+	if not address :mime :anychild "to" "henk at tukkerland.ex" {
+		test_fail "to header not recognized";
+	}
+
+	if not address :mime :anychild "cc" "ivo at boer.ex" {
+		test_fail "cc header not recognized";
+	}
+
+	if not address :mime :anychild "bcc" "joop at hooibaal.ex" {
+		test_fail "bcc header not recognized";
+	}
+
+	if not address :mime :anychild "sender" "s.bosch at friep.frop" {
+		test_fail "sender header not recognized";
+	}
+
+	if not address :mime :anychild "resent-from" "ivo at boer.ex" {
+		test_fail "resent-from header not recognized";
+	}
+
+	if not address :mime :anychild "resent-to" "idioot at dombo.ex" {
+		test_fail "resent-to header not recognized";
+	}
+}
+
+/*
+ * Address headers - foreverypart
+ */
+
+test "Address headers - foreverypart" {
+	foreverypart {
+		if not address :mime :anychild "from" "stephan at friep.frop" {
+			test_fail "from header not recognized";
+		}
+
+		if not address :mime :anychild "to" "henk at tukkerland.ex" {
+			test_fail "to header not recognized";
+		}
+
+		if not address :mime :anychild "cc" "ivo at boer.ex" {
+			test_fail "cc header not recognized";
+		}
+
+		if not address :mime :anychild "bcc" "joop at hooibaal.ex" {
+			test_fail "bcc header not recognized";
+		}
+
+		if not address :mime :anychild "sender" "s.bosch at friep.frop" {
+			test_fail "sender header not recognized";
+		}
+
+		if not address :mime :anychild "resent-from" "ivo at boer.ex" {
+			test_fail "resent-from header not recognized";
+		}
+
+		if not address :mime :anychild "resent-to" "idioot at dombo.ex" {
+			test_fail "resent-to header not recognized";
+		}
+	}
+}
+
+/*
+ * Multipart anychild
+ */
+
+test_set "message" text:
+From: Hendrik <hendrik at example.com>
+To: Harrie <harrie at example.com>
+Date: Sat, 11 Oct 2010 00:31:44 +0200
+Subject: Harrie is een prutser
+Content-Type: multipart/mixed; boundary=AA
+CC: AA at example.com
+
+This is a multi-part message in MIME format.
+--AA
+Content-Type: multipart/mixed; boundary=BB
+CC: BB at example.com
+
+This is a multi-part message in MIME format.
+--BB
+Content-Type: text/plain; charset="us-ascii"
+CC: CC at example.com
+
+Hello
+
+--BB
+Content-Type: text/plain; charset="us-ascii"
+CC: DD at example.com
+
+Hello again
+
+--BB--
+This is the end of MIME multipart.
+
+--AA
+Content-Type: text/plain; charset="us-ascii"
+CC: EE at example.com
+
+And again
+
+--AA--
+This is the end of  MIME multipart.
+.
+;
+
+test "Multipart anychild" {
+	if not address :mime :anychild :localpart "Cc" "AA" {
+		test_fail "AA Cc repient does not exist";
+	}
+	if not address :mime :anychild :localpart "Cc" "BB" {
+		test_fail "BB Cc repient does not exist";
+	}
+	if not address :mime :anychild :localpart "Cc" "CC" {
+		test_fail "CC Cc repient does not exist";
+	}
+	if not address :mime :anychild :localpart "Cc" "DD" {
+		test_fail "DD Cc repient does not exist";
+	}
+	if not address :mime :anychild :localpart "Cc" "EE" {
+		test_fail "EE Cc repient does not exist";
+	}
+}
diff -r 658ddaa1457f -r 2ccde5ca8fd4 tests/extensions/mime/exists.svtest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/extensions/mime/exists.svtest	Sun Jan 03 22:06:50 2016 +0100


More information about the dovecot-cvs mailing list