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

(-)a/t/db_dependent/Auth.t (-3 / +23 lines)
Lines 1294-1300 subtest 'checkpw() return values tests' => sub { Link Here
1294
1294
1295
subtest 'StaffLoginBranchBasedOnIP' => sub {
1295
subtest 'StaffLoginBranchBasedOnIP' => sub {
1296
1296
1297
    plan tests => 5;
1297
    plan tests => 7;
1298
1298
1299
    $schema->storage->txn_begin;
1299
    $schema->storage->txn_begin;
1300
1300
Lines 1340-1350 subtest 'StaffLoginBranchBasedOnIP' => sub { Link Here
1340
        "AutoLocation prevents StaffLoginBranchBasedOnIP from logging user in to another branch"
1340
        "AutoLocation prevents StaffLoginBranchBasedOnIP from logging user in to another branch"
1341
    );
1341
    );
1342
1342
1343
    t::lib::Mocks::mock_preference( 'AutoLocation', 0 );
1344
    my $other_branch   = $builder->build_object( { class => 'Koha::Libraries', value => { branchip => "127.0.0.1" } } );
1345
    ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' );
1346
    is( $userid, $patron->userid, "User successfully logged in" );
1347
    $session = C4::Auth::get_session($sessionID);
1348
    is( $session->param('branch'), $branch->branchcode, "Logged in branch is set based which branch when two libraries have same IP?" );
1349
1343
};
1350
};
1344
1351
1345
subtest 'AutoLocation' => sub {
1352
subtest 'AutoLocation' => sub {
1346
1353
1347
    plan tests => 9;
1354
    plan tests => 10;
1348
1355
1349
    $schema->storage->txn_begin;
1356
    $schema->storage->txn_begin;
1350
1357
Lines 1416-1421 subtest 'AutoLocation' => sub { Link Here
1416
        C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } );
1423
        C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } );
1417
    is( $template->{VARS}->{wrongip}, 1, "Login denied when branch specified and IP does not match branch IP" );
1424
    is( $template->{VARS}->{wrongip}, 1, "Login denied when branch specified and IP does not match branch IP" );
1418
1425
1426
1427
    $ENV{REMOTE_ADDR} = '129.0.0.1';          # Set current IP to match other_branch
1428
    $cgi->param( 'branch', undef );           # Do not pass a branch
1429
    $patron->library->branchip('')->store;    # Unset user branch IP, to allow IP matching on any branch
1430
    # Add a second branch with same IP
1431
    my $another_library = $builder->build_object( { class => 'Koha::Libraries', value => { branchip => '129.0.0.1' } } );
1432
    ( $userid, $cookie, $sessionID, $flags, $template ) =
1433
        C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } );
1434
    $session = C4::Auth::get_session($sessionID);
1435
    is(
1436
        $session->param('branch'), $other_library->branchcode,
1437
        "Which branch is chosen when home branch has no IP and more than 1 library matches?"
1438
    );
1439
1419
    $schema->storage->txn_rollback;
1440
    $schema->storage->txn_rollback;
1420
1441
1421
};
1442
};
1422
- 

Return to bug 36908