Lines 288-294
ok(C4::Auth::checkpw_hash('password', $hash1), 'password validates with first ha
Link Here
|
288 |
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 |
|
289 |
|
290 |
subtest 'Check value of login_attempts in checkpw' => sub { |
290 |
subtest 'Check value of login_attempts in checkpw' => sub { |
291 |
plan tests => 6; |
291 |
plan tests => 11; |
292 |
|
292 |
|
293 |
t::lib::Mocks::mock_preference('FailedLoginAttempts', 3); |
293 |
t::lib::Mocks::mock_preference('FailedLoginAttempts', 3); |
294 |
|
294 |
|
Lines 313-318
subtest 'Check value of login_attempts in checkpw' => sub {
Link Here
|
313 |
is( @test, 0, 'checkpw failed again and returns nothing now' ); |
313 |
is( @test, 0, 'checkpw failed again and returns nothing now' ); |
314 |
$patron->discard_changes; # refresh |
314 |
$patron->discard_changes; # refresh |
315 |
is( $patron->login_attempts, 3, 'Login attempts not increased anymore' ); |
315 |
is( $patron->login_attempts, 3, 'Login attempts not increased anymore' ); |
|
|
316 |
|
317 |
# Administrative lockout cannot be undone? |
318 |
# Pass the right password now (or: add a nice mock). |
319 |
my $auth = Test::MockModule->new( 'C4::Auth' ); |
320 |
$auth->mock( 'checkpw_hash', sub { return 1; } ); # not for production :) |
321 |
$patron->login_attempts(0)->store; |
322 |
@test = checkpw( $dbh, $patron->userid, '123', undef, 'opac', 1 ); |
323 |
is( $test[0], 1, 'Build confidence in the mock' ); |
324 |
$patron->login_attempts(-1)->store; |
325 |
is( $patron->account_locked, 1, 'Check administrative lockout' ); |
326 |
@test = checkpw( $dbh, $patron->userid, '123', undef, 'opac', 1 ); |
327 |
is( @test, 0, 'checkpw gave red' ); |
328 |
$patron->discard_changes; # refresh |
329 |
is( $patron->login_attempts, -1, 'Still locked out' ); |
330 |
t::lib::Mocks::mock_preference('FailedLoginAttempts', ''); # disable |
331 |
is( $patron->account_locked, 1, 'Check administrative lockout without pref' ); |
316 |
}; |
332 |
}; |
317 |
|
333 |
|
318 |
$schema->storage->txn_rollback; |
334 |
$schema->storage->txn_rollback; |
319 |
- |
|
|