From 3fa08e71e0ab4887b9f7c585b76a8e7afa69f6fd Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@dovecot.fi> Date: Thu, 7 Jul 2016 18:25:29 +0200 Subject: [PATCH] extprograms plugin: Added tests for invocation of unknown programs. --- .../plugins/extprograms/execute/errors.svtest | 18 +++++++++ .../execute/errors/unknown-program.sieve | 3 ++ .../plugins/extprograms/filter/errors.svtest | 18 +++++++++ .../filter/errors/unknown-program.sieve | 3 ++ tests/plugins/extprograms/pipe/errors.svtest | 37 +++++++++++++++++++ .../pipe/errors/unknown-program.sieve | 3 ++ 6 files changed, 82 insertions(+) create mode 100644 tests/plugins/extprograms/execute/errors/unknown-program.sieve create mode 100644 tests/plugins/extprograms/filter/errors/unknown-program.sieve create mode 100644 tests/plugins/extprograms/pipe/errors/unknown-program.sieve diff --git a/tests/plugins/extprograms/execute/errors.svtest b/tests/plugins/extprograms/execute/errors.svtest index b08e77ce0..3dd2d5f68 100644 --- a/tests/plugins/extprograms/execute/errors.svtest +++ b/tests/plugins/extprograms/execute/errors.svtest @@ -33,3 +33,21 @@ test "Variables" { test_fail "wrong number of errors reported"; } } + +/* + * Unknown program + */ + +test "Unknown program" { + if not test_script_compile "errors/unknown-program.sieve" { + test_fail "compile should have succeeded"; + } + + if test_script_run { + test_fail "execution should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "1" { + test_fail "wrong number of errors reported"; + } +} diff --git a/tests/plugins/extprograms/execute/errors/unknown-program.sieve b/tests/plugins/extprograms/execute/errors/unknown-program.sieve new file mode 100644 index 000000000..3a79bb67b --- /dev/null +++ b/tests/plugins/extprograms/execute/errors/unknown-program.sieve @@ -0,0 +1,3 @@ +require "vnd.dovecot.execute"; + +execute "unknown"; diff --git a/tests/plugins/extprograms/filter/errors.svtest b/tests/plugins/extprograms/filter/errors.svtest index 3461c0192..1d04ba1ba 100644 --- a/tests/plugins/extprograms/filter/errors.svtest +++ b/tests/plugins/extprograms/filter/errors.svtest @@ -19,3 +19,21 @@ test "Command syntax" { test_fail "wrong number of errors reported"; } } + +/* + * Unknown program + */ + +test "Unknown program" { + if not test_script_compile "errors/unknown-program.sieve" { + test_fail "compile should have succeeded"; + } + + if test_script_run { + test_fail "execution should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "1" { + test_fail "wrong number of errors reported"; + } +} diff --git a/tests/plugins/extprograms/filter/errors/unknown-program.sieve b/tests/plugins/extprograms/filter/errors/unknown-program.sieve new file mode 100644 index 000000000..7e530ee20 --- /dev/null +++ b/tests/plugins/extprograms/filter/errors/unknown-program.sieve @@ -0,0 +1,3 @@ +require "vnd.dovecot.filter"; + +filter "unknown"; diff --git a/tests/plugins/extprograms/pipe/errors.svtest b/tests/plugins/extprograms/pipe/errors.svtest index 4987fbc19..802caeed1 100644 --- a/tests/plugins/extprograms/pipe/errors.svtest +++ b/tests/plugins/extprograms/pipe/errors.svtest @@ -18,6 +18,43 @@ test "Command syntax" { } } +/* Unknown program */ + +test_set "message" text: +From: stephan@example.com +To: pipe@example.net +Subject: Frop! + +Frop! +. +; + +test_config_set "sieve_pipe_bin_dir" "${tst.path}/../bin"; +test_config_reload :extension "vnd.dovecot.pipe"; +test_result_reset; + +test "Unknown program" { + if not test_script_compile "errors/unknown-program.sieve" { + test_fail "compile failed"; + } + + if not test_script_run { + test_fail "execute failed"; + } + + if test_result_execute { + test_fail "pipe 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 :index 1 :contains "failed to pipe" { + test_fail "wrong error reported"; + } +} + /* Timeout */ test_set "message" text: diff --git a/tests/plugins/extprograms/pipe/errors/unknown-program.sieve b/tests/plugins/extprograms/pipe/errors/unknown-program.sieve new file mode 100644 index 000000000..fd6338bfd --- /dev/null +++ b/tests/plugins/extprograms/pipe/errors/unknown-program.sieve @@ -0,0 +1,3 @@ +require "vnd.dovecot.pipe"; + +pipe "unknown"; -- GitLab