diff --git a/Makefile.am b/Makefile.am index 6fe58623a8f9c073cc0c1707327eec120b43d321..3e67d5e7f7244f219a57005d828f63647ae3413f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -167,6 +167,7 @@ test_cases = \ tests/extensions/metadata/execute.svtest \ tests/extensions/metadata/errors.svtest \ tests/extensions/mime/errors.svtest \ + tests/extensions/mime/execute.svtest \ tests/extensions/mime/content-header.svtest \ tests/extensions/vnd.dovecot/debug/execute.svtest \ tests/extensions/vnd.dovecot/environment/basic.svtest \ diff --git a/tests/extensions/mime/execute.svtest b/tests/extensions/mime/execute.svtest index 701d817a4ee45dfc281635e5ebef00392436f983..2ced83b48a186b4d4aafdbc768ff59017d1c9c55 100644 --- a/tests/extensions/mime/execute.svtest +++ b/tests/extensions/mime/execute.svtest @@ -4,8 +4,51 @@ require "vnd.dovecot.testsuite"; * Execution testing (currently just meant to trigger any segfaults) */ -test "Basic" { - if not test_script_compile "execute/ihave.sieve" { +test_set "message" text: +From: Whomever <whoever@example.com> +To: Someone <someone@example.com> +Date: Sat, 10 Oct 2009 00:30:04 +0200 +Subject: whatever +Content-Type: multipart/mixed; boundary=outer + +This is a multi-part message in MIME format. + +--outer +Content-Type: multipart/alternative; boundary=inner + +This is a nested multi-part message in MIME format. + +--inner +Content-Type: text/plain; charset="us-ascii" + +Hello + +--inner +Content-Type: text/html; charset="us-ascii" + +<html><body>Hello</body></html> + +--inner-- + +This is the end of the inner MIME multipart. + +--outer +Content-Type: message/rfc822 + +From: Someone Else +Subject: Hello, this is an elaborate request for you to finally say hello + already! + +Please say Hello + +--outer-- + +This is the end of the outer MIME multipart. +. +; + +test "Basic - foreverypart" { + if not test_script_compile "execute/foreverypart.sieve" { test_fail "script compile failed"; } @@ -17,7 +60,23 @@ test "Basic" { test_fail "result execute failed"; } - test_binary_save "ihave-basic"; - test_binary_load "ihave-basic"; + test_binary_save "ihave-basic"; + test_binary_load "ihave-basic"; } +test "Basic - mime" { + if not test_script_compile "execute/mime.sieve" { + test_fail "script compile failed"; + } + + if not test_script_run { + test_fail "script run failed"; + } + + if not test_result_execute { + test_fail "result execute failed"; + } + + test_binary_save "ihave-basic"; + test_binary_load "ihave-basic"; +} diff --git a/tests/extensions/mime/execute/foreverypart.sieve b/tests/extensions/mime/execute/foreverypart.sieve index 0fe84c8278b9cb8d997b6f9ac8db9139f88fc754..9ae1fba1895aa3906e80bc4ebe60c2206a1d290a 100644 --- a/tests/extensions/mime/execute/foreverypart.sieve +++ b/tests/extensions/mime/execute/foreverypart.sieve @@ -1,7 +1,14 @@ -require "ihave"; +require "foreverypart"; +require "variables"; -if ihave "nonsense-extension" { - nonsense_command "Frop!"; +foreverypart { + foreverypart { + foreverypart { + foreverypart { + set "a" "a${a}"; + } + } + } } -redirect "frop@example.com"; + diff --git a/tests/extensions/mime/execute/mime.sieve b/tests/extensions/mime/execute/mime.sieve new file mode 100644 index 0000000000000000000000000000000000000000..dd7fedc020bf0e263923c82c83568b62de9e4ca2 --- /dev/null +++ b/tests/extensions/mime/execute/mime.sieve @@ -0,0 +1,69 @@ +require "mime"; +require "foreverypart"; +require "variables"; + +if header :contains :mime "Content-Type" "text/plain" { + discard; +} +if header :mime :type "Content-Type" "text" { + discard; +} +if header :mime :subtype "Content-Type" "plain" { + discard; +} +if header :mime :contenttype "Content-Type" "text/plain" { + discard; +} +if header :mime :param ["frop", "friep"] "Content-Type" "frml" { + discard; +} +if header :anychild :contains :mime "Content-Type" "text/plain" { + discard; +} +if header :mime :anychild :type "Content-Type" "text" { + discard; +} +if header :mime :subtype :anychild "Content-Type" "plain" { + discard; +} +if header :anychild :mime :contenttype "Content-Type" "text/plain" { + discard; +} +if header :mime :param ["frop", "friep"] :anychild "Content-Type" "frml" { + discard; +} + +foreverypart { + foreverypart { + if header :contains :mime "Content-Type" "text/plain" { + discard; + } + if header :mime :type "Content-Type" "text" { + discard; + } + if header :mime :subtype "Content-Type" "plain" { + discard; + } + if header :mime :contenttype "Content-Type" "text/plain" { + discard; + } + if header :mime :param ["frop", "friep"] "Content-Type" "frml" { + discard; + } + if header :anychild :contains :mime "Content-Type" "text/plain" { + discard; + } + if header :mime :anychild :type "Content-Type" "text" { + discard; + } + if header :mime :subtype :anychild "Content-Type" "plain" { + discard; + } + if header :anychild :mime :contenttype "Content-Type" "text/plain" { + discard; + } + if header :mime :param ["frop", "friep"] :anychild "Content-Type" "frml" { + discard; + } + } +}