Fix conf test & unit test (#2243)
This commit is contained in:
parent
f7800e5644
commit
48df4a8807
|
@ -684,6 +684,15 @@ sub tests {
|
|||
|
||||
# Warn if bruteForceProtection enabled without History
|
||||
bruteForceProtection => sub {
|
||||
my @lockTimes =
|
||||
sort { $a <=> $b }
|
||||
map {
|
||||
$_ =~ s/\D//;
|
||||
abs $_;
|
||||
}
|
||||
grep { /\d+/ }
|
||||
split /\s*,\s*/, $conf->{bruteForceProtectionLockTimes};
|
||||
$conf->{bruteForceProtectionLockTimes} = join ', ', @lockTimes;
|
||||
return 1 unless ( $conf->{bruteForceProtection} );
|
||||
return ( 1,
|
||||
'"History" plugin is required to enable "BruteForceProtection" plugin'
|
||||
|
@ -699,8 +708,7 @@ sub tests {
|
|||
)
|
||||
if ( $conf->{bruteForceProtectionIncrementalTempo}
|
||||
&& $conf->{failedLoginNumber} <
|
||||
$conf->{bruteForceProtectionMaxFailed} +
|
||||
$conf->{bruteForceProtectionLockTimes} );
|
||||
$conf->{bruteForceProtectionMaxFailed} + scalar @lockTimes );
|
||||
return ( 1,
|
||||
'Number of failed logins history must be higher or equal than allowed failed logins'
|
||||
)
|
||||
|
|
|
@ -80,10 +80,11 @@ ok(
|
|||
ok( $res->[2]->[0] =~ /<span trmsg="86"><\/span>/,
|
||||
'Rejected -> Protection enabled' )
|
||||
or print STDERR Dumper( $res->[2]->[0] );
|
||||
ok( $res->[2]->[0] =~ m%5 <span trspan="seconds">seconds</span>%,
|
||||
'LockTime = 5' )
|
||||
ok( $res->[2]->[0] =~ m%(\d) <span trspan="seconds">seconds</span>%,
|
||||
"LockTime = $1" );
|
||||
ok( $1 <= 5 && $1 >= 3, 'LockTime in range' )
|
||||
or print STDERR Dumper( $res->[2]->[0] );
|
||||
count(3);
|
||||
count(4);
|
||||
|
||||
# Waiting
|
||||
Time::Fake->offset("+4s");
|
||||
|
|
Loading…
Reference in New Issue