File: sql_based_whitelist.t

package info (click to toggle)
spamassassin 3.4.2-1%2Bdeb10u3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 13,004 kB
  • sloc: perl: 57,283; ansic: 3,398; sh: 637; sql: 211; makefile: 200; python: 17
file content (69 lines) | stat: -rwxr-xr-x 1,822 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl

use lib '.'; use lib 't';
use SATest;

use Test::More;
plan skip_all => 'AWL SQL Tests not enabled.' if conf_bool('run_awl_sql_tests');
plan tests => 11;
diag "Note: Failure may be due to an incorrect config";

sa_t_init("sql_based_whitelist");

my $dbconfig = '';
foreach my $setting (qw(
                  user_awl_dsn
                  user_awl_sql_username
                  user_awl_sql_password
                  user_awl_sql_table
                ))
{
  my $val = conf($setting);
  $dbconfig .= "$setting $val\n" if $val;
}

my $testuser = 'tstusr.'.$$.'.'.time();

tstlocalrules ("
use_auto_whitelist 1
auto_whitelist_factory Mail::SpamAssassin::SQLBasedAddrList
$dbconfig
user_awl_sql_override_username $testuser
");

# ---------------------------------------------------------------------------

%is_nonspam_patterns = (
q{ Subject: Re: [SAtalk] auto-whitelisting}, 'subj',
);
%is_spam_patterns = (
q{Subject: 4000           Your Vacation Winning !}, 'subj',
);

%is_spam_patterns2 = (
q{ X-Spam-Status: Yes}, 'status',
);


%patterns = %is_nonspam_patterns;

ok(sarun ("--remove-addr-from-whitelist whitelist_test\@whitelist.spamassassin.taint.org", \&patterns_run_cb));

# 3 times, to get into the whitelist:
ok(sarun ("-L -t < data/nice/002", \&patterns_run_cb));
ok(sarun ("-L -t < data/nice/002", \&patterns_run_cb));
ok(sarun ("-L -t < data/nice/002", \&patterns_run_cb));

# Now check
ok(sarun ("-L -t < data/nice/002", \&patterns_run_cb));
ok_all_patterns();

%patterns = %is_spam_patterns;
ok(sarun ("-L -t < data/spam/004", \&patterns_run_cb));
ok_all_patterns();

%patterns = %is_spam_patterns2;
ok(sarun ("-L -t < data/spam/007", \&patterns_run_cb));
ok_all_patterns();

ok(sarun ("--remove-addr-from-whitelist whitelist_test\@whitelist.spamassassin.taint.org", \&patterns_run_cb));