From d86f17e6b86fe2c94a6b27488f06598122cd120d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 4 Apr 2019 09:42:38 +0100 Subject: [PATCH] Bug 21336: (QA follow-up) Add tests for administrative lockout Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens --- t/db_dependent/Koha/Patrons.t | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index 6acff6c..b248729 100644 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -1121,14 +1121,17 @@ subtest 'libraries_where_can_see_patrons + can_see_patron_infos + search_limited }; subtest 'account_locked' => sub { - plan tests => 9; + plan tests => 13; my $patron = $builder->build({ source => 'Borrower', value => { login_attempts => 0 } }); $patron = Koha::Patrons->find( $patron->{borrowernumber} ); for my $value ( undef, '', 0 ) { t::lib::Mocks::mock_preference('FailedloginAttempts', $value); + $patron->login_attempts(0)->store; is( $patron->account_locked, 0, 'Feature is disabled, patron account should not be considered locked' ); $patron->login_attempts(1)->store; is( $patron->account_locked, 0, 'Feature is disabled, patron account should not be considered locked' ); + $patron->login_attempts(-1)->store; + is( $patron->account_locked, 1, 'Feature is disabled but administrative lockout has been triggered' ); } t::lib::Mocks::mock_preference('FailedloginAttempts', 3); @@ -1138,6 +1141,8 @@ subtest 'account_locked' => sub { is( $patron->account_locked, 1, 'Patron has 3 failed attempts, account should be considered locked yet' ); $patron->login_attempts(4)->store; is( $patron->account_locked, 1, 'Patron could not have 4 failed attempts, but account should still be considered locked' ); + $patron->login_attempts(-1)->store; + is( $patron->account_locked, 1, 'Administrative lockout triggered' ); $patron->delete; }; -- 1.7.2.5