From b07279a6a2e79ef9421fa1699661340a1f8fd012 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 14 Feb 2024 10:56:17 +0100 Subject: [PATCH] Bug 36092: Add test --- t/db_dependent/Auth.t | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t index af7709f0587..50226b705db 100755 --- a/t/db_dependent/Auth.t +++ b/t/db_dependent/Auth.t @@ -7,7 +7,7 @@ use CGI qw ( -utf8 ); use Test::MockObject; use Test::MockModule; use List::MoreUtils qw/all any none/; -use Test::More tests => 20; +use Test::More tests => 21; use Test::Warn; use t::lib::Mocks; use t::lib::TestBuilder; @@ -42,7 +42,7 @@ $schema->storage->txn_begin; subtest 'checkauth() tests' => sub { - plan tests => 9; + plan tests => 10; my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } }); @@ -110,11 +110,35 @@ subtest 'checkauth() tests' => sub { is( $userid, undef, 'If librarian user is used and password with GET, they should not be logged in' ); }; - subtest 'Template params tests (password_expired)' => sub { + subtest 'sessionID should be passed to the template for auth' => sub { plan tests => 1; - my $password_expired; + subtest 'hit auth.tt' => sub { + + plan tests => 1; + + my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 0 } } ); + + my $password = set_weak_password($patron); + + my $cgi_mock = Test::MockModule->new('CGI'); + $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 ); + + my ( $userid, $cookie, $sessionID, $flags, $template ) = + C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); + ok( $template->{VARS}->{sessionID} ); + }; + }; + + subtest 'Template params tests (password_expired)' => sub { + + plan tests => 1; my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); -- 2.34.1