From 7bc46ea231c3e63e017da2a26a7a8918ed161cab 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 Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- t/db_dependent/Auth.t | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t index f8311e5460..a5423ea6f5 100755 --- a/t/db_dependent/Auth.t +++ b/t/db_dependent/Auth.t @@ -42,7 +42,7 @@ $schema->storage->txn_begin; subtest 'checkauth() tests' => sub { - plan tests => 10; + plan tests => 11; my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } }); @@ -139,13 +139,36 @@ subtest 'checkauth() tests' => sub { }; + subtest 'sessionID should be passed to the template for auth' => sub { + + plan tests => 1; + + 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 $password_expired; - my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); my $password = set_weak_password($patron); -- 2.39.5