From 0cb3a96d9bba9e017cfcb4ff66dfd5adcd88c536 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Sun, 3 Jan 2010 22:29:04 +0100 Subject: [PATCH] Spamtest extension: added tests for strlen values to the testsuite. --- .../extensions/spamvirustest/spamtest.svtest | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/tests/extensions/spamvirustest/spamtest.svtest b/tests/extensions/spamvirustest/spamtest.svtest index 0a6369444..167d44903 100644 --- a/tests/extensions/spamvirustest/spamtest.svtest +++ b/tests/extensions/spamvirustest/spamtest.svtest @@ -128,3 +128,102 @@ test "Value: past-max" { } } +/* + * Value + */ + +test_set "message" text: +From: legitimate@example.com +To: victim@dovecot.org +Subject: Not spammish +X-Spam-Status: +X-Spam-Status1: s +X-Spam-Status2: sssssss +X-Spam-Status3: ssssssss +X-Spam-Status4: ssssssssssssss + +Test! +. +; + +test_config :set "sieve_spamtest_status_header" "X-Spam-Status"; +test_config :set "sieve_spamtest_max_value" "8.0"; +test_config :set "sieve_spamtest_status_type" "strlen"; +test_config :unset "sieve_spamtest_max_header"; +test_config :reload "spamtest"; + +test "Strlen: zero" { + if spamtest :is "0" { + test_fail "spamtest not configured or test failed"; + } + + if not spamtest :is "1" { + if spamtest :matches "*" { } + test_fail "wrong spam value produced: ${1}"; + } + + if spamtest :is "2" { + test_fail "spam test matches anything"; + } +} + +test_config :set "sieve_spamtest_status_header" "X-Spam-Status1"; +test_config :reload "spamtest"; + +test "Strlen: low" { + if spamtest :is "0" { + test_fail "spamtest not configured or test failed"; + } + + if not spamtest :value "gt" "1" { + test_fail "too small spam value produced"; + } + + if not spamtest :value "eq" "2" { + if spamtest :matches "*" { } + test_fail "wrong spam value produced: ${1}"; + } +} + +test_config :set "sieve_spamtest_status_header" "X-Spam-Status2"; +test_config :reload "spamtest"; + +test "Strlen: high" { + if spamtest :is "0" { + test_fail "spamtest not configured or test failed"; + } + + if not spamtest :value "eq" "8" { + if spamtest :matches "*" { } + test_fail "wrong spam value produced: ${1}"; + } +} + +test_config :set "sieve_spamtest_status_header" "X-Spam-Status3"; +test_config :reload "spamtest"; + +test "Value: max" { + if spamtest :is "0" { + test_fail "spamtest not configured or test failed"; + } + + if not spamtest :value "eq" "10" { + if spamtest :matches "*" { } + test_fail "wrong spam value produced: ${1}"; + } +} + +test_config :set "sieve_spamtest_status_header" "X-Spam-Status4"; +test_config :reload "spamtest"; + +test "Value: past-max" { + if spamtest :is "0" { + test_fail "spamtest not configured or test failed"; + } + + if not spamtest :value "eq" "10" { + if spamtest :matches "*" { } + test_fail "wrong spam value produced: ${1}"; + } +} + -- GitLab