Skip to content
Snippets Groups Projects
Commit 0cb3a96d authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Spamtest extension: added tests for strlen values to the testsuite.

parent d0f9c920
No related branches found
No related tags found
No related merge requests found
......@@ -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}";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.