dovecot-2.2-pigeonhole: test suite: mime extension: Improved hea...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Sat Jan 2 18:36:06 UTC 2016
details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/b5edf3efbdbb
changeset: 2192:b5edf3efbdbb
user: Stephan Bosch <stephan at rename-it.nl>
date: Sat Jan 02 19:36:01 2016 +0100
description:
test suite: mime extension: Improved header test cases to catch header trimming and folding problems.
diffstat:
tests/extensions/mime/header.svtest | 168 ++++++++++++++++++++++++++++++++++-
1 files changed, 163 insertions(+), 5 deletions(-)
diffs (223 lines):
diff -r 123020846e51 -r b5edf3efbdbb tests/extensions/mime/header.svtest
--- a/tests/extensions/mime/header.svtest Sat Jan 02 19:35:24 2016 +0100
+++ b/tests/extensions/mime/header.svtest Sat Jan 02 19:36:01 2016 +0100
@@ -1,5 +1,6 @@
require "vnd.dovecot.testsuite";
require "variables";
+require "foreverypart";
require "mime";
/*
@@ -70,6 +71,63 @@
}
/*
+ * Basic functionality - foreverypart
+ */
+
+test "Basic functionality - foreverypart" {
+ foreverypart {
+ /* Must match */
+ if not header :mime :anychild :contains ["Subject", "Comments"] "Frobnitzm" {
+ test_fail "failed to match header (1)";
+ }
+
+ if not header :mime :anychild :contains ["Subject", "Comments"] "nonsense" {
+ test_fail "failed to match header(2)";
+ }
+
+ if not header :mime :anychild :matches "Keywords" "*, strange, *" {
+ test_fail "failed to match header (3)";
+ }
+
+ if not header :mime :anychild :is "Comments" "This is nonsense." {
+ test_fail "failed to match header (4)";
+ }
+
+ /* Must not match */
+ if header :mime :anychild ["subject", "comments", "keywords"] "idiotic" {
+ test_fail "matched nonsense";
+ }
+
+ /* Match first key */
+ if not header :mime :anychild :contains ["keywords"] ["strange", "snot", "vreemd"] {
+ test_fail "failed to match first key";
+ }
+
+ /* Match second key */
+ if not header :mime :anychild :contains ["keywords"] ["raar", "strange", "vreemd"] {
+ test_fail "failed to match second key";
+ }
+
+ /* Match last key */
+ if not header :mime :anychild :contains ["keywords"] ["raar", "snot", "strange"] {
+ test_fail "failed to match last key";
+ }
+
+ /* First header */
+ if not header :mime :anychild :contains ["keywords", "subject"]
+ ["raar", "strange", "vreemd"] {
+ test_fail "failed to match first header";
+ }
+
+ /* Second header */
+ if not header :mime :anychild :contains ["subject", "keywords"]
+ ["raar", "strange", "vreemd"] {
+ test_fail "failed to match second header";
+ }
+ }
+}
+
+/*
* Matching empty key
*/
@@ -103,6 +161,30 @@
}
/*
+ * Matching empty key - foreverypart
+ */
+
+test "Matching empty key - foreverypart" {
+ foreverypart {
+ if header :mime :anychild :is "X-Caffeine" "" {
+ test_fail ":is-matched non-empty header with empty string";
+ }
+
+ if not header :mime :anychild :contains "X-Caffeine" "" {
+ test_fail "failed to match existing header with empty string";
+ }
+
+ if not header :mime :anychild :is "comments" "" {
+ test_fail "failed to match empty header :mime :anychild with empty string";
+ }
+
+ if header :mime :anychild :contains "X-Nonsense" "" {
+ test_fail ":contains-matched non-existent header with empty string";
+ }
+ }
+}
+
+/*
* Ignoring whitespace
*/
@@ -141,6 +223,35 @@
}
/*
+ * Ignoring whitespace - foreverypart
+ */
+
+test "Ignoring whitespace - foreverypart" {
+ foreverypart {
+ if not header :mime :anychild :is "x-a" "Text" {
+ if header :mime :anychild :matches "x-a" "*" {
+ set "header" "${1}";
+ }
+ test_fail "header :mime :anychild test does not strip leading whitespace (header=`${header}`)";
+ }
+
+ if not header :mime :anychild :is "x-b" "Text" {
+ if header :mime :anychild :matches "x-b" "*" {
+ set "header" "${1}";
+ }
+ test_fail "header :mime :anychild test does not strip trailing whitespace (header=`${header}`)";
+ }
+
+ if not header :mime :anychild :is "subject" "Help" {
+ if header :mime :anychild :matches "subject" "*" {
+ set "header" "${1}";
+ }
+ test_fail "header :mime :anychild test does not strip both leading and trailing whitespace (header=`${header}`)";
+ }
+ }
+}
+
+/*
* Absent or empty header
*/
@@ -170,6 +281,27 @@
}
/*
+ * Absent or empty header - foreverypart
+ */
+
+test "Absent or empty header - foreverypart" {
+ foreverypart {
+ if not header :mime :anychild :matches "Cc" "?*" {
+ test_fail "CC header is not absent or empty";
+ }
+
+ if header :mime :anychild :matches "Subject" "?*" {
+ test_fail "Subject header is empty, but matched otherwise";
+ }
+
+ if header :mime :anychild :matches "Comment" "?*" {
+ test_fail "Comment header is empty, but matched otherwise";
+ }
+ }
+}
+
+
+/*
* Invalid header name
*/
@@ -196,12 +328,23 @@
}
/*
- * Folded headers
+ * Invalid header name - foreverypart
*/
-/* "Header lines are unfolded as described in [RFC 2822] section 2.2.3.
- * ...
- * "
+test "Invalid header name - foreverypart" {
+ foreverypart {
+ if header :mime :anychild :contains "subject:" "" {
+ test_fail "matched invalid header name";
+ }
+
+ if header :mime :anychild :contains "to!" "" {
+ test_fail "matched invalid header name";
+ }
+ }
+}
+
+/*
+ * Folded headers
*/
test_set "message" text:
@@ -216,9 +359,24 @@
.
;
-test "Folded header" {
+test "Folded headers" {
if not header :mime :anychild :is "x-multiline"
"This is a multi-line header body, which should be unfolded correctly." {
test_fail "failed to properly unfold folded header.";
}
}
+
+/*
+ * Folded headers - foreverypart
+ */
+
+test "Folded headers - foreverypart" {
+ foreverypart {
+ if not header :mime :anychild :is "x-multiline"
+ "This is a multi-line header body, which should be unfolded correctly." {
+ test_fail "failed to properly unfold folded header.";
+ }
+ }
+}
+
+
More information about the dovecot-cvs
mailing list