1# t/03_functions.t; test the basic functions 2 3$|++; 4if(-e "/usr/sbin/makemap" && -f "/usr/sbin/makemap" && -x "/usr/sbin/makemap") 5{ 6 print "1..7 7"; 8} 9else 10{ 11 print "1..0 # SKIP /usr/sbin/makemap not found 12"; 13 exit 0; 14} 15 16my($test) = 1; 17 18# 1 load 19use Sendmail::AccessDB; 20my $foo; 21 22$Sendmail::AccessDB::DB_FILE="./t/test.db"; 23system("touch ./t/test.db"); 24system("/usr/sbin/makemap hash ./t/test < ./t/test"); 25 26 27my $friend = Sendmail::AccessDB::spam_friend('foo@bar.com'); 28if ( (defined $friend) and ($friend eq 'FRIEND')) 29 { print "ok $test\n";}else{ print "not ok $test\n"; } 30$test++; 31 32$friend = Sendmail::AccessDB::spam_friend('foo@bar.de'); 33if ( (defined $friend) and ($friend eq 'FOE')) 34 { print "ok $test\n";}else{ print "not ok $test\n"; } 35$test++; 36 37 38my $whitelisted = Sendmail::AccessDB::whitelisted('foo.test.example.com','type'=>'hostname'); 39if ( (defined $whitelisted) and ($whitelisted)) 40 { print "ok $test\n" }else{ print "not ok $test\n"; } 41$test++; 42 43my $should_fail = Sendmail::AccessDB::whitelisted('bar.example.com'); 44if ($should_fail) { print "not ok $test\n";} else { print "ok $test\n"; } 45$test++; 46 47my $lookup = Sendmail::AccessDB::lookup('foo.bar.tld','qualifier'=>'Qual'); 48if ( (defined $lookup) and ($lookup eq 'OK')) 49 { print "ok $test\n" } else { print "not ok $test\n"; }; 50$test++; 51 52my $wltwo = Sendmail::AccessDB::whitelisted('user@foo.bar.tld','qualifier'=>'Qual','type'=>'mail'); 53if ($wltwo) { print "ok $test\n" } else { print "not ok $test\n"; }; 54$test++; 55 56my $should_be_skip = Sendmail::AccessDB::lookup('user@foo.bar.tld2','qualifier'=>'Qual','type'=>'mail'); 57if ($should_be_skip eq "SKIP") { print "ok $test\n" } else { print "not ok $test\n"; }; 58$test++; 59 60 61 62# end of t/03_functions.t 63 64