message.svtest   [plain text]


require "vnd.dovecot.testsuite";
require "vacation";
require "variables";
require "body";

test_set "message" text:
From: stephan@example.org
Subject: frop
References: <1234@local.machine.example> <3456@example.net>
 <435444@ttms.example.org> <4223@froop.example.net> <m345444444@message-id.exp>
Message-ID: <432df324@example.org>
To: nico@frop.example.org

Frop
.
;

test "References" {
	vacation "I am not in today!";

	if not test_result_execute {
		test_fail "execution of result failed";
	}

	test_message :smtp 0;

	if not header :contains "references" "432df324@example.org" {
		test_fail "references header does not contain new id";
	}

	if anyof ( 
		not header :contains "references" "1234@local.machine.example", 
		not header :contains "references" "3456@example.net",
		not header :contains "references" "435444@ttms.example.org", 
		not header :contains "references" "4223@froop.example.net", 
		not header :contains "references" "m345444444@message-id.exp" 
		) {
		test_fail "references header does not contain all existing ids";
	}

	if header :contains "references" "hutsefluts" {
		test_fail "references header contains nonsense";
	}
}

test "In-Reply-To" {
	if not header :is "in-reply-to" "<432df324@example.org>" {
		test_fail "in-reply-to header set incorrectly";
	}
}

test_result_reset;

test_set "message" text:
From: stephan@example.org
Subject: frop
References: <1234@local.machine.example> <3456@example.net>
 <435444@ttms.example.org> <4223@froop.example.net> <m345444444@message-id.exp>
Message-ID: <432df324@example.org>
To: nico@frop.example.org

Frop
.
;

test "Variables" {
	set "message" "I am not in today!";
	set "subject" "Out of office";
	set "from" "user@example.com";

	vacation :from "${from}" :subject "${subject}" "${message}";

	if not test_result_execute {
		test_fail "execution of result failed";
	}

	test_message :smtp 0;

	if not header :contains "subject" "Out of office" {
		test_fail "subject not set properly";
	}

	if not header :contains "from" "user@example.com" {
		test_fail "from address not set properly";
	}

	if not body :contains :raw "I am not in today!" {
		test_fail "message not set properly";
	}
}