Lines 41-47
$schema->storage->txn_begin;
Link Here
|
41 |
|
41 |
|
42 |
subtest 'checkauth() tests' => sub { |
42 |
subtest 'checkauth() tests' => sub { |
43 |
|
43 |
|
44 |
plan tests => 6; |
44 |
plan tests => 7; |
45 |
|
45 |
|
46 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } }); |
46 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } }); |
47 |
|
47 |
|
Lines 260-267
subtest 'checkauth() tests' => sub {
Link Here
|
260 |
is( $auth_status, 'ok', 'User waiting for 2FA setup, pref was disabled, access OK' ); |
260 |
is( $auth_status, 'ok', 'User waiting for 2FA setup, pref was disabled, access OK' ); |
261 |
}; |
261 |
}; |
262 |
|
262 |
|
263 |
C4::Context->_new_userenv; # For next tests |
263 |
subtest 'loggedinlibrary permission tests' => sub { |
|
|
264 |
|
265 |
plan tests => 3; |
266 |
my $staff_user = $builder->build_object( |
267 |
{ class => 'Koha::Patrons', value => { flags => 536870916 } } ); |
264 |
|
268 |
|
|
|
269 |
my $branch = $builder->build_object({ class => 'Koha::Libraries' }); |
270 |
|
271 |
my $password = 'password'; |
272 |
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); |
273 |
$staff_user->set_password( { password => $password } ); |
274 |
my $cgi = Test::MockObject->new(); |
275 |
$cgi->mock( 'cookie', sub { return; } ); |
276 |
$cgi->mock( |
277 |
'param', |
278 |
sub { |
279 |
my ( $self, $param ) = @_; |
280 |
if ( $param eq 'userid' ) { return $staff_user->userid; } |
281 |
elsif ( $param eq 'password' ) { return $password; } |
282 |
elsif ( $param eq 'branch' ) { return $branch->branchcode; } |
283 |
else { return; } |
284 |
} |
285 |
); |
286 |
|
287 |
$cgi->mock( 'request_method', sub { return 'POST' } ); |
288 |
my ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired' ); |
289 |
my $sesh = C4::Auth::get_session($sessionID); |
290 |
is( $sesh->param('branch'), $branch->branchcode, "If user has permission, they should be able to choose a branch" ); |
291 |
|
292 |
$staff_user->flags(4)->store->discard_changes; |
293 |
( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired' ); |
294 |
$sesh = C4::Auth::get_session($sessionID); |
295 |
is( $sesh->param('branch'), $staff_user->branchcode, "If user has not permission, they should not be able to choose a branch" ); |
296 |
|
297 |
$staff_user->flags(1)->store->discard_changes; |
298 |
( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired' ); |
299 |
$sesh = C4::Auth::get_session($sessionID); |
300 |
is( $sesh->param('branch'), $branch->branchcode, "If user is superlibrarian, they should be able to choose a branch" ); |
301 |
|
302 |
}; |
303 |
C4::Context->_new_userenv; # For next tests |
265 |
}; |
304 |
}; |
266 |
|
305 |
|
267 |
subtest 'track_login_daily tests' => sub { |
306 |
subtest 'track_login_daily tests' => sub { |
268 |
- |
|
|