From 6242fa8d3005be3df33264cce8e15423b90c8959 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 21 Jan 2022 09:34:49 +0100 Subject: [PATCH] Bug 29915: Add tests Content-Type: text/plain; charset=utf-8 Rebased 25-01-22 on changes for 29914. --- t/db_dependent/Auth.t | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t index f053bd115d..3e6a8b4774 100755 --- a/t/db_dependent/Auth.t +++ b/t/db_dependent/Auth.t @@ -442,7 +442,7 @@ subtest '_timeout_syspref' => sub { }; subtest 'check_cookie_auth' => sub { - plan tests => 4; + plan tests => 5; t::lib::Mocks::mock_preference('timeout', "1d"); # back to default @@ -458,20 +458,24 @@ subtest 'check_cookie_auth' => sub { } ); $cgi->mock('multi_param', sub {return q{}} ); - $cgi->mock( 'cookie', sub { return; } ); + my $sessionID; + $cgi->mock( 'cookie', sub { return $sessionID; } ); $cgi->mock( 'request_method', sub { return 'POST' } ); $ENV{REMOTE_ADDR} = '127.0.0.1'; # Setting authnotrequired=1 or we wont' hit the return but the end of the sub that prints headers - my ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 1 ); + my ( $userid, $cookie, $flags ); + ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 1 ); my ($auth_status, $session) = C4::Auth::check_cookie_auth($sessionID); isnt( $auth_status, 'ok', 'check_cookie_auth should not return ok if the user has not been authenticated before if no permissions needed' ); is( $auth_status, 'anon', 'check_cookie_auth should return anon if the user has not been authenticated before and no permissions needed' ); + my $original_sessionID = $sessionID; ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 1 ); + is( $original_sessionID, $sessionID, 'checkauth should not generate a different sessionID' ); ($auth_status, $session) = C4::Auth::check_cookie_auth($sessionID, {catalogue => 1}); isnt( $auth_status, 'ok', 'check_cookie_auth should not return ok if the user has not been authenticated before and permissions needed' ); is( $auth_status, 'anon', 'check_cookie_auth should return anon if the user has not been authenticated before and permissions needed' ); -- 2.20.1