dovecot-2.0-sieve: Spamtest extension: added various value tests...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Fri Jan 8 00:58:44 EET 2010
details: http://hg.rename-it.nl/dovecot-2.0-sieve/rev/f8ed8afd025d
changeset: 1180:f8ed8afd025d
user: Stephan Bosch <stephan at rename-it.nl>
date: Sun Jan 03 21:41:45 2010 +0100
description:
Spamtest extension: added various value tests to the testsuite.
diffstat:
tests/extensions/spamvirustest/spamtest.svtest | 105 ++++++++++++++++++++++++--
1 files changed, 97 insertions(+), 8 deletions(-)
diffs (140 lines):
diff -r a6bd9a3fd5dc -r f8ed8afd025d tests/extensions/spamvirustest/spamtest.svtest
--- a/tests/extensions/spamvirustest/spamtest.svtest Sun Jan 03 21:41:21 2010 +0100
+++ b/tests/extensions/spamvirustest/spamtest.svtest Sun Jan 03 21:41:45 2010 +0100
@@ -1,5 +1,8 @@
require "vnd.dovecot.testsuite";
require "spamtest";
+require "relational";
+require "comparator-i;ascii-numeric";
+require "variables";
/*
* Value
@@ -9,29 +12,32 @@
From: legitimate at example.com
To: victim at dovecot.org
Subject: Not spammish
-X-Company-MailScanner-SpamScore: -1.6 (-)
-X-Company-MailScanner-SpamCheck:
- No, score=-1.6 required=5.0 tests=AWL,BAYES_00,HTML_IMAGE_RATIO_02,HTML_MESSAGE,MIME_HTML_MOSTLY
- autolearn=no version=3.2.5
+X-SpamCheck: No, score=-1.6 required=5.0 autolearn=no version=3.2.5
+X-SpamCheck1: No, score=0.0 required=5.0 autolearn=no version=3.2.5
+X-SpamCheck2: No, score=1.0 required=5.0 autolearn=no version=3.2.5
+X-SpamCheck3: No, score=4.0 required=5.0 autolearn=no version=3.2.5
+X-SpamCheck4: Yes, score=5.0 required=5.0 autolearn=no version=3.2.5
+X-SpamCheck5: Yes, score=7.6 required=5.0 autolearn=no version=3.2.5
Test!
.
;
test_config :set "sieve_spamtest_status_header"
- "X-Company-MailScanner-SpamCheck: [ \\ta-zA-Z]+, score=(-?[0-9]+.[0-9]+)";
+ "X-SpamCheck:[ \\ta-zA-Z]+, score=(-?[0-9]+.[0-9]+)";
test_config :set "sieve_spamtest_max_header"
- "X-Company-MailScanner-SpamCheck: [ \\ta-zA-Z]+, score=-?[0-9]+.[0-9]+ required=(-?[0-9]+.[0-9]+)";
+ "X-SpamCheck:[ \\ta-zA-Z]+, score=-?[0-9]+.[0-9]+ required=(-?[0-9]+.[0-9]+)";
test_config :set "sieve_spamtest_status_type" "value";
test_config :reload "spamtest";
test "Value: subzero" {
if spamtest :is "0" {
- test_fail "spamtest not configured";
+ test_fail "spamtest not configured or test failed";
}
if not spamtest :is "1" {
- test_fail "wrong spam value produced";
+ if spamtest :matches "*" { }
+ test_fail "wrong spam value produced: ${1}";
}
if spamtest :is "2" {
@@ -39,3 +45,86 @@
}
}
+test_config :set "sieve_spamtest_status_header"
+ "X-SpamCheck1:[ \\ta-zA-Z]+, score=(-?[0-9]+.[0-9]+)";
+test_config :reload "spamtest";
+
+test "Value: 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-SpamCheck2:[ \\ta-zA-Z]+, score=(-?[0-9]+.[0-9]+)";
+test_config :reload "spamtest";
+
+test "Value: 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-SpamCheck3:[ \\ta-zA-Z]+, score=(-?[0-9]+.[0-9]+)";
+test_config :reload "spamtest";
+
+test "Value: 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-SpamCheck4:[ \\ta-zA-Z]+, score=(-?[0-9]+.[0-9]+)";
+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-SpamCheck5:[ \\ta-zA-Z]+, score=(-?[0-9]+.[0-9]+)";
+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}";
+ }
+}
+
More information about the dovecot-cvs
mailing list