From af0d6a8686f5332dd352170ae4305938540e9987 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 24 May 2023 11:52:50 -0300 Subject: [PATCH] Bug 33815: Regression tests Signed-off-by: Tomas Cohen Arazi Signed-off-by: Owen Leonard --- t/db_dependent/Auth.t | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t index 01aa3575e9..5c2aad72d4 100755 --- a/t/db_dependent/Auth.t +++ b/t/db_dependent/Auth.t @@ -762,7 +762,7 @@ subtest 'check_cookie_auth' => sub { }; subtest 'checkauth & check_cookie_auth' => sub { - plan tests => 31; + plan tests => 35; # flags = 4 => { catalogue => 1 } my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => 4 } }); @@ -824,6 +824,23 @@ subtest 'checkauth & check_cookie_auth' => sub { is( $auth_status, 'ok' ); is( $session->id, $first_sessionID ); + my $patron_to_delete = $builder->build_object({ class => 'Koha::Patrons' }); + my $fresh_userid = $patron_to_delete->userid; + $patron_to_delete->delete; + my $old_userid = $patron->userid; + + # change the current session user's userid + $patron->userid( $fresh_userid )->store; + ( $auth_status, $session ) = C4::Auth::check_cookie_auth($sessionID, {catalogue => 1}); + is( $auth_status, 'expired' ); + is( $session, undef ); + + # restore userid and generate a new session + $patron->userid($old_userid)->store; + ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth($cgi, 0, {catalogue => 1}); + is( $sessionID, $first_sessionID ); + is( $userid, $patron->userid ); + # Logging out! $cgi->param('logout.x', 1); $cgi->delete( 'userid', 'password' ); -- 2.30.2