Bug 36034: Add test

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2024-02-14 08:49:33 +01:00 committed by Lucas Gass
parent 3280e5a99d
commit 80822f7689

View file

@ -41,7 +41,7 @@ $schema->storage->txn_begin;
subtest 'checkauth() tests' => sub { subtest 'checkauth() tests' => sub {
plan tests => 9; plan tests => 10;
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } }); my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } });
@ -111,6 +111,36 @@ subtest 'checkauth() tests' => sub {
is( $userid, undef, 'If librarian user is used and password with GET, they should not be logged in' ); is( $userid, undef, 'If librarian user is used and password with GET, they should not be logged in' );
}; };
subtest 'cas_ticket must be empty in session' => sub {
plan tests => 2;
my $patron = $builder->build_object(
{ class => 'Koha::Patrons', value => { flags => 1 } } );
my $password = 'password';
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 );
$patron->set_password( { password => $password } );
$cgi = Test::MockObject->new();
$cgi->mock( 'cookie', sub { return; } );
$cgi->mock(
'param',
sub {
my ( $self, $param ) = @_;
if ( $param eq 'userid' ) { return $patron->userid; }
elsif ( $param eq 'password' ) { return $password; }
else { return; }
}
);
$cgi->mock( 'request_method', sub { return 'POST' } );
( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired' );
is( $userid, $patron->userid, 'If librarian user is used and password with POST, they should be logged in' );
my $session = C4::Auth::get_session($sessionID);
is( $session->param('cas_ticket'), undef );
};
subtest 'Template params tests (password_expired)' => sub { subtest 'Template params tests (password_expired)' => sub {
plan tests => 1; plan tests => 1;