From 43c2d305ef2ff42a3e4ba2fda5d1ad4ceeb907d1 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 12 Feb 2019 14:19:26 -0300 Subject: [PATCH] [18.05.x] Bug 22132: (follow-up) Make tests use Koha::Patron->update_password Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/api/v1/auth_basic.t | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/api/v1/auth_basic.t b/t/db_dependent/api/v1/auth_basic.t index 4fb48f0277..48ff1af6db 100644 --- 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::AuthUtils; + my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; @@ -37,11 +39,12 @@ subtest 'success tests' => sub { t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); my $password = 'AbcdEFG123'; + my $digest = Koha::AuthUtils::hash_password( $password ); my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { userid => 'tomasito', flags => 2**4 } } ); - $patron->set_password({ password => $password }); my $userid = $patron->userid; + $patron->update_password( $userid, $digest ); $t->get_ok("//$userid:$password@/api/v1/patrons") ->status_is( 200, 'Successful authentication and permissions check' ); @@ -66,13 +69,14 @@ subtest 'failure tests' => sub { my $password = 'AbcdEFG123'; my $bad_password = '123456789'; + my $digest = Koha::AuthUtils::hash_password( $password ); t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { userid => 'tomasito', flags => 2**4 } } ); - $patron->set_password({ password => $password }); my $userid = $patron->userid; + $patron->update_password( $userid, $digest ); $t->get_ok("//@/api/v1/patrons") ->status_is( 401, 'No credentials passed' ); -- 2.20.1