File: spamc_x_E_R.t

package info (click to toggle)
spamassassin 4.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,988 kB
  • sloc: perl: 88,863; ansic: 5,193; sh: 3,737; javascript: 339; sql: 295; makefile: 209; python: 49
file content (120 lines) | stat: -rwxr-xr-x 3,782 bytes parent folder | download | duplicates (3)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/perl -T

use lib '.'; use lib 't';
use SATest; sa_t_init("spamc_x_E_R");

use Test::More;
plan skip_all => "Long running tests disabled" unless conf_bool('run_long_tests');
plan skip_all => "Spamd tests disabled" if $SKIP_SPAMD_TESTS;
plan tests => 49;

# ---------------------------------------------------------------------------
# test case for bug 5412; exit status with -x/-E/-R combos

%patterns = ( );

ok(start_spamd("-L"));

# ----------------------------------------------------------------------
# nonspam mails -- return 0
ok(scrun("-E < data/nice/001", \&patterns_run_cb));
ok(scrun("-R < data/nice/001", \&patterns_run_cb));
ok(scrun("-x -E < data/nice/001", \&patterns_run_cb));
ok(scrun("-x -R < data/nice/001", \&patterns_run_cb));
ok(scrun("-x -R -E < data/nice/001", \&patterns_run_cb));

# ----------------------------------------------------------------------
# spam mails
ok(scrun("-R < data/spam/001", \&patterns_run_cb));
ok(scrun("-x -R < data/spam/001", \&patterns_run_cb));

# returns 1; this will kill spamd as a side-effect
ok(scrunwantfail("-x -E < data/spam/001", \&patterns_run_cb));
stop_spamd(); $spamd_pid = undef; $spamd_already_killed = undef;
ok(start_spamd("-L"));

# returns 1; this will kill spamd
ok(scrunwantfail("-E < data/spam/001", \&patterns_run_cb));
stop_spamd(); $spamd_pid = undef; $spamd_already_killed = undef;
ok(start_spamd("-L"));

# returns 1; this will kill spamd
ok(scrunwantfail("-x -R -E < data/spam/001", \&patterns_run_cb));
stop_spamd(); # just to be sure

# ----------------------------------------------------------------------
# error conditions
# max-size of 512 bytes; EX_TOOBIG, pass through message despite -x

%patterns = (
  'Subject: There yours for FREE!', 'subj',
);
%anti_patterns = (
  'X-Spam-Flag:', 'flag',
);

# this should have exit code == 0, and pass through the full
# unfiltered text
clear_pattern_counters();
ok(scrun("-s 512 -x < data/spam/001", \&patterns_run_cb));
ok ok_all_patterns();

# this should have exit code == 0, and pass through the full
# unfiltered text
clear_pattern_counters();
ok(scrun("-s 512 -x -E < data/spam/001", \&patterns_run_cb));
ok ok_all_patterns();

%patterns = (
  '0/0', '0/0',
);
%anti_patterns = (
  'Subject: There yours for FREE!', 'subj',
  'X-Spam-Flag:', 'flag',
);

# this should have exit code == 0, and emit "0/0"
clear_pattern_counters();
ok(scrun("-s 512 -x -R < data/spam/001", \&patterns_run_cb));
ok ok_all_patterns();

# this should have exit code == 0, and emit "0/0"
clear_pattern_counters();
ok(scrun("-s 512 -x -E -R < data/spam/001", \&patterns_run_cb));
ok ok_all_patterns();

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

$spamdhost = '255.255.255.255'; # cause "connection failed" errors

# these should have exit code == 0
ok(scrun("--connect-retries 1 -E < data/spam/001", \&patterns_run_cb));
ok(scrun("--connect-retries 1 -R < data/spam/001", \&patterns_run_cb));

# we do not want to see the output with -x on error
%patterns = ();
%anti_patterns = (
  'Subject: There yours for FREE!', 'subj',
  'X-Spam-Flag: YES', 'flag',
);

# this should have exit code != 0
clear_pattern_counters();
ok(scrunwantfail("--connect-retries 1 -x < data/spam/001", \&patterns_run_cb));
ok ok_all_patterns();

# this should have exit code != 0
clear_pattern_counters();
ok(scrunwantfail("--connect-retries 1 -x -R < data/spam/001", \&patterns_run_cb));
ok ok_all_patterns();

# this should have exit code != 0
clear_pattern_counters();
ok(scrunwantfail("--connect-retries 1 -x -E -R < data/spam/001", \&patterns_run_cb));
ok ok_all_patterns();

# this should have exit code != 0
clear_pattern_counters();
ok(scrunwantfail("--connect-retries 1 -x -E < data/spam/001", \&patterns_run_cb));
ok ok_all_patterns();