Bug 29914: Add tests
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 3af901ae64)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
(cherry picked from commit 86abecb3c2690745035c6703681505e825a8eb9a)
Signed-off-by: Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
This commit is contained in:
parent
2dd06e9409
commit
d63dce396d
|
|
@ -10,7 +10,7 @@ use CGI qw ( -utf8 );
|
|||
use Test::MockObject;
|
||||
use Test::MockModule;
|
||||
use List::MoreUtils qw/all any none/;
|
||||
use Test::More tests => 23;
|
||||
use Test::More tests => 24;
|
||||
use Test::Warn;
|
||||
use t::lib::Mocks;
|
||||
use t::lib::TestBuilder;
|
||||
|
|
@ -410,4 +410,30 @@ subtest '_timeout_syspref' => sub {
|
|||
is( C4::Auth::_timeout_syspref, 600, );
|
||||
};
|
||||
|
||||
subtest 'check_cookie_auth' => sub {
|
||||
plan tests => 1;
|
||||
|
||||
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => 1 } });
|
||||
|
||||
# Mock a CGI object with real userid param
|
||||
my $cgi = Test::MockObject->new();
|
||||
$cgi->mock(
|
||||
'param',
|
||||
sub {
|
||||
my $var = shift;
|
||||
if ( $var eq 'userid' ) { return $patron->userid; }
|
||||
elsif ( $var eq 'timeout' ) { return 3600; }
|
||||
}
|
||||
);
|
||||
$cgi->mock('multi_param', sub {return q{}} );
|
||||
$cgi->mock( 'cookie', sub { return; } );
|
||||
$cgi->mock( 'request_method', sub { return 'POST' } );
|
||||
|
||||
# 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 ($auth_status, $session) = C4::Auth::check_cookie_auth($sessionID, {catalogue => 1});
|
||||
is( $auth_status, 'anon', 'check_cookie_auth should not return ok if the user has not been authenticated before' );
|
||||
};
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
|
|||
Loading…
Reference in New Issue