File: sql_based_whitelist.t

package info (click to toggle)
spamassassin 3.4.0-6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,296 kB
  • ctags: 2,968
  • sloc: perl: 54,007; ansic: 3,397; sh: 590; makefile: 195; sql: 176; python: 17
file content (76 lines) | stat: -rwxr-xr-x 1,911 bytes parent folder | download | duplicates (8)
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
70
71
72
73
74
75
76
#!/usr/bin/perl

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

use constant TEST_ENABLED => conf_bool('run_awl_sql_tests');

use Test;

BEGIN { plan tests => (TEST_ENABLED ? 11 : 0),
        onfail => sub {
            warn "\n\nNote: Failure may be due to an incorrect config";
        }
    };

exit unless TEST_ENABLED;

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));