File: razor2.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 (50 lines) | stat: -rwxr-xr-x 1,566 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
#!/usr/bin/perl

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

use constant HAS_RAZOR2 => eval { require Razor2::Client::Agent; };
use constant HAS_RAZOR2_IDENT => eval { -r $ENV{'HOME'}.'/.razor/identity'; };

use Test::More;
plan skip_all => "Net tests disabled" unless conf_bool('run_net_tests');
plan skip_all => "Needs Razor2" unless HAS_RAZOR2;
plan skip_all => "Needs Razor2 Identity File Needed. razor-register / razor-admin -register has not been run, or identity file ($ENV{'HOME'}/.razor/identity) is unreadable." unless HAS_RAZOR2_IDENT;
plan tests => 2;

diag('Note: Failures may not be an SpamAssassin bug, as Razor tests can fail due to problems with the Razor servers.');

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

#report the email as spam so it fails below.  This process is not likely to work and I can't find a test point for razor. KAM 2018-08-20
#unless (HAS_RAZOR2 or HAS_RAZOR2_IDENT) {
#  system ("razor-report < data/spam/001");
#  if (($? >> 8) != 0) {
#    warn "'razor-report < data/spam/001' failed. This may cause this test to fail.\n";
#  }
#}

tstpre ("
loadplugin Mail::SpamAssassin::Plugin::Razor2
");

#RAZOR2 file was from real-world spam in August 2018

#TESTING FOR SPAM
%patterns = (
        q{ Listed in Razor2 }, 'spam',
            );

sarun ("-t < data/spam/razor2", \&patterns_run_cb);
ok_all_patterns();

#TESTING FOR HAM
%patterns = ();
%anti_patterns = (
	q{ Listed in Razor2 }, 'nonspam',
		 );

sarun ("-t < data/nice/001", \&patterns_run_cb);
ok_all_patterns();