Bug 37104: Unit tests

prove t/db-dependent/Auth.t

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit ce0fe316b8)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Sam Lau 2024-06-17 19:31:52 +00:00 committed by Lucas Gass
parent 9537ba5957
commit 39754b8b99
1 changed files with 22 additions and 3 deletions

View File

@ -690,7 +690,7 @@ subtest 'Check value of login_attempts in checkpw' => sub {
};
subtest 'Check value of login_attempts in checkpw' => sub {
plan tests => 2;
plan tests => 3;
t::lib::Mocks::mock_preference('FailedLoginAttempts', 3);
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
@ -703,6 +703,10 @@ subtest 'Check value of login_attempts in checkpw' => sub {
@test = checkpw( $patron->userid, '123', undef, 'opac', 1 );
is( $test[0], -2, 'Patron returned as expired correctly' );
## Make our patron the anonymous patron
t::lib::Mocks::mock_preference( 'AnonymousPatron', $patron->id );
@test = checkpw( $patron->userid, '123', undef, 'opac', 1 );
is( $test[0], -3, 'Patron returned as anonymous patron correctly' );
};
subtest '_timeout_syspref' => sub {
@ -1084,7 +1088,7 @@ subtest 'checkpw() return values tests' => sub {
subtest 'Internal check tests' => sub {
plan tests => 25;
plan tests => 29;
$schema->storage->txn_begin;
@ -1141,6 +1145,14 @@ subtest 'checkpw() return values tests' => sub {
is( ref( $return[1] ), 'Koha::Patron' );
is( $return[1]->id, $patron->id, 'Patron matched correctly' );
t::lib::Mocks::mock_preference( 'AnonymousPatron', $patron->id );
@return = checkpw( $patron->userid, $password, undef, );
is( scalar @return, 2, "Two results on expired password scenario" );
is( $return[0], -3, '-3 returned' );
is( ref( $return[1] ), 'Koha::Patron' );
is( $return[1]->id, $patron->id, 'Patron matched correctly' );
@return = checkpw( $unused_userid, $password, undef, );
is( scalar @return, 2, "Two results on non-existing userid scenario" );
@ -1158,7 +1170,7 @@ subtest 'checkpw() return values tests' => sub {
subtest 'CAS check (mocked) tests' => sub {
plan tests => 25;
plan tests => 29;
$schema->storage->txn_begin;
@ -1225,6 +1237,13 @@ subtest 'checkpw() return values tests' => sub {
is( ref( $return[1] ), 'Koha::Patron' );
is( $return[1]->id, $patron->id, 'Patron matched correctly' );
t::lib::Mocks::mock_preference( 'AnonymousPatron', $patron->id );
@return = checkpw( $patron->userid, $password, undef, );
is( scalar @return, 2, "Two results on expired password scenario" );
is( $return[0], -3, '-3 returned' );
is( ref( $return[1] ), 'Koha::Patron' );
is( $return[1]->id, $patron->id, 'Patron matched correctly' );
@return = checkpw( $unused_userid, $password, $query, );
is( scalar @return, 2, "Two results on non-existing userid scenario" );