Lines 10-16
use CGI qw ( -utf8 );
Link Here
|
10 |
use Test::MockObject; |
10 |
use Test::MockObject; |
11 |
use Test::MockModule; |
11 |
use Test::MockModule; |
12 |
use List::MoreUtils qw/all any none/; |
12 |
use List::MoreUtils qw/all any none/; |
13 |
use Test::More tests => 22; |
13 |
use Test::More tests => 23; |
14 |
use Test::Warn; |
14 |
use Test::Warn; |
15 |
use t::lib::Mocks; |
15 |
use t::lib::Mocks; |
16 |
use t::lib::TestBuilder; |
16 |
use t::lib::TestBuilder; |
Lines 32-37
my $dbh = C4::Context->dbh;
Link Here
|
32 |
# FIXME: SessionStorage defaults to mysql, but it seems to break transaction |
32 |
# FIXME: SessionStorage defaults to mysql, but it seems to break transaction |
33 |
# handling |
33 |
# handling |
34 |
t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' ); |
34 |
t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' ); |
|
|
35 |
t::lib::Mocks::mock_preference( 'GDPR_Policy', '' ); # Disabled |
35 |
|
36 |
|
36 |
$schema->storage->txn_begin; |
37 |
$schema->storage->txn_begin; |
37 |
|
38 |
|
Lines 285-287
ok( ( any { 'OPACBaseURL' eq $_ } keys %{$template2->{VARS}} ),
Link Here
|
285 |
|
286 |
|
286 |
ok(C4::Auth::checkpw_hash('password', $hash1), 'password validates with first hash'); |
287 |
ok(C4::Auth::checkpw_hash('password', $hash1), 'password validates with first hash'); |
287 |
ok(C4::Auth::checkpw_hash('password', $hash2), 'password validates with second hash'); |
288 |
ok(C4::Auth::checkpw_hash('password', $hash2), 'password validates with second hash'); |
|
|
289 |
|
290 |
subtest 'Check value of login_attempts in checkpw' => sub { |
291 |
plan tests => 6; |
292 |
|
293 |
t::lib::Mocks::mock_preference('FailedLoginAttempts', 3); |
294 |
|
295 |
# Only interested here in regular login |
296 |
$C4::Auth::cas = 0; |
297 |
$C4::Auth::ldap = 0; |
298 |
|
299 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
300 |
$patron->login_attempts(2); |
301 |
$patron->password('123')->store; # yes, deliberately not hashed |
302 |
|
303 |
is( $patron->account_locked, 0, 'Patron not locked' ); |
304 |
my @test = checkpw( $dbh, $patron->userid, '123', undef, 'opac', 1 ); |
305 |
# Note: 123 will not be hashed to 123 ! |
306 |
is( $test[0], 0, 'checkpw should have failed' ); |
307 |
$patron->discard_changes; # refresh |
308 |
is( $patron->login_attempts, 3, 'Login attempts increased' ); |
309 |
is( $patron->account_locked, 1, 'Check locked status' ); |
310 |
|
311 |
# And another try to go over the limit: different return value! |
312 |
@test = checkpw( $dbh, $patron->userid, '123', undef, 'opac', 1 ); |
313 |
is( @test, 0, 'checkpw failed again and returns nothing now' ); |
314 |
$patron->discard_changes; # refresh |
315 |
is( $patron->login_attempts, 3, 'Login attempts not increased anymore' ); |
316 |
}; |
317 |
|
318 |
$schema->storage->txn_rollback; |