|
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 => 20; |
13 |
use Test::More tests => 21; |
| 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 315-317
my $hash2 = hash_password('password');
Link Here
|
| 315 |
|
316 |
|
| 316 |
ok(C4::Auth::checkpw_hash('password', $hash1), 'password validates with first hash'); |
317 |
ok(C4::Auth::checkpw_hash('password', $hash1), 'password validates with first hash'); |
| 317 |
ok(C4::Auth::checkpw_hash('password', $hash2), 'password validates with second hash'); |
318 |
ok(C4::Auth::checkpw_hash('password', $hash2), 'password validates with second hash'); |
|
|
319 |
|
| 320 |
subtest 'Check value of login_attempts in checkpw' => sub { |
| 321 |
plan tests => 6; |
| 322 |
|
| 323 |
t::lib::Mocks::mock_preference('FailedLoginAttempts', 3); |
| 324 |
|
| 325 |
# Only interested here in regular login |
| 326 |
$C4::Auth::cas = 0; |
| 327 |
$C4::Auth::ldap = 0; |
| 328 |
|
| 329 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
| 330 |
$patron->login_attempts(2); |
| 331 |
$patron->password('123')->store; # yes, deliberately not hashed |
| 332 |
|
| 333 |
is( $patron->account_locked, 0, 'Patron not locked' ); |
| 334 |
my @test = checkpw( $dbh, $patron->userid, '123', undef, 'opac', 1 ); |
| 335 |
# Note: 123 will not be hashed to 123 ! |
| 336 |
is( $test[0], 0, 'checkpw should have failed' ); |
| 337 |
$patron->discard_changes; # refresh |
| 338 |
is( $patron->login_attempts, 3, 'Login attempts increased' ); |
| 339 |
is( $patron->account_locked, 1, 'Check locked status' ); |
| 340 |
|
| 341 |
# And another try to go over the limit: different return value! |
| 342 |
@test = checkpw( $dbh, $patron->userid, '123', undef, 'opac', 1 ); |
| 343 |
is( @test, 0, 'checkpw failed again and returns nothing now' ); |
| 344 |
$patron->discard_changes; # refresh |
| 345 |
is( $patron->login_attempts, 3, 'Login attempts not increased anymore' ); |
| 346 |
}; |
| 347 |
|
| 348 |
$schema->storage->txn_rollback; |