diff options
Diffstat (limited to 'pigeonhole/tests/extensions/editheader')
17 files changed, 2809 insertions, 0 deletions
diff --git a/pigeonhole/tests/extensions/editheader/addheader.svtest b/pigeonhole/tests/extensions/editheader/addheader.svtest new file mode 100644 index 0000000..426b43d --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/addheader.svtest @@ -0,0 +1,833 @@ +require "vnd.dovecot.testsuite"; +require "encoded-character"; +require "variables"; +require "fileinto"; +require "mailbox"; +require "body"; + +require "editheader"; + +set "message" text: +From: stephan@example.com +To: timo@example.com +Subject: Frop! + +Frop! + +. +; + +test_set "message" "${message}"; +test "Addheader - first" { + if size :over 76 { + test_fail "original message is longer than 76 bytes?!"; + } + + addheader "X-Some-Header" "Header content"; + + if not size :over 76 { + test_fail "mail is not larger"; + } + + if size :over 107 { + test_fail "mail is too large"; + } + + if size :under 107 { + test_fail "mail is too small"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not exists "x-some-header" { + test_fail "header not added"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content added"; + } + + redirect "frop@example.com"; + fileinto :create "folder1"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder1" 0 { + test_fail "message not stored"; + } + + if not size :over 76 { + test_fail "stored mail is not larger"; + } + + if size :over 107 { + test_fail "stored mail is too large"; + } + + if size :under 100 { + test_fail "stored mail is too small"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not exists "x-some-header" { + test_fail "header not in stored mail"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content in stored mail "; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not exists "x-some-header" { + test_fail "header not in redirected mail"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content in redirected mail "; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_result_reset; +test_set "message" "${message}"; +test "Addheader - first (two)" { + if size :over 76 { + test_fail "original message is longer than 76 bytes?!"; + } + + addheader "X-Some-Header" "Header content"; + addheader "X-Some-Other-Header" "More header content"; + + if not size :over 76 { + test_fail "mail is not larger"; + } + + if size :over 149 { + test_fail "mail is too large"; + } + + if size :under 149 { + test_fail "mail is too small"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not exists "x-some-header" { + test_fail "header #1 not added"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content added #1"; + } + + if not exists "x-some-other-header" { + test_fail "header #2 not added"; + } + + if not header :is "x-some-other-header" "More header content" { + test_fail "wrong content added #2"; + } + + redirect "frop@example.com"; + fileinto :create "folder2"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder2" 0 { + test_fail "message not stored"; + } + + if not size :over 76 { + test_fail "stored mail is not larger"; + } + + if size :over 149 { + test_fail "stored mail is too large"; + } + + if size :under 100 { + test_fail "stored mail is too small"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not exists "x-some-header" { + test_fail "header #1 not in stored mail"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content #1 in stored mail "; + } + + if not exists "x-some-other-header" { + test_fail "header #2 not in stored mail"; + } + + if not header :is "x-some-other-header" "More header content" { + test_fail "wrong content #2 in stored mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not exists "x-some-header" { + test_fail "header not in redirected mail"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content in redirected mail "; + } + + if not exists "x-some-other-header" { + test_fail "header #2 not in redirected mail"; + } + + if not header :is "x-some-other-header" "More header content" { + test_fail "wrong content #2 in redirected mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_result_reset; +test_set "message" "${message}"; +test "Addheader - last" { + if size :over 76 { + test_fail "original message is longer than 76 bytes?!"; + } + + addheader :last "X-Some-Header" "Header content"; + + if not size :over 76 { + test_fail "mail is not larger"; + } + + if size :over 107 { + test_fail "mail is too large"; + } + + if size :under 107 { + test_fail "mail is too small"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not exists "x-some-header" { + test_fail "header not added"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content added"; + } + + redirect "frop@example.com"; + fileinto :create "folder3"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder3" 0 { + test_fail "message not stored"; + } + + if not size :over 76 { + test_fail "stored mail is not larger"; + } + + if size :over 107 { + test_fail "stored mail is too large"; + } + + if size :under 100 { + test_fail "stored mail is too small"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not exists "x-some-header" { + test_fail "header not in stored mail"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content in stored mail "; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not exists "x-some-header" { + test_fail "header not in redirected mail"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content in redirected mail "; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_result_reset; +test_set "message" "${message}"; +test "Addheader - last (two)" { + if size :over 76 { + test_fail "original message is longer than 76 bytes?!"; + } + + addheader :last "X-Some-Header" "Header content"; + addheader "X-Some-Other-Header" "More header content"; + + if not size :over 76 { + test_fail "mail is not larger"; + } + + if size :over 149 { + test_fail "mail is too large"; + } + + if size :under 149 { + test_fail "mail is too small"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not exists "x-some-header" { + test_fail "header #1 not added"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content added #1"; + } + + if not exists "x-some-other-header" { + test_fail "header #2 not added"; + } + + if not header :is "x-some-other-header" "More header content" { + test_fail "wrong content added #2"; + } + + redirect "frop@example.com"; + fileinto :create "folder4"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder4" 0 { + test_fail "message not stored"; + } + + if not size :over 76 { + test_fail "stored mail is not larger"; + } + + if size :over 149 { + test_fail "stored mail is too large"; + } + + if size :under 100 { + test_fail "stored mail is too small"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not exists "x-some-header" { + test_fail "header #1 not in stored mail"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content #1 in stored mail"; + } + + if not exists "x-some-other-header" { + test_fail "header #2 not in stored mail"; + } + + if not header :is "x-some-other-header" "More header content" { + test_fail "wrong content #2 in stored mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not exists "x-some-header" { + test_fail "header #1 not in redirected mail"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content #1 in redirected mail "; + } + + if not exists "x-some-other-header" { + test_fail "header #2 not in redirected mail"; + } + + if not header :is "x-some-other-header" "More header content" { + test_fail "wrong content #2 in redirected mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_result_reset; +test_set "message" "${message}"; +test "Addheader - framed" { + if size :over 76 { + test_fail "original message is longer than 76 bytes?!"; + } + + addheader "X-Some-Header-first" "Header content first"; + addheader :last "X-Some-Header-last" "Header content last"; + + if not size :over 76 { + test_fail "mail is not larger"; + } + + if size :over 160 { + test_fail "mail is too large"; + } + + if size :under 160 { + test_fail "mail is too small"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not exists "x-some-header-first" { + test_fail "first header not added"; + } + + if not exists "x-some-header-last" { + test_fail "last header not added"; + } + + if not header :is "x-some-header-first" "Header content first" { + test_fail "wrong first content added"; + } + + if not header :is "x-some-header-last" "Header content last" { + test_fail "wrong last content added"; + } + + redirect "frop@example.com"; + fileinto :create "folder5"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder5" 0 { + test_fail "message not stored"; + } + + if not size :over 76 { + test_fail "stored mail is not larger"; + } + + if size :over 160 { + test_fail "stored mail is too large"; + } + + if size :under 152 { + test_fail "stored mail is too small"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not exists "x-some-header-first" { + test_fail "first header not in stored mail"; + } + + if not exists "x-some-header-last" { + test_fail "last header not in stored mail"; + } + + if not header :is "x-some-header-first" "Header content first" { + test_fail "wrong first header content in stored mail "; + } + + if not header :is "x-some-header-last" "Header content last" { + test_fail "wrong last header content in stored mail "; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not exists "x-some-header-first" { + test_fail "first header not in redirected mail"; + } + + if not exists "x-some-header-last" { + test_fail "last header not in redirected mail"; + } + + if not header :is "x-some-header-first" "Header content first" { + test_fail "wrong first header content in redirected mail "; + } + + if not header :is "x-some-header-last" "Header content last" { + test_fail "wrong last header content in redirected mail "; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +/* + * Addheader - folded + */ + +test_result_reset; +test_set "message" "${message}"; +test "Addheader - folded" { + set "before" + "This is very long header content, folded to fit inside multiple header lines. This may cause problems, so that is why it is tested here."; + set "after" + "This is somewhat longer header content, folded to fit inside multiple header lines. This may cause problems, so that is why it is tested here."; + + addheader :last "X-Some-Header-first" "${before}"; + addheader :last "X-Some-Header-last" "${after}"; + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not exists "x-some-header-first" { + test_fail "first header not added"; + } + + if not exists "x-some-header-last" { + test_fail "last header not added"; + } + + if not header :is "x-some-header-first" "${before}" { + test_fail "wrong first content added"; + } + + if not header :is "x-some-header-last" "${after}" { + test_fail "wrong last content added"; + } + + redirect "frop@example.com"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not exists "x-some-header-first" { + test_fail "first header not in redirected mail"; + } + + if not exists "x-some-header-last" { + test_fail "last header not in redirected mail"; + } + + if not header :is "x-some-header-first" "${before}" { + test_fail "wrong first header content in redirected mail "; + } + + if not header :is "x-some-header-last" "${after}" { + test_fail "wrong last header content in redirected mail "; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +/* + * Addheader - newlines + */ + +test_result_reset; +test_set "message" "${message}"; +test "Addheader - newlines" { + set "before" text: +This is very long header content + containing newlines. This may + cause some problems, so that + is why it is tested here. +. +; + + set "after" text: +This is somewhat longer header content + containing newlines. This may + cause some problems, so that + is why it is tested here. +. +; + + set "before_out" + "This is very long header content containing newlines. This may cause some problems, so that is why it is tested here."; + + set "after_out" + "This is somewhat longer header content containing newlines. This may cause some problems, so that is why it is tested here."; + + addheader "X-Some-Header-first" "${before}"; + addheader :last "X-Some-Header-last" "${after}"; + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not exists "x-some-header-first" { + test_fail "first header not added"; + } + + if not exists "x-some-header-last" { + test_fail "last header not added"; + } + + if not header :is "x-some-header-first" "${before_out}" { + if header :matches "x-some-header-first" "*" {} + test_fail "wrong first content added: `${0}`"; + } + + if not header :is "x-some-header-last" "${after_out}" { + if header :matches "x-some-header-last" "*" {} + test_fail "wrong last content added: `${0}`"; + } + + redirect "frop@example.com"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not exists "x-some-header-first" { + test_fail "first header not in redirected mail"; + } + + if not exists "x-some-header-last" { + test_fail "last header not in redirected mail"; + } + + if not header :is "x-some-header-first" "${before_out}" { + if header :matches "x-some-header-first" "*" {} + test_fail "wrong first header content in redirected mail: `${0}`"; + } + + if not header :is "x-some-header-last" "${after_out}" { + if header :matches "x-some-header-last" "*" {} + test_fail "wrong last header content in redirected mail: `${0}`"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_result_reset; +test_set "message" "${message}"; +test "Addheader - implicit keep" { + if size :over 76 { + test_fail "original message is longer than 76 bytes?!"; + } + + addheader "X-Some-Header" "Header content"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "INBOX" 0 { + test_fail "message not stored"; + } + + if not size :over 76 { + test_fail "stored mail is not larger"; + } + + if size :over 107 { + test_fail "stored mail is too large"; + } + + if size :under 100 { + test_fail "stored mail is too small"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored message"; + } + + if not exists "x-some-header" { + test_fail "header not added to stored message"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content added to stored message"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } +} + +test_set "message" "${message}"; +test "Addheader - UTF 8" { + if size :over 76 { + test_fail "original message is longer than 76 bytes?!"; + } + + addheader "X-Some-Header" "Это тест!"; + fileinto :create "folder6"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder6" 0 { + test_fail "message not stored"; + } + + if not exists "x-some-header" { + test_fail "header not added to stored message"; + } + + if not header :is "x-some-header" "Это тест!" { + if header :matches "x-some-header" "*" {} + test_fail "Bel character not retained: `${0}`"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } +} + +test_result_reset; + +test_set "message" "${message}"; +test "Addheader - devious characters" { + if size :over 76 { + test_fail "original message is longer than 76 bytes?!"; + } + + addheader "X-Some-Header" "Ring my ${hex:07}!"; + fileinto :create "folder7"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder7" 0 { + test_fail "message not stored"; + } + + if not exists "x-some-header" { + test_fail "header not added to stored message"; + } + + if header :is "x-some-header" "Ring my !" { + if header :matches "x-some-header" "*" {} + test_fail "Bel character not retained: `${0}`"; + } + + if not header :is "x-some-header" "Ring my ${hex:07}!" { + if header :matches "x-some-header" "*" {} + test_fail "Incorrect header value: `${0}`"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } +} diff --git a/pigeonhole/tests/extensions/editheader/alternating.svtest b/pigeonhole/tests/extensions/editheader/alternating.svtest new file mode 100644 index 0000000..44d459c --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/alternating.svtest @@ -0,0 +1,181 @@ +require "vnd.dovecot.testsuite"; +require "variables"; +require "fileinto"; +require "mailbox"; +require "body"; + +require "editheader"; + +set "message" text: +From: stephan@example.com +To: timo@example.com +Subject: Frop! + +Frop! + +. +; + + +test_set "message" "${message}"; +test "Alternating - add; delete" { + addheader "X-Some-Header" "Header content"; + + if not exists "x-some-header" { + test_fail "header not added"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content added"; + } + + redirect "frop@example.com"; + + deleteheader "X-Some-Header"; + + if exists "x-some-header" { + test_fail "header not deleted"; + } + + fileinto :create "folder1"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + /* redirected message */ + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not exists "x-some-header" { + test_fail "added header not in redirected mail"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content in redirected mail "; + } + + /* stored message message */ + + if not test_message :folder "folder1" 0 { + test_fail "message not stored"; + } + + if exists "x-some-header" { + test_fail "added header still present stored mail"; + } +} + +test_result_reset; + +test_set "message" "${message}"; +test "Alternating - delete; add" { + deleteheader "Subject"; + + if exists "subject" { + test_fail "header not deleted"; + } + + redirect "frop@example.com"; + + addheader "Subject" "Friep!"; + + if not exists "subject" { + test_fail "header not added"; + } + + if not header :is "subject" "Friep!" { + test_fail "wrong content added"; + } + + fileinto :create "folder2"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + /* redirected message */ + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if exists "subject" { + test_fail "deleted header still present redirected mail"; + } + + /* stored message message */ + + if not test_message :folder "folder2" 0 { + test_fail "message not stored"; + } + + if not exists "subject" { + test_fail "added header not in stored mail"; + } + + if not header :is "subject" "Friep!" { + test_fail "wrong content in redirected mail "; + } +} + +test_result_reset; + +test_set "message" "${message}"; +test "Alternating - add :last; delete any" { + addheader :last "X-Some-Header" "Header content"; + + if not exists "x-some-header" { + test_fail "header not added"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content added"; + } + + redirect "frop@example.com"; + + deleteheader "X-Some-Other-Header"; + + if not exists "x-some-header" { + test_fail "header somehow deleted"; + } + + fileinto :create "folder3"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + /* redirected message */ + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not exists "x-some-header" { + test_fail "added header not in redirected mail"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content in redirected mail "; + } + + /* stored message message */ + + if not test_message :folder "folder3" 0 { + test_fail "message not stored"; + } + + if not exists "x-some-header" { + test_fail "added header lost in stored mail"; + } + + if not header :is "x-some-header" "Header content" { + test_fail "wrong content in stored mail "; + } + +} + diff --git a/pigeonhole/tests/extensions/editheader/deleteheader.svtest b/pigeonhole/tests/extensions/editheader/deleteheader.svtest new file mode 100644 index 0000000..8b9d3ad --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/deleteheader.svtest @@ -0,0 +1,1115 @@ +require "vnd.dovecot.testsuite"; +require "variables"; +require "fileinto"; +require "mailbox"; +require "body"; + +require "editheader"; + +set "message" text: +X-A: Onzinnige informatie +X-B: kun je maar beter +X-C: niet via e-mail versturen +From: stephan@example.com +X-D: en daarom is het nuttig +To: timo@example.com +Subject: Frop! +X-A: dit terstond te verwijderen, +X-B: omdat dit anders +X-C: alleen maar schijfruimte verspilt. + +Frop! + +. +; + +test_set "message" "${message}"; +test "Deleteheader - nonexistent" { + if size :over 288 { + test_fail "original message is longer than 288 bytes?!"; + } + + if size :under 288 { + test_fail "original message is shorter than 288 bytes?!"; + } + + deleteheader "X-Z"; + + if size :under 288 { + test_fail "message is shorter than original"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained"; + } + + redirect "frop@example.com"; + fileinto :create "folder1"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder1" 0 { + test_fail "message not stored"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained in stored mail"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained in stored mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained in redirected mail"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained in redirected mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_set "message" "${message}"; +test "Deleteheader - nonexistent (match)" { + if size :over 288 { + test_fail "original message is longer than 288 bytes?!"; + } + + if size :under 288 { + test_fail "original message is shorter than 288 bytes?!"; + } + + deleteheader :matches "X-Z" "*frop*"; + + if size :under 288 { + test_fail "message is shorter than original"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained"; + } + + redirect "frop@example.com"; + fileinto :create "folder1b"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder1b" 0 { + test_fail "message not stored"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained in stored mail"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained in stored mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained in redirected mail"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained in redirected mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_result_reset; +test_set "message" "${message}"; +test "Deleteheader - one" { + if size :over 288 { + test_fail "original message is longer than 288 bytes?!"; + } + + if size :under 288 { + test_fail "original message is shorter than 288 bytes?!"; + } + + deleteheader "X-D"; + + if not size :under 288 { + test_fail "edited message is not shorter"; + } + + if size :over 258 { + test_fail "edited message is too long"; + } + + if size :under 258 { + test_fail "edited message is too short"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained"; + } + + if exists "X-D" { + test_fail "X-D header not deleted"; + } + + redirect "frop@example.com"; + fileinto :create "folder2"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder2" 0 { + test_fail "message not stored"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained in stored mail"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained in stored mail"; + } + + if exists "X-D" { + test_fail "X-D header not deleted in stored mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained in redirected mail"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained in redirected mail"; + } + + if exists "X-D" { + test_fail "X-D header not deleted in redirected mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_result_reset; +test_set "message" "${message}"; +test "Deleteheader - two (first)" { + if size :over 288 { + test_fail "original message is longer than 288 bytes?!"; + } + + if size :under 288 { + test_fail "original message is shorter than 288 bytes?!"; + } + + deleteheader "X-A"; + + if not size :under 288 { + test_fail "edited message is not shorter"; + } + + if size :over 226 { + test_fail "edited message is too long"; + } + + if size :under 226 { + test_fail "edited message is too short"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained"; + } + + if exists "X-A" { + test_fail "X-A header not deleted"; + } + + redirect "frop@example.com"; + fileinto :create "folder3"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder3" 0 { + test_fail "message not stored"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained in stored mail"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained in stored mail"; + } + + if exists "X-A" { + test_fail "X-A header not deleted in stored mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained in redirected mail"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained in redirected mail"; + } + + if exists "X-A" { + test_fail "X-A header not deleted in redirected mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_result_reset; +test_set "message" "${message}"; +test "Deleteheader - two (last)" { + if size :over 288 { + test_fail "original message is longer than 288 bytes?!"; + } + + if size :under 288 { + test_fail "original message is shorter than 288 bytes?!"; + } + + deleteheader "X-C"; + + if not size :under 288 { + test_fail "edited message is not shorter"; + } + + if size :over 215 { + test_fail "edited message is too long"; + } + + if size :under 215 { + test_fail "edited message is too short"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not header :is "X-A" "dit terstond te verwijderen," { + test_fail "original X-A header not retained"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained"; + } + + if exists "X-C" { + test_fail "X-C header not deleted"; + } + + redirect "frop@example.com"; + fileinto :create "folder4"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder4" 0 { + test_fail "message not stored"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not header :is "X-A" "dit terstond te verwijderen," { + test_fail "original X-A header not retained in stored mail"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained in stored mail"; + } + + if exists "X-C" { + test_fail "X-C header not deleted in stored mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not header :is "X-A" "dit terstond te verwijderen," { + test_fail "original X-A header not retained in redirected mail"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained in redirected mail"; + } + + if exists "X-C" { + test_fail "X-C header not deleted in redirected mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_result_reset; +test_set "message" "${message}"; +test "Deleteheader - :index" { + if size :over 288 { + test_fail "original message is longer than 288 bytes?!"; + } + + if size :under 288 { + test_fail "original message is shorter than 288 bytes?!"; + } + + deleteheader :index 1 "X-A"; + deleteheader :index 2 "X-C"; + + if not size :under 288 { + test_fail "edited message is not shorter"; + } + + if size :over 220 { + test_fail "edited message is too long"; + } + + if size :under 220 { + test_fail "edited message is too short"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not header :is "X-A" "dit terstond te verwijderen," { + test_fail "original X-A (2) header not retained"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C (1) header not retained"; + } + + if header :is "X-A" "Onzinnige informatie" { + test_fail "original X-A (1) header not deleted"; + } + + if header :is "X-C" "alleen maar schijfruimte verspilt." { + test_fail "original X-C (2) header not deleted"; + } + + redirect "frop@example.com"; + fileinto :create "folder5"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder5" 0 { + test_fail "message not stored"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not header :is "X-A" "dit terstond te verwijderen," { + test_fail "original X-A (2) header not retained in stored mail"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C (1) header not retained in stored mail"; + } + + if header :is "X-A" "Onzinnige informatie" { + test_fail "original X-A (1) header not deleted in stored mail"; + } + + if header :is "X-C" "alleen maar schijfruimte verspilt." { + test_fail "original X-C (2) header not deleted in stored mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if not header :is "X-A" "dit terstond te verwijderen," { + test_fail "original X-A (2) header not retained redirected mail"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-B (1) header not retained redirected mail"; + } + + if header :is "X-A" "Onzinnige informatie" { + test_fail "original X-A (1) header not deleted redirected mail"; + } + + if header :is "X-C" "alleen maar schijfruimte verspilt." { + test_fail "original X-B (2) header not deleted redirected mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_result_reset; +test_set "message" "${message}"; +test "Deleteheader - :index :last" { + if size :over 288 { + test_fail "original message is longer than 288 bytes?!"; + } + + if size :under 288 { + test_fail "original message is shorter than 288 bytes?!"; + } + + deleteheader :index 1 :last "X-A"; + deleteheader :last :index 2 "X-C"; + + if size :over 221 { + test_fail "edited message is too long"; + } + + if size :under 221 { + test_fail "edited message is too short"; + } + + if not size :under 288 { + test_fail "edited message is not shorter"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained"; + } + + if not header :is "X-A" "Onzinnige informatie" { + test_fail "original X-A (1) header not retained"; + } + + if not header :is "X-C" "alleen maar schijfruimte verspilt." { + test_fail "original X-C (2) header not retained"; + } + + if header :is "X-A" "dit terstond te verwijderen," { + test_fail "original X-A (2) header not deleted"; + } + + if header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C (1) header not deleted"; + } + + redirect "frop@example.com"; + fileinto :create "folder6"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder6" 0 { + test_fail "message not stored"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not header :is "X-A" "Onzinnige informatie" { + test_fail "original X-A (1) header not retained in stored mail"; + } + + if not header :is "X-C" "alleen maar schijfruimte verspilt." { + test_fail "original X-C (2) header not retained in stored mail"; + } + + if header :is "X-A" "dit terstond te verwijderen," { + test_fail "original X-A (2) header not deleted in stored mail"; + } + + if header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C (1) header not deleted in stored mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in redirected mail"; + } + + if header :is "X-A" "dit terstond te verwijderen," { + test_fail "original X-A (2) header not deleted redirected mail"; + } + + if header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-B (1) header not deleted redirected mail"; + } + + if not header :is "X-A" "Onzinnige informatie" { + test_fail "original X-A (1) header not retained redirected mail"; + } + + if not header :is "X-C" "alleen maar schijfruimte verspilt." { + test_fail "original X-B (2) header not retained redirected mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_result_reset; +test_set "message" "${message}"; +test "Deleteheader - implicit keep" { + deleteheader "X-D"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "INBOX" 0 { + test_fail "message not stored"; + } + + if not header :is "subject" "Frop!" { + test_fail "original subject header not retained in stored mail"; + } + + if not header :is "X-B" "omdat dit anders" { + test_fail "original X-B header not retained in stored mail"; + } + + if not header :is "X-C" "niet via e-mail versturen" { + test_fail "original X-C header not retained in stored mail"; + } + + if exists "X-D" { + test_fail "X-D header not deleted in stored mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } +} + +/* + * + */ + +test_result_reset; + +test_set "message" text: +X-A: Dit is een klein verhaaltje +X-B: om te testen of de correcte +X-C: informatie wordt herkend en +X-D: verwijderd. Zo valt goed te +X-A: zien dat het allemaal werkt +X-B: zoals het bedoeld is. Alles +X-C: wordt in een keer getest op +X-D: een wijze die efficient die +X-A: problemen naar voren brengt +X-B: die bij dit nieuwe deel van +X-C: de programmatuur naar voren +X-D: kunnen komen. Zo werkt het! + +Frop! +. +; + +test "Deleteheader - :matches" { + if size :over 417 { + test_fail "original message is longer than 417 bytes?!"; + } + + if size :under 417 { + test_fail "original message is shorter than 417 bytes?!"; + } + + deleteheader :matches "X-A" "*klein*"; + deleteheader :matches "X-B" "*bedoeld*"; + deleteheader :matches "X-C" "*programmatuur*"; + deleteheader :contains "X-D" ["verwijderd", "!"]; + + if not size :under 417 { + test_fail "edited message is not shorter"; + } + + if size :over 247 { + test_fail "edited message is too long"; + } + + if size :under 247 { + test_fail "edited message is too short"; + } + + if not header :is "X-A" "zien dat het allemaal werkt" { + test_fail "original X-A (2) header not retained"; + } + + if not header :is "X-A" "problemen naar voren brengt" { + test_fail "original X-A (3) header not retained"; + } + + if not header :is "X-B" "om te testen of de correcte" { + test_fail "original X-B (1) header not retained"; + } + + if not header :is "X-B" "die bij dit nieuwe deel van" { + test_fail "original X-B (3) header not retained"; + } + + if not header :is "X-C" "informatie wordt herkend en" { + test_fail "original X-C (1) header not retained"; + } + + if not header :is "X-C" "wordt in een keer getest op" { + test_fail "original X-C (2) header not retained"; + } + + if not header :is "X-D" "een wijze die efficient die" { + test_fail "original X-C (2) header not retained"; + } + + if header :is "X-A" "Dit is een klein verhaaltje" { + test_fail "original X-A (1) header not deleted"; + } + + if header :is "X-B" "zoals het bedoeld is. Alles" { + test_fail "original X-B (2) header not deleted"; + } + + if header :is "X-C" "de programmatuur naar voren" { + test_fail "original X-C (3) header not deleted"; + } + + if header :is "X-D" "verwijderd. Zo valt goed te" { + test_fail "original X-C (1) header not deleted"; + } + + if header :is "X-D" "kunnen komen. Zo werkt het!" { + test_fail "original X-C (3) header not deleted"; + } + + redirect "frop@example.com"; + fileinto :create "folder7"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :folder "folder7" 0 { + test_fail "message not stored"; + } + + if not header :is "X-A" "zien dat het allemaal werkt" { + test_fail "original X-A (2) header not retained in stored mail"; + } + + if not header :is "X-A" "problemen naar voren brengt" { + test_fail "original X-A (3) header not retained in stored mail"; + } + + if not header :is "X-B" "om te testen of de correcte" { + test_fail "original X-B (1) header not retained in stored mail"; + } + + if not header :is "X-B" "die bij dit nieuwe deel van" { + test_fail "original X-B (3) header not retained in stored mail"; + } + + if not header :is "X-C" "informatie wordt herkend en" { + test_fail "original X-C (1) header not retained in stored mail"; + } + + if not header :is "X-C" "wordt in een keer getest op" { + test_fail "original X-C (2) header not retained in stored mail"; + } + + if not header :is "X-D" "een wijze die efficient die" { + test_fail "original X-C (2) header not retained in stored mail"; + } + + if header :is "X-A" "Dit is een klein verhaaltje" { + test_fail "original X-A (1) header not deleted in stored mail"; + } + + if header :is "X-B" "zoals het bedoeld is. Alles" { + test_fail "original X-B (2) header not deleted in stored mail"; + } + + if header :is "X-C" "de programmatuur naar voren" { + test_fail "original X-C (3) header not deleted in stored mail"; + } + + if header :is "X-D" "verwijderd. Zo valt goed te" { + test_fail "original X-C (1) header not deleted in stored mail"; + } + + if header :is "X-D" "kunnen komen. Zo werkt het!" { + test_fail "original X-C (3) header not deleted in stored mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in stored mail"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not header :is "X-A" "zien dat het allemaal werkt" { + test_fail "original X-A (2) header not retained in redirected mail"; + } + + if not header :is "X-A" "problemen naar voren brengt" { + test_fail "original X-A (3) header not retained in redirected mail"; + } + + if not header :is "X-B" "om te testen of de correcte" { + test_fail "original X-B (1) header not retained in redirected mail"; + } + + if not header :is "X-B" "die bij dit nieuwe deel van" { + test_fail "original X-B (3) header not retained in redirected mail"; + } + + if not header :is "X-C" "informatie wordt herkend en" { + test_fail "original X-C (1) header not retained in redirected mail"; + } + + if not header :is "X-C" "wordt in een keer getest op" { + test_fail "original X-C (2) header not retained in redirected mail"; + } + + if not header :is "X-D" "een wijze die efficient die" { + test_fail "original X-C (2) header not retained in redirected mail"; + } + + if header :is "X-A" "Dit is een klein verhaaltje" { + test_fail "original X-A (1) header not deleted in redirected mail"; + } + + if header :is "X-B" "zoals het bedoeld is. Alles" { + test_fail "original X-B (2) header not deleted in redirected mail"; + } + + if header :is "X-C" "de programmatuur naar voren" { + test_fail "original X-C (3) header not deleted in redirected mail"; + } + + if header :is "X-D" "verwijderd. Zo valt goed te" { + test_fail "original X-C (1) header not deleted in redirected mail"; + } + + if header :is "X-D" "kunnen komen. Zo werkt het!" { + test_fail "original X-C (3) header not deleted in redirected mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + + +/* + * + */ + +set "message2" text: +X-A: Long folded header to test removal of folded + headers from a message. This is the top header. +X-B: First intermittent unfolded header +X-A: Long folded header to test removal of folded + headers from a message. This is the middle header. +X-B: Second intermittent unfolded header +X-A: Long folded header to test removal of folded + headers from a message. This is the bottom header, + which concludes the header of this message. + +Frop! +. +; + +test_result_reset; +test_set "message" "${message2}"; +test "Deleteheader - folded" { + deleteheader "X-A"; + + if exists "X-A" { + test_fail "original X-A (1) header not deleted"; + } + + if not header :is "X-B" "First intermittent unfolded header" { + test_fail "original X-B (2) header not retained"; + } + + if not header :is "X-B" "Second intermittent unfolded header" { + test_fail "original X-B (2) header not retained"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } + + redirect "frop@example.com"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if exists "X-A" { + test_fail "original X-A (1) header not deleted in redirected mail"; + } + + if not header :is "X-B" "First intermittent unfolded header" { + test_fail "original X-B (2) header not retained in redirected mail"; + } + + if not header :is "X-B" "Second intermittent unfolded header" { + test_fail "original X-B (2) header not retained in redirected mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + +test_result_reset; +test_set "message" "${message2}"; +test "Deleteheader - folded (match)" { + deleteheader :matches "X-A" "*header*"; + + if exists "X-A" { + test_fail "original X-A (1) header not deleted"; + } + + if not header :is "X-B" "First intermittent unfolded header" { + test_fail "original X-B (2) header not retained"; + } + + if not header :is "X-B" "Second intermittent unfolded header" { + test_fail "original X-B (2) header not retained"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } + + redirect "frop@example.com"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if exists "X-A" { + test_fail "original X-A (1) header not deleted in redirected mail"; + } + + if not header :is "X-B" "First intermittent unfolded header" { + test_fail "original X-B (2) header not retained in redirected mail"; + } + + if not header :is "X-B" "Second intermittent unfolded header" { + test_fail "original X-B (2) header not retained in redirected mail"; + } + + if not body :matches "Frop!*" { + test_fail "body not retained in redirected mail"; + } +} + + +/* + * TEST: Ignoring whitespace + */ + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.com +Subject: Help +X-A: Text +X-B: Text + +Text +. +; + +test "Ignoring whitespace" { + deleteheader :is "subject" "Help"; + deleteheader :is "x-a" "Text"; + deleteheader :is "x-b" "Text"; + + if exists "subject" { + test_fail "subject header not deleted"; + } + + if exists "x-a" { + test_fail "x-a header not deleted"; + } + + if exists "x-b" { + test_fail "x-b header not deleted"; + } +} + +/* + * TEST: Interaction with body test + */ + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.com +Subject: Hoppa + +Text +. +; + +test "Interaction with body test" { + addheader "X-Frop" "frop"; + + if body "!TEST!" {} + + deleteheader "subject"; + + if exists "subject" { + test_fail "subject header not deleted"; + } +} + diff --git a/pigeonhole/tests/extensions/editheader/errors.svtest b/pigeonhole/tests/extensions/editheader/errors.svtest new file mode 100644 index 0000000..1d1f24d --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/errors.svtest @@ -0,0 +1,164 @@ +require "vnd.dovecot.testsuite"; +require "comparator-i;ascii-numeric"; +require "relational"; +require "variables"; + +require "editheader"; + +test "Invalid field-name" { + if test_script_compile "errors/field-name.sieve" { + test_fail "compile should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "5" { + test_fail "wrong number of errors reported"; + } + + if not test_error :index 1 :matches "*field name*X-field:*invalid*" { + test_fail "wrong error reported (1)"; + } + + if not test_error :index 2 :matches "*field name*X field*invalid*" { + test_fail "wrong error reported (2)"; + } + + if not test_error :index 3 :matches "*field name*X-field:*invalid*" { + test_fail "wrong error reported (3)"; + } + + if not test_error :index 4 :matches "*field name*X field*invalid*" { + test_fail "wrong error reported (4)"; + } +} + +test "Invalid field-name at runtime " { + if not test_script_compile "errors/field-name-runtime.sieve" { + test_fail "compile failed"; + } + + if test_script_run { + test_fail "run should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "1" { + test_fail "wrong number of errors reported"; + } + + if not test_error :matches "*field name*X-field:*invalid*" { + test_fail "wrong error reported"; + } +} + +test "Invalid field value" { + if test_script_compile "errors/field-value.sieve" { + test_fail "compile should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "2" { + test_fail "wrong number of errors reported"; + } + + if not test_error :index 1 :matches "*value*Woah*invalid*" { + test_fail "wrong error reported (1): ${0}"; + } +} + +test "Command syntax (FIXME: count only)" { + if test_script_compile "errors/command-syntax.sieve" { + test_fail "compile should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "10" { + test_fail "wrong number of errors reported"; + } +} + +/* + * TEST - Size limit + */ + +test "Size limit" { + if not test_script_compile "errors/size-limit.sieve" { + test_fail "compile should have succeeded"; + } + + test_config_set "sieve_editheader_max_header_size" "1024"; + test_config_reload :extension "editheader"; + + if test_script_compile "errors/size-limit.sieve" { + test_fail "compile should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "2" { + test_fail "wrong number of errors reported"; + } +} + + +/* + * TEST - Size limit at runtime + */ + +test_config_set "sieve_editheader_max_header_size" ""; +test_config_reload :extension "editheader"; + +test "Size limit at runtime" { + if not test_script_compile "errors/size-limit-runtime.sieve" { + test_fail "compile should have succeeded"; + } + + if not test_script_run { + test_fail "run failed"; + } + + test_config_set "sieve_editheader_max_header_size" "1024"; + test_config_reload :extension "editheader"; + + if not test_script_compile "errors/size-limit-runtime.sieve" { + test_fail "compile should have succeeded"; + } + + if test_script_run { + test_fail "run should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "1" { + test_fail "wrong number of errors reported"; + } +} + +/* + * TEST - Implicit keep at runtime error + */ + +test_set "message" text: +From: stephan@example.com +To: tss@example.com +Subject: Frop + +Frop! +. +; + +test "Implicit keep at runtime error" { + if not test_script_compile "errors/runtime-error.sieve" { + test_fail "compile failed"; + } + + if not test_script_run { + test_fail "run failed"; + } + + if test_result_execute { + test_fail "result execution should have failed"; + } + + if not test_message :folder "INBOX" 0 { + test_fail "message not stored (no implicit keep)"; + } + + if exists "X-Frop" { + test_fail "implicit keep message has editheader changes"; + } +} + diff --git a/pigeonhole/tests/extensions/editheader/errors/command-syntax.sieve b/pigeonhole/tests/extensions/editheader/errors/command-syntax.sieve new file mode 100644 index 0000000..8543e6d --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/errors/command-syntax.sieve @@ -0,0 +1,42 @@ +require "editheader"; + +/* "addheader" [":last"] <field-name: string> <value: string> + */ + +# 1: missing field name and value +addheader; + +# 2: missing value +addheader "x-frop"; + +# 3: value not a string; number +addheader "x-frop" 2; + +# 4: value not a string; list +addheader "x-frop" ["frop"]; + +# 5: strange tag +addheader :tag "x-frop" "frop"; + +/* "deleteheader" [":index" <fieldno: number> [":last"]] + * [COMPARATOR] [MATCH-TYPE] + * <field-name: string> + * [<value-patterns: string-list>] + */ + +# 6: missing field name +deleteheader; + +# 7: :last tag without index +deleteheader :last "x-frop"; + +# 8: :index tag with string argument +deleteheader :index "frop" "x-frop"; + +# OK: match type without value patterns +deleteheader :matches "x-frop"; + +# 9: value patterns not a string(list) +deleteheader "x-frop" 1; + + diff --git a/pigeonhole/tests/extensions/editheader/errors/field-name-runtime.sieve b/pigeonhole/tests/extensions/editheader/errors/field-name-runtime.sieve new file mode 100644 index 0000000..3f34461 --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/errors/field-name-runtime.sieve @@ -0,0 +1,6 @@ +require "editheader"; +require "variables"; + +set "header" "X-field:"; + +addheader "${header}" "Frop"; diff --git a/pigeonhole/tests/extensions/editheader/errors/field-name.sieve b/pigeonhole/tests/extensions/editheader/errors/field-name.sieve new file mode 100644 index 0000000..469bfc8 --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/errors/field-name.sieve @@ -0,0 +1,19 @@ +require "editheader"; + +# Ok +addheader "X-field" "Frop"; + +# Invalid ':' +addheader "X-field:" "Frop"; + +# Invalid ' ' +addheader "X field" "Frop"; + +# Ok +deleteheader "X-field"; + +# Invalid ':' +deleteheader "X-field:"; + +# Invalid ' ' +deleteheader "X field"; diff --git a/pigeonhole/tests/extensions/editheader/errors/field-value.sieve b/pigeonhole/tests/extensions/editheader/errors/field-value.sieve new file mode 100644 index 0000000..c9f4eab --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/errors/field-value.sieve @@ -0,0 +1,15 @@ +require "editheader"; +require "encoded-character"; + +# Ok +addheader "X-field" "Frop"; + +# Ok +addheader "X-field" "Frop +Frml"; + +# Invalid 'BELL'; but not an error +addheader "X-field" "Yeah${hex:07}!"; + +# Invalid 'NUL' +addheader "X-field" "Woah${hex:00}!"; diff --git a/pigeonhole/tests/extensions/editheader/errors/runtime-error.sieve b/pigeonhole/tests/extensions/editheader/errors/runtime-error.sieve new file mode 100644 index 0000000..b308d74 --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/errors/runtime-error.sieve @@ -0,0 +1,6 @@ +require "editheader"; +require "fileinto"; + +addheader "X-Frop" "Friep"; + +fileinto "Rediculous.non-existent.folder"; diff --git a/pigeonhole/tests/extensions/editheader/errors/size-limit-runtime.sieve b/pigeonhole/tests/extensions/editheader/errors/size-limit-runtime.sieve new file mode 100644 index 0000000..73a1437 --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/errors/size-limit-runtime.sieve @@ -0,0 +1,46 @@ +require "editheader"; +require "variables"; + +set "blob" text: +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +. +; + +addheader "x-frop" "${blob}"; diff --git a/pigeonhole/tests/extensions/editheader/errors/size-limit.sieve b/pigeonhole/tests/extensions/editheader/errors/size-limit.sieve new file mode 100644 index 0000000..598f5f9 --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/errors/size-limit.sieve @@ -0,0 +1,43 @@ +require "editheader"; + +addheader "x-frop" text: +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +. +; diff --git a/pigeonhole/tests/extensions/editheader/execute.svtest b/pigeonhole/tests/extensions/editheader/execute.svtest new file mode 100644 index 0000000..e65cc5d --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/execute.svtest @@ -0,0 +1,57 @@ +require "vnd.dovecot.testsuite"; +require "include"; +require "variables"; +require "editheader"; + +/* + * Testsuite self-test + */ + +set "message" "."; +addheader "X-Some-Header" "Header content"; +test_result_reset; +test_set "message" "${message}"; + +/* + * Multi script + */ + +test_result_reset; + +test_set "message" text: +From: idiot@example.com +To: idiot@example.org +Subject: Frop! + +Frop. +. +; + +test_result_reset; +test "Multi script" { + if not test_multiscript [ + "execute/multiscript-before.sieve", + "execute/multiscript-personal.sieve", + "execute/multiscript-after.sieve" + ] { + test_fail "failed to run all scripts"; + } + + test_message :folder "INBOX" 0; + + if not header "subject" "Frop!" { + test_fail "keep not executed."; + } + + if not header "X-Before" "before" { + test_fail "No X-Before header"; + } + + if not header "X-Personal" "personal" { + test_fail "No X-Personal header"; + } + + if not header "X-After" "after" { + test_fail "No X-After header"; + } +} diff --git a/pigeonhole/tests/extensions/editheader/execute/multiscript-after.sieve b/pigeonhole/tests/extensions/editheader/execute/multiscript-after.sieve new file mode 100644 index 0000000..f11f02d --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/execute/multiscript-after.sieve @@ -0,0 +1,4 @@ +require "editheader"; + +addheader "X-After" "after"; + diff --git a/pigeonhole/tests/extensions/editheader/execute/multiscript-before.sieve b/pigeonhole/tests/extensions/editheader/execute/multiscript-before.sieve new file mode 100644 index 0000000..5c8a988 --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/execute/multiscript-before.sieve @@ -0,0 +1,4 @@ +require "editheader"; + +addheader "X-Before" "before"; + diff --git a/pigeonhole/tests/extensions/editheader/execute/multiscript-personal.sieve b/pigeonhole/tests/extensions/editheader/execute/multiscript-personal.sieve new file mode 100644 index 0000000..92e82ac --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/execute/multiscript-personal.sieve @@ -0,0 +1,4 @@ +require "editheader"; + +addheader "X-Personal" "personal"; + diff --git a/pigeonhole/tests/extensions/editheader/protected.svtest b/pigeonhole/tests/extensions/editheader/protected.svtest new file mode 100644 index 0000000..148a9c8 --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/protected.svtest @@ -0,0 +1,173 @@ +require "vnd.dovecot.testsuite"; + +require "variables"; +require "encoded-character"; +require "editheader"; + +set "message" text: +Received: by example.com (Postfix, from userid 202) + id 32A131WFW23QWE4; Mon, 21 Nov 2011 05:25:26 +0200 (EET) +Delivery-date: Mon, 21 Nov 2011 04:26:04 +0100 +Auto-Submitted: yes +X-Friep: frop 3 +Subject: Frop! +From: stephan@example.com +To: tss@example.com + +Frop! +. +; + +test_set "message" "${message}"; +test "Default protected" { + if not exists "received" { + test_fail "received header did not exist in the first place"; + } + + if not exists "auto-submitted" { + test_fail "auto-submitted header did not exist in the first place"; + } + + deleteheader "received"; + deleteheader "auto-submitted"; + deleteheader "subject"; + + if not exists "received" { + test_fail "protected received header was deleted"; + } + + if not exists "auto-submitted" { + test_fail "protected auto-submitted header was deleted"; + } + + if exists "subject" { + test_fail "subject header cannot be protected, but it was not deleted"; + } +} + +test_config_set "sieve_editheader_protected" "subject delivery-date x-frop"; +test_config_reload :extension "editheader"; + +test_set "message" "${message}"; +test "Configured protected" { + if not exists "delivery-date" { + test_fail "received header did not exist in the first place"; + } + + if not exists "subject" { + test_fail "received header did not exist in the first place"; + } + + if exists "x-frop" { + test_fail "x-frop header already present"; + } + + deleteheader "delivery-date"; + deleteheader "subject"; + addheader "x-frop" "Frop!"; + + if not exists "delivery-date" { + test_fail "protected delivery-date header was deleted"; + } + + if exists "subject" { + test_fail "subject header cannot be protected, but it was not deleted"; + } + + if exists "x-frop" { + test_fail "protected x-frop header was added"; + } +} + +test_config_set "sieve_editheader_protected" ""; +test_config_set "sieve_editheader_forbid_add" "subject x-frop"; +test_config_set "sieve_editheader_forbid_delete" "subject x-friep"; +test_config_reload :extension "editheader"; + +test_set "message" "${message}"; +test "Configured forbid_add/forbid_delete" { + if not exists "delivery-date" { + test_fail "received header did not exist in the first place"; + } + + if not exists "subject" { + test_fail "received header did not exist in the first place"; + } + + if not exists "x-friep" { + test_fail "x-friep header did not exist in the first place"; + } + + if exists "x-frop" { + test_fail "x-frop header already present"; + } + + deleteheader "delivery-date"; + deleteheader "subject"; + deleteheader "x-friep"; + + if exists "delivery-date" { + test_fail "unprotected delivery-date header was not deleted"; + } + + if exists "subject" { + test_fail "subject header cannot be protected, but it was not deleted"; + } + + if not exists "x-friep" { + test_fail "protected x-friep header was deleted"; + } + + addheader "delivery-date" "Yesterday"; + addheader "subject" "Fropfrop!"; + addheader "x-frop" "Frop!"; + addheader "received" text: +by sieve.example.com (My little Sieve script) +id 3jhl22khhf23f; Mon, 24 Aug 2015 04:11:54 -0600; +. +; + addheader "auto-submitted" "no way"; + + if not header "delivery-date" "Yesterday" { + test_fail "unprotected delivery-date header was not added"; + } + + if not header "subject" "Fropfrop!" { + test_fail "subject header cannot be protected, but it was not added"; + } + + if exists "x-frop" { + test_fail "protected x-frop header was added"; + } + + if not header :contains "received" "sieve.example.com" { + test_fail "received header was not added"; + } + + if not header "auto-submitted" "no way" { + test_fail "autosubmitted header was not added"; + } +} + +/* + * TEST - Bad header configuration + */ + +test_config_set "sieve_editheader_protected" "${unicode:1F4A9} delivery-date"; +test_config_reload :extension "editheader"; + +test_set "message" "${message}"; +test "Bad header configuration" { + if not exists "delivery-date" { + test_fail "delivery-date header did not exist in the first place"; + } + + deleteheader "delivery-date"; + + if not exists "delivery-date" { + test_fail "protected delivery-date header was deleted"; + } +} + +test_config_set "sieve_editheader_protected" ""; +test_config_reload :extension "editheader"; diff --git a/pigeonhole/tests/extensions/editheader/utf8.svtest b/pigeonhole/tests/extensions/editheader/utf8.svtest new file mode 100644 index 0000000..159a71c --- /dev/null +++ b/pigeonhole/tests/extensions/editheader/utf8.svtest @@ -0,0 +1,97 @@ +require "vnd.dovecot.testsuite"; + +require "encoded-character"; +require "variables"; +require "editheader"; + +test_set "message" text: +Subject: Frop! +From: stephan@example.com +To: stephan@example.com + +Frop! +. +; + +test "UTF8 - add; get" { + set "comment" "Ein unerh${unicode:00F6}rt gro${unicode:00DF}er Test"; + + addheader "Comment" "${comment}"; + + if not exists "comment" { + test_fail "header not added"; + } + + if not header :is "comment" "${comment}" { + test_fail "wrong content added/retrieved"; + } + + redirect "frop@example.com"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + /* redirected message */ + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not exists "comment" { + test_fail "header not added in redirected mail"; + } + + if not header :is "comment" "${comment}" { + test_fail "wrong content added/retrieved from redirected mail"; + } +} + +test_result_reset; + +test_set "message" text: +Subject: Frop! +Comment: Ein =?utf-8?q?unerh=C3=B6rt_gro=C3=9Fer?= Test +X-Spam: no +From: stephan@example.com +To: stephan@example.com + +Frop! +. +; + +test "UTF8 - existing; delete other; get" { + set "comment" "Ein unerh${unicode:00F6}rt gro${unicode:00DF}er Test"; + + deleteheader "x-spam"; + + if not exists "comment" { + test_fail "header not present"; + } + + if not header :is "comment" "${comment}" { + test_fail "wrong content retrieved"; + } + + redirect "frop@example.com"; + + if not test_result_execute { + test_fail "failed to execute result"; + } + + /* redirected message */ + + if not test_message :smtp 0 { + test_fail "message not redirected"; + } + + if not exists "comment" { + test_fail "header not present in redirected mail"; + } + + if not header :is "comment" "${comment}" { + test_fail "wrong content retrieved from redirected mail"; + } +} + + |