From a2e5225823b3eb4ba94f738cc0c3da0f932acd31 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 25 Apr 2022 11:05:15 -0300 Subject: [PATCH] Bug 29924: Add tests for API Basic auth behavior Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/api/v1/auth_basic.t | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/api/v1/auth_basic.t b/t/db_dependent/api/v1/auth_basic.t index 49fdfe93d2e..78c75720410 100755 --- a/t/db_dependent/api/v1/auth_basic.t +++ b/t/db_dependent/api/v1/auth_basic.t @@ -23,6 +23,8 @@ use Test::Mojo; use t::lib::TestBuilder; use t::lib::Mocks; +use Koha::DateUtils qw( dt_from_string ); + my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; @@ -77,7 +79,7 @@ subtest 'success tests' => sub { subtest 'failure tests' => sub { - plan tests => 8; + plan tests => 13; $schema->storage->txn_begin; @@ -91,6 +93,16 @@ subtest 'failure tests' => sub { $patron->set_password({ password => $password }); my $userid = $patron->userid; + $t->get_ok("//$userid:$password@/api/v1/patrons") + ->status_is( 200, 'All good' ); + + # expire patron's password + $patron->password_expiration_date( dt_from_string->subtract( days => 1 ) )->store; + + $t->get_ok("//$userid:$password@/api/v1/patrons") + ->status_is( 403 ) + ->json_is( '/error' => 'Password has expired', 'Password expired' ); + $t->get_ok("//@/api/v1/patrons") ->status_is( 401, 'No credentials passed' ); -- 2.34.1