require "vnd.dovecot.testsuite";
test_set "message" text:
From: stephan@example.org
Cc: frop@example.com
To: test@dovecot.example.net
X-Bullshit: f fr fro frop frob frobn frobnitzn
Subject: Test Message
Comment:
Test!
.
;
# Match tests
test "Match empty" {
if not header :contains "x-bullshit" "" {
test_fail "contains tests fails to match \"\" against non-empty string";
}
if not header :contains "comment" "" {
test_fail "contains tests fails to match \"\" against empty string";
}
}
test "Match full" {
if not address :contains "from" "stephan@example.org" {
test_fail "should have matched";
}
}
test "Match begin" {
if not address :contains "from" "stephan" {
test_fail "should have matched";
}
}
test "Match end" {
if not address :contains "from" "example.org" {
test_fail "should have matched";
}
}
test "Match middle" {
if not address :contains "from" "@" {
test_fail "should have matched";
}
}
test "Match similar beginnings" {
if not header :contains "x-bullshit" "frobnitzn" {
test_fail "should have matched";
}
}
test "Match case-insensitive" {
if not address :contains :comparator "i;ascii-casemap" "from" "EXAMPLE" {
test_fail "match fails to apply correct comparator";
}
if not address :contains "from" "EXAMPLE" {
test_fail "default comparator is wrong";
}
}
# Non-match tests
test "No match full (typo)" {
if address :contains "to" "frob@example.com" {
test_fail "should not have matched";
}
}
test "No match end (typo)" {
if header :contains "x-bullshit" "frobnitzm" {
test_fail "should not have matched";
}
}