Lines 318-324
ok(C4::Auth::checkpw_hash('password', $hash1), 'password validates with first ha
Link Here
|
318 |
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 |
|
319 |
|
320 |
subtest 'Check value of login_attempts in checkpw' => sub { |
320 |
subtest 'Check value of login_attempts in checkpw' => sub { |
321 |
plan tests => 6; |
321 |
plan tests => 11; |
322 |
|
322 |
|
323 |
t::lib::Mocks::mock_preference('FailedLoginAttempts', 3); |
323 |
t::lib::Mocks::mock_preference('FailedLoginAttempts', 3); |
324 |
|
324 |
|
Lines 343-348
subtest 'Check value of login_attempts in checkpw' => sub {
Link Here
|
343 |
is( @test, 0, 'checkpw failed again and returns nothing now' ); |
343 |
is( @test, 0, 'checkpw failed again and returns nothing now' ); |
344 |
$patron->discard_changes; # refresh |
344 |
$patron->discard_changes; # refresh |
345 |
is( $patron->login_attempts, 3, 'Login attempts not increased anymore' ); |
345 |
is( $patron->login_attempts, 3, 'Login attempts not increased anymore' ); |
|
|
346 |
|
347 |
# Administrative lockout cannot be undone? |
348 |
# Pass the right password now (or: add a nice mock). |
349 |
my $auth = Test::MockModule->new( 'C4::Auth' ); |
350 |
$auth->mock( 'checkpw_hash', sub { return 1; } ); # not for production :) |
351 |
$patron->login_attempts(0)->store; |
352 |
@test = checkpw( $dbh, $patron->userid, '123', undef, 'opac', 1 ); |
353 |
is( $test[0], 1, 'Build confidence in the mock' ); |
354 |
$patron->login_attempts(-1)->store; |
355 |
is( $patron->account_locked, 1, 'Check administrative lockout' ); |
356 |
@test = checkpw( $dbh, $patron->userid, '123', undef, 'opac', 1 ); |
357 |
is( @test, 0, 'checkpw gave red' ); |
358 |
$patron->discard_changes; # refresh |
359 |
is( $patron->login_attempts, -1, 'Still locked out' ); |
360 |
t::lib::Mocks::mock_preference('FailedLoginAttempts', ''); # disable |
361 |
is( $patron->account_locked, 1, 'Check administrative lockout without pref' ); |
346 |
}; |
362 |
}; |
347 |
|
363 |
|
348 |
$schema->storage->txn_rollback; |
364 |
$schema->storage->txn_rollback; |
349 |
- |
|
|