From ac7960187d31f6ac0fc09037ad2d3337de18c31f Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 24 Aug 2023 18:19:37 +0000 Subject: [PATCH] Bug 34513: (QA follow-up) Tidy Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 332b95b2507184e20cd70ddfb16c6f5a260d6dc0) Signed-off-by: Fridolin Somers (cherry picked from commit e193989419bf3bff551bf61b9cf46a366fd7b854) Signed-off-by: Jacob O'Mara --- t/db_dependent/Auth.t | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t index 4aebb55b53..a72677f0fb 100755 --- a/t/db_dependent/Auth.t +++ b/t/db_dependent/Auth.t @@ -153,29 +153,31 @@ subtest 'checkauth() tests' => sub { }; subtest 'Reset auth state when changing users' => sub { + #NOTE: It's easiest to detect this when changing to a non-existent user, since #that should trigger a redirect to login (instead of returning a session cookie) plan tests => 2; - my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } }); + my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => undef } } ); my $session = C4::Auth::get_session(); - $session->param( 'number', $patron->id ); - $session->param( 'id', $patron->userid ); - $session->param( 'ip', '1.2.3.4' ); - $session->param( 'lasttime', time() ); - $session->param( 'interface', 'intranet' ); + $session->param( 'number', $patron->id ); + $session->param( 'id', $patron->userid ); + $session->param( 'ip', '1.2.3.4' ); + $session->param( 'lasttime', time() ); + $session->param( 'interface', 'intranet' ); $session->flush; my $sessionID = $session->id; C4::Context->_new_userenv($sessionID); - my ( $return ) = C4::Auth::check_cookie_auth( $sessionID, undef, { skip_version_check => 1, remote_addr => '1.2.3.4' } ); + my ($return) = + C4::Auth::check_cookie_auth( $sessionID, undef, { skip_version_check => 1, remote_addr => '1.2.3.4' } ); is( $return, 'ok', 'Patron authenticated' ); my $mock1 = Test::MockModule->new('C4::Auth'); - $mock1->mock( 'safe_exit', sub {return 'safe_exit_redirect'} ); + $mock1->mock( 'safe_exit', sub { return 'safe_exit_redirect' } ); my $mock2 = Test::MockModule->new('CGI'); $mock2->mock( 'request_method', 'POST' ); - $mock2->mock( 'cookie', sub { return $sessionID; } ); # oversimplified.. + $mock2->mock( 'cookie', sub { return $sessionID; } ); # oversimplified.. my $cgi = CGI->new; $cgi->param( -name => 'userid', -value => 'Bond' ); @@ -190,7 +192,7 @@ subtest 'checkauth() tests' => sub { @return = C4::Auth::checkauth( $cgi, 0, {} ); close STDOUT; } - is( $return[0], 'safe_exit_redirect', 'Changing to non-existent user causes a redirect to login'); + is( $return[0], 'safe_exit_redirect', 'Changing to non-existent user causes a redirect to login' ); }; -- 2.39.5