From 4958ace4d5e4fa73a6575a524f54452ba95ca04d Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 5 Jun 2020 09:26:08 -0300 Subject: [PATCH] Bug 24003: (follow-up) Basic auth missing tests for stashed user Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/api/v1/auth_basic.t | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/api/v1/auth_basic.t b/t/db_dependent/api/v1/auth_basic.t index 1073bfd0bb0..99b81159dac 100644 --- a/t/db_dependent/api/v1/auth_basic.t +++ b/t/db_dependent/api/v1/auth_basic.t @@ -30,7 +30,7 @@ my $t = Test::Mojo->new('Koha::REST::V1'); subtest 'success tests' => sub { - plan tests => 6; + plan tests => 9; $schema->storage->txn_begin; @@ -52,10 +52,18 @@ subtest 'success tests' => sub { ); }); + my $stash; + $t->app->hook(after_dispatch => sub { $stash = shift->stash }); + $t->get_ok("//$userid:$password@/api/v1/patrons") ->status_is( 200, 'Successful authentication and permissions check' ) ->json_is('/userenv/number' => $patron->borrowernumber ); + my $user = $stash->{'koha.user'}; + ok( defined $user, 'The \'koha.user\' object is defined in the stash') and + is( ref($user), 'Koha::Patron', 'Stashed koha.user object type is Koha::Patron') and + is( $user->borrowernumber, $patron->borrowernumber, 'The stashed user is the right one' ); + $patron->flags(undef)->store; $t->get_ok("//$userid:$password@/api/v1/patrons") -- 2.27.0