summaryrefslogtreecommitdiff
path: root/t/06-age.t
blob: 0d47c5e0a229efabfbd4cde6b2d00814fcb3e918 (plain)
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
# -*- mode: cperl -*- 
use Test::More tests=>3;
use File::Temp 'tempdir';
 
my $basetime;
 
BEGIN {
*CORE::GLOBAL::time=sub{$basetime};
}
 
use DAKKAR::Graylister;
 
no warnings 'redefine';
 
my $dbdir=tempdir(CLEANUP=>1);
 
local $ENV{SMTPMAILFROM}='gino';
local $ENV{SMTPRCPTTO}='pino';
local $ENV{TCPREMOTEIP}='10.1.2.3';
local $ENV{DAKGL_DBNAME}="$dbdir/gray5.db";
my ($host,$from,$to)=DAKKAR::Graylister::get_from_env();
 
$basetime=10;
 
ok(!DAKKAR::Graylister::is_second_attempt($host,$from,$to),'first attempt');
DAKKAR::Graylister::record_first_attempt($host,$from,$to);
ok(DAKKAR::Graylister::is_second_attempt($host,$from,$to),'second attempt');
 
$basetime=90000;
 
DAKKAR::Graylister::remove_old_attempts();
 
ok(!DAKKAR::Graylister::is_second_attempt($host,$from,$to),'aged attempt');