|
Lines 328-335
subtest 'checkauth() tests' => sub {
Link Here
|
| 328 |
is( $auth_status, 'ok', 'User waiting for 2FA setup, pref was disabled, access OK' ); |
328 |
is( $auth_status, 'ok', 'User waiting for 2FA setup, pref was disabled, access OK' ); |
| 329 |
}; |
329 |
}; |
| 330 |
|
330 |
|
| 331 |
C4::Context->_new_userenv; # For next tests |
331 |
subtest 'loggedinlibrary permission tests' => sub { |
|
|
332 |
|
| 333 |
plan tests => 3; |
| 334 |
my $staff_user = $builder->build_object( |
| 335 |
{ class => 'Koha::Patrons', value => { flags => 536870916 } } ); |
| 336 |
|
| 337 |
my $branch = $builder->build_object({ class => 'Koha::Libraries' }); |
| 332 |
|
338 |
|
|
|
339 |
my $password = 'password'; |
| 340 |
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); |
| 341 |
$staff_user->set_password( { password => $password } ); |
| 342 |
my $cgi = Test::MockObject->new(); |
| 343 |
$cgi->mock( 'cookie', sub { return; } ); |
| 344 |
$cgi->mock( |
| 345 |
'param', |
| 346 |
sub { |
| 347 |
my ( $self, $param ) = @_; |
| 348 |
if ( $param eq 'userid' ) { return $staff_user->userid; } |
| 349 |
elsif ( $param eq 'password' ) { return $password; } |
| 350 |
elsif ( $param eq 'branch' ) { return $branch->branchcode; } |
| 351 |
else { return; } |
| 352 |
} |
| 353 |
); |
| 354 |
|
| 355 |
$cgi->mock( 'request_method', sub { return 'POST' } ); |
| 356 |
my ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired' ); |
| 357 |
my $sesh = C4::Auth::get_session($sessionID); |
| 358 |
is( $sesh->param('branch'), $branch->branchcode, "If user has permission, they should be able to choose a branch" ); |
| 359 |
|
| 360 |
$staff_user->flags(4)->store->discard_changes; |
| 361 |
( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired' ); |
| 362 |
$sesh = C4::Auth::get_session($sessionID); |
| 363 |
is( $sesh->param('branch'), $staff_user->branchcode, "If user has not permission, they should not be able to choose a branch" ); |
| 364 |
|
| 365 |
$staff_user->flags(1)->store->discard_changes; |
| 366 |
( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired' ); |
| 367 |
$sesh = C4::Auth::get_session($sessionID); |
| 368 |
is( $sesh->param('branch'), $branch->branchcode, "If user is superlibrarian, they should be able to choose a branch" ); |
| 369 |
|
| 370 |
}; |
| 371 |
C4::Context->_new_userenv; # For next tests |
| 333 |
}; |
372 |
}; |
| 334 |
|
373 |
|
| 335 |
subtest 'track_login_daily tests' => sub { |
374 |
subtest 'track_login_daily tests' => sub { |
| 336 |
- |
|
|