utf-8.svtest   [plain text]


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

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

Frop
.
;

test "UTF-8 Subject" {
	/* Trigger vacation response with rediculous Russian subject */
	vacation :subject "Auto: Я могу есть стекло, оно мне не вредит."
		"I am not in today"; 

	/* Execute Sieve result (sending message to dummy SMTP) */
	if not test_result_execute {
		test_fail "execution of result failed";
	}

	/* Retrieve message from dummy SMTP and set it as the active message under
	 * test.
	 */
	test_message :smtp 0;

	set "expected" "Auto: Я могу есть стекло, оно мне не вредит.";
	if not header :is "subject" "${expected}" {
		if header :matches "subject" "*" { set "subject" "${1}"; }

		test_fail text:
subject header is not encoded/decoded properly:
expected: ${expected}
decoded: ${subject}
.
;
	}
}

test_result_reset;

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

Frop
.
;


test "MIME Encoded Subject" {
	/* Trigger vacation response with rediculous Russian subject */
	vacation :subject "=?utf-8?b?w4TDlsOc?= sadasd"
		"I am not in today"; 

	/* Execute Sieve result (sending message to dummy SMTP) */
	if not test_result_execute {
		test_fail "execution of result failed";
	}

	/* Retrieve message from dummy SMTP and set it as the active message under
	 * test.
	 */
	test_message :smtp 0;

	set "expected" "ÄÖÜ sadasd";
	if not header :is "subject" "${expected}" {
		if header :matches "subject" "*" { set "subject" "${1}"; }

		test_fail text:
subject header is not encoded/decoded properly:
expected: ${expected}
decoded: ${subject}
.
;
	}
}