From 849e8ff5b33edef776d22d871a4cedc8cc57b5a5 Mon Sep 17 00:00:00 2001 From: Victor Grousset/tuxayo Date: Thu, 15 Feb 2024 18:43:21 +0100 Subject: [PATCH] Bug 35904: (QA follow-up): rename do_not_print + add comment rename to no_print_for_tests --- C4/Auth.pm | 6 +++--- t/db_dependent/Auth.t | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index c099dbc28c..46495f754d 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -791,7 +791,7 @@ sub checkauth { my $type = shift; my $emailaddress = shift; my $template_name = shift; - my $params = shift || {}; # do_not_print + my $params = shift || {}; # no_print_for_tests: no HTTP response and just return template variables $type = 'opac' unless $type; if ( $type eq 'opac' && !C4::Context->preference("OpacPublic") ) { @@ -1333,7 +1333,7 @@ sub checkauth { $uri->query_param_delete('userid'); $uri->query_param_delete('password'); $uri->query_param_delete('koha_login_context'); - unless ( $params->{do_not_print} ) { + unless ( $params->{no_print_for_tests} ) { print $query->redirect( -uri => $uri->as_string, -cookie => $cookie, -status => '303 See other' ); safe_exit; } @@ -1484,7 +1484,7 @@ sub checkauth { ); $template->param(%info); - if ( $params->{do_not_print} ) { + if ( $params->{no_print_for_tests} ) { # This must be used for testing purpose only! return ( undef, undef, undef, undef, $template ); } diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t index d6ee58d744..1e62f45764 100755 --- a/t/db_dependent/Auth.t +++ b/t/db_dependent/Auth.t @@ -156,7 +156,7 @@ subtest 'checkauth() tests' => sub { $cgi->param( 'userid', $patron->userid ); $cgi->param( 'password', $password ); - my ( $userid, $cookie, $sessionID, $flags, $template ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); + my ( $userid, $cookie, $sessionID, $flags, $template ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { no_print_for_tests => 1 } ); is( $template->{VARS}->{password_has_expired}, 1 ); }; @@ -191,7 +191,7 @@ subtest 'checkauth() tests' => sub { $cgi->param( -name => 'koha_login_context', -value => 1 ); my ( $userid, $cookie, $flags, $template ); ( $userid, $cookie, $sessionID, $flags, $template ) = - C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); + C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { no_print_for_tests => 1 } ); is( $template->{VARS}->{loginprompt}, 1, 'Changing to non-existent user causes a redirect to login' ); }; @@ -226,7 +226,7 @@ subtest 'checkauth() tests' => sub { $cgi->param( -name => 'password', -value => $password ); $cgi->param( -name => 'koha_login_context', -value => 1 ); my ( $userid, $cookie, $sessionID, $flags, $template ) = - C4::Auth::checkauth( $cgi, 0, {}, 'opac', undef, undef, { do_not_print => 1 } ); + C4::Auth::checkauth( $cgi, 0, {}, 'opac', undef, undef, { no_print_for_tests => 1 } ); is( $userid, $patron2->userid, 'Login of patron2 approved' ); isnt( $sessionID, $previous_sessionID, 'Did not return previous session ID' ); ok( $sessionID, 'New session ID not empty' ); @@ -243,7 +243,7 @@ subtest 'checkauth() tests' => sub { $cgi->param( -name => 'password', -value => $password ); $cgi->param( -name => 'koha_login_context', -value => 1 ); ( $userid, $cookie, $sessionID, $flags, $template ) = - C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); + C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { no_print_for_tests => 1 } ); is( $template->{VARS}->{nopermission}, 1, 'No permission response' ); }; @@ -774,7 +774,7 @@ subtest 'checkauth & check_cookie_auth' => sub { $ENV{"HTTP_COOKIE"} = "CGISESSID=$sessionID"; # Not authenticated yet, the login form is displayed my $template; - ( $userid, $cookie, $sessionID, $flags, $template ) = C4::Auth::checkauth($cgi, 0, {catalogue => 1}, 'intranet', undef, undef, { do_not_print => 1 } ); + ( $userid, $cookie, $sessionID, $flags, $template ) = C4::Auth::checkauth($cgi, 0, {catalogue => 1}, 'intranet', undef, undef, { no_print_for_tests => 1 } ); is( $template->{VARS}->{loginprompt}, 1, ); # Sending undefined fails obviously @@ -816,7 +816,7 @@ subtest 'checkauth & check_cookie_auth' => sub { $cgi->param('logout.x', 1); $cgi->delete( 'userid', 'password' ); ( $userid, $cookie, $sessionID, $flags, $template ) = - C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); + C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { no_print_for_tests => 1 } ); is( $sessionID, undef ); is( $ENV{"HTTP_COOKIE"}, "CGISESSID=$first_sessionID", 'HTTP_COOKIE not unset' ); -- 2.43.2