-
Notifications
You must be signed in to change notification settings - Fork 70
/
db_awl_path.t
executable file
·47 lines (37 loc) · 1.31 KB
/
db_awl_path.t
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
#!/usr/bin/perl
use lib '.'; use lib 't';
use SATest; sa_t_init("db_awl_path");
use Test; BEGIN { plan tests => 4 };
use IO::File;
# ---------------------------------------------------------------------------
%is_spam_patterns = (
q{ X-Spam-Status: Yes}, 'isspam',
);
# We can't easily test to see if a given AWL was used. so what we do
# is tell SpamAssassin to use an inaccessible one, then verify that
# the address in question was *not* whitelisted successfully. '
open (OUT, ">log/awl");
print OUT "file created to block AWL from working; AWL expects a dir";
close OUT;
tstprefs ("
$default_cf_lines
auto_whitelist_path ./log/awl/shouldbeinaccessible
auto_whitelist_file_mode 0755
");
my $fh = IO::File->new_tmpfile();
ok($fh);
open(STDERR, ">&=".fileno($fh)) || die "Cannot reopen STDERR";
sarun("--add-addr-to-whitelist whitelist_test\@whitelist.spamassassin.taint.org",
\&patterns_run_cb);
seek($fh, 0, 0);
my $error = do {
local $/;
<$fh>;
};
print "# $error\n";
ok($error, qr/(cannot create tmp lockfile)|(unlink of lock file.*failed)/, "Check we get the right error back");
# and this mail should *not* be whitelisted as a result.
%patterns = %is_spam_patterns;
sarun ("-L -t < data/spam/004", \&patterns_run_cb);
ok_all_patterns();
ok(unlink 'log/awl'); # need a little cleanup