View | Details | Raw Unified | Return to bug 29915
Collapse All | Expand All

(-)a/t/db_dependent/Auth.t (-4 / +7 lines)
Lines 442-448 subtest '_timeout_syspref' => sub { Link Here
442
};
442
};
443
443
444
subtest 'check_cookie_auth' => sub {
444
subtest 'check_cookie_auth' => sub {
445
    plan tests => 4;
445
    plan tests => 5;
446
446
447
    t::lib::Mocks::mock_preference('timeout', "1d"); # back to default
447
    t::lib::Mocks::mock_preference('timeout', "1d"); # back to default
448
448
Lines 458-477 subtest 'check_cookie_auth' => sub { Link Here
458
        }
458
        }
459
    );
459
    );
460
    $cgi->mock('multi_param', sub {return q{}} );
460
    $cgi->mock('multi_param', sub {return q{}} );
461
    $cgi->mock( 'cookie', sub { return; } );
461
    my $sessionID;
462
    $cgi->mock( 'cookie', sub { return $sessionID; } );
462
    $cgi->mock( 'request_method', sub { return 'POST' } );
463
    $cgi->mock( 'request_method', sub { return 'POST' } );
463
464
464
    $ENV{REMOTE_ADDR} = '127.0.0.1';
465
    $ENV{REMOTE_ADDR} = '127.0.0.1';
465
466
466
    # Setting authnotrequired=1 or we wont' hit the return but the end of the sub that prints headers
467
    # Setting authnotrequired=1 or we wont' hit the return but the end of the sub that prints headers
467
    my ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 1 );
468
    my ( $userid, $cookie, $flags );
469
    ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 1 );
468
470
469
    my ($auth_status, $session) = C4::Auth::check_cookie_auth($sessionID);
471
    my ($auth_status, $session) = C4::Auth::check_cookie_auth($sessionID);
470
    isnt( $auth_status, 'ok', 'check_cookie_auth should not return ok if the user has not been authenticated before if no permissions needed' );
472
    isnt( $auth_status, 'ok', 'check_cookie_auth should not return ok if the user has not been authenticated before if no permissions needed' );
471
    is( $auth_status, 'anon', 'check_cookie_auth should return anon if the user has not been authenticated before and no permissions needed' );
473
    is( $auth_status, 'anon', 'check_cookie_auth should return anon if the user has not been authenticated before and no permissions needed' );
472
474
475
    my $original_sessionID = $sessionID;
473
    ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 1 );
476
    ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 1 );
474
477
478
    is( $original_sessionID, $sessionID, 'checkauth should not generate a different sessionID' );
475
    ($auth_status, $session) = C4::Auth::check_cookie_auth($sessionID, {catalogue => 1});
479
    ($auth_status, $session) = C4::Auth::check_cookie_auth($sessionID, {catalogue => 1});
476
    isnt( $auth_status, 'ok', 'check_cookie_auth should not return ok if the user has not been authenticated before and permissions needed' );
480
    isnt( $auth_status, 'ok', 'check_cookie_auth should not return ok if the user has not been authenticated before and permissions needed' );
477
    is( $auth_status, 'anon', 'check_cookie_auth should return anon if the user has not been authenticated before and permissions needed' );
481
    is( $auth_status, 'anon', 'check_cookie_auth should return anon if the user has not been authenticated before and permissions needed' );
478
- 

Return to bug 29915