From 59ae5d7b6d3d43bc076764d0e9b927b84efb83bb Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 28 Feb 2024 10:06:08 +0100 Subject: [PATCH] Bug 36102: (follow-up 2) Add cud-login to the login form - fix tests Bug 36102: [TO SQUASH] (follow-up 2) Add cud-login to the login form - fix tests Signed-off-by: Jonathan Druart --- t/db_dependent/Auth.t | 54 +++++++++++----------- t/db_dependent/www/auth_values_input_www.t | 4 +- t/db_dependent/www/history.t | 4 +- t/db_dependent/www/search_utf8.t | 4 +- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t index 039b90ed8c..99381c9365 100755 --- a/t/db_dependent/Auth.t +++ b/t/db_dependent/Auth.t @@ -69,8 +69,8 @@ subtest 'checkauth() tests' => sub { $cgi->mock( 'cookie', sub { return; } ); $cgi->mock( 'param', sub { my ( $self, $param ) = @_; - if ( $param eq 'userid' ) { return $db_user_id; } - elsif ( $param eq 'password' ) { return $db_user_pass; } + if ( $param eq 'login_userid' ) { return $db_user_id; } + elsif ( $param eq 'login_password' ) { return $db_user_pass; } else { return; } }); $cgi->mock( 'request_method', sub { return 'POST' } ); @@ -95,8 +95,8 @@ subtest 'checkauth() tests' => sub { 'param', sub { my ( $self, $param ) = @_; - if ( $param eq 'userid' ) { return $patron->userid; } - elsif ( $param eq 'password' ) { return $password; } + if ( $param eq 'login_userid' ) { return $patron->userid; } + elsif ( $param eq 'login_password' ) { return $password; } else { return; } } ); @@ -124,8 +124,8 @@ subtest 'checkauth() tests' => sub { 'param', sub { my ( $self, $param ) = @_; - if ( $param eq 'userid' ) { return $patron->userid; } - elsif ( $param eq 'password' ) { return $password; } + if ( $param eq 'login_userid' ) { return $patron->userid; } + elsif ( $param eq 'login_password' ) { return $password; } else { return; } } ); @@ -155,8 +155,8 @@ subtest 'checkauth() tests' => sub { my $cgi = CGI->new; # Simulating the login form submission - $cgi->param( 'userid', $patron->userid ); - $cgi->param( 'password', $password ); + $cgi->param( 'login_userid', $patron->userid ); + $cgi->param( 'login_password', $password ); my ( $userid, $cookie, $sessionID, $flags, $template ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); @@ -177,8 +177,8 @@ subtest 'checkauth() tests' => sub { $cgi_mock->mock( 'request_method', sub { return 'POST' } ); my $cgi = CGI->new; # Simulating the login form submission - $cgi->param( 'userid', $patron->userid ); - $cgi->param( 'password', $password ); + $cgi->param( 'login_userid', $patron->userid ); + $cgi->param( 'login_password', $password ); my ( $userid, $cookie, $sessionID, $flags, $template ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); is( $template->{VARS}->{password_has_expired}, 1 ); @@ -210,8 +210,8 @@ subtest 'checkauth() tests' => sub { $mock2->mock( 'cookie', sub { return $sessionID; } ); # oversimplified.. my $cgi = CGI->new; - $cgi->param( -name => 'userid', -value => 'Bond' ); - $cgi->param( -name => 'password', -value => 'James Bond' ); + $cgi->param( -name => 'login_userid', -value => 'Bond' ); + $cgi->param( -name => 'login_password', -value => 'James Bond' ); $cgi->param( -name => 'koha_login_context', -value => 1 ); my ( $userid, $cookie, $flags, $template ); ( $userid, $cookie, $sessionID, $flags, $template ) = @@ -246,8 +246,8 @@ subtest 'checkauth() tests' => sub { my $cgi = CGI->new; my $password = 'Incr3d1blyZtr@ng93$'; $patron2->set_password({ password => $password }); - $cgi->param( -name => 'userid', -value => $patron2->userid ); - $cgi->param( -name => 'password', -value => $password ); + $cgi->param( -name => 'login_userid', -value => $patron2->userid ); + $cgi->param( -name => 'login_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 } ); @@ -263,8 +263,8 @@ subtest 'checkauth() tests' => sub { $session->flush; $previous_sessionID = $session->id; C4::Context->_new_userenv($previous_sessionID); - $cgi->param( -name => 'userid', -value => $patron2->userid ); - $cgi->param( -name => 'password', -value => $password ); + $cgi->param( -name => 'login_userid', -value => $patron2->userid ); + $cgi->param( -name => 'login_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 } ); @@ -286,8 +286,8 @@ subtest 'checkauth() tests' => sub { 'param', sub { my ( $self, $param ) = @_; - if ( $param eq 'userid' ) { return $patron->userid; } - elsif ( $param eq 'password' ) { return $password; } + if ( $param eq 'login_userid' ) { return $patron->userid; } + elsif ( $param eq 'login_password' ) { return $password; } elsif ( $param eq 'otp_token' ) { return $otp_token; } elsif ( $param eq 'logout.x' ) { return $logout; } else { return; } @@ -394,8 +394,8 @@ subtest 'checkauth() tests' => sub { 'param', sub { my ( $self, $param ) = @_; - if ( $param eq 'userid' ) { return $staff_user->userid; } - elsif ( $param eq 'password' ) { return $password; } + if ( $param eq 'login_userid' ) { return $staff_user->userid; } + elsif ( $param eq 'login_password' ) { return $password; } elsif ( $param eq 'branch' ) { return $branch->branchcode; } else { return; } } @@ -807,8 +807,8 @@ subtest 'checkauth & check_cookie_auth' => sub { is( $session, undef ); # Simulating the login form submission - $cgi->param('userid', $patron->userid); - $cgi->param('password', $password); + $cgi->param('login_userid', $patron->userid); + $cgi->param('login_password', $password); # Logged in! ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth($cgi, 0, {catalogue => 1}); @@ -838,7 +838,7 @@ subtest 'checkauth & check_cookie_auth' => sub { # Logging out! $cgi->param('logout.x', 1); - $cgi->delete( 'userid', 'password' ); + $cgi->delete( 'login_userid', 'login_password' ); ( $userid, $cookie, $sessionID, $flags, $template ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); @@ -871,8 +871,8 @@ subtest 'checkauth & check_cookie_auth' => sub { { # First logging in $cgi = CGI->new; - $cgi->param('userid', $patron->userid); - $cgi->param('password', $password); + $cgi->param('login_userid', $patron->userid); + $cgi->param('login_password', $password); ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth($cgi, 0, {catalogue => 1}); is( $userid, $patron->userid ); $first_sessionID = $sessionID; @@ -1311,8 +1311,8 @@ subtest 'AutoLocation' => sub { my $auth = Test::MockModule->new('C4::Auth'); # Simulating the login form submission - $cgi->param( 'userid', $patron->userid ); - $cgi->param( 'password', $password ); + $cgi->param( 'login_userid', $patron->userid ); + $cgi->param( 'login_password', $password ); $ENV{REMOTE_ADDR} = '127.0.0.1'; my ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); diff --git a/t/db_dependent/www/auth_values_input_www.t b/t/db_dependent/www/auth_values_input_www.t index 6a5fecd709..5933658ced 100755 --- a/t/db_dependent/www/auth_values_input_www.t +++ b/t/db_dependent/www/auth_values_input_www.t @@ -64,8 +64,8 @@ my ($category, $expected_base, $add_form_link_exists); $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'connect to intranet' ); $agent->form_name('loginform'); -$agent->field( 'password', $password ); -$agent->field( 'userid', $user ); +$agent->field( 'login_password', $password ); +$agent->field( 'login_userid', $user ); $agent->field( 'branch', '' ); $agent->click_ok( '', 'login to staff interface' ); $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'load main page' ); diff --git a/t/db_dependent/www/history.t b/t/db_dependent/www/history.t index ce79516ddd..2ea2285600 100755 --- a/t/db_dependent/www/history.t +++ b/t/db_dependent/www/history.t @@ -53,8 +53,8 @@ my $agent = Test::WWW::Mechanize->new( autocheck => 1 ); # Login $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'Load the intranet login page' ); $agent->form_name('loginform'); -$agent->field( 'password', $password ); -$agent->field( 'userid', $user ); +$agent->field( 'login_password', $password ); +$agent->field( 'login_userid', $user ); $agent->field( 'branch', '' ); $agent->click( '', 'Login to the intranet' ); $agent->get_ok( "$intranet/cgi-bin/koha/about.pl", 'Load the about page' ); diff --git a/t/db_dependent/www/search_utf8.t b/t/db_dependent/www/search_utf8.t index df72115359..efd16fe544 100755 --- a/t/db_dependent/www/search_utf8.t +++ b/t/db_dependent/www/search_utf8.t @@ -92,8 +92,8 @@ if ( not defined $mock_zebra->{indexer_pid} ) { our $agent = Test::WWW::Mechanize->new( autocheck => 1 ); $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'connect to intranet' ); $agent->form_name('loginform'); -$agent->field( 'userid', $ENV{KOHA_PASS} ); -$agent->field( 'password', $ENV{KOHA_USER} ); +$agent->field( 'login_userid', $ENV{KOHA_PASS} ); +$agent->field( 'login_password', $ENV{KOHA_USER} ); $agent->field( 'branch', '' ); $agent->click_ok( '', 'login to staff interface' ); -- 2.39.5