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

(-)a/t/db_dependent/Auth.t (-3 / +22 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 => 11;
1348
1355
1349
    $schema->storage->txn_begin;
1356
    $schema->storage->txn_begin;
1350
1357
Lines 1423-1428 subtest 'AutoLocation' => sub { Link Here
1423
    $session = C4::Auth::get_session($sessionID);
1430
    $session = C4::Auth::get_session($sessionID);
1424
    is( $session->param('branch'), $noip_library->branchcode, "When a branch with no IP set is chosen, we respect the choice regardless of current IP" );
1431
    is( $session->param('branch'), $noip_library->branchcode, "When a branch with no IP set is chosen, we respect the choice regardless of current IP" );
1425
1432
1433
    $ENV{REMOTE_ADDR} = '129.0.0.1';          # Set current IP to match other_branch
1434
    $cgi->param( 'branch', undef );           # Do not pass a branch
1435
    $patron->library->branchip('')->store;    # Unset user branch IP, to allow IP matching on any branch
1436
    # Add a second branch with same IP
1437
    my $another_library = $builder->build_object( { class => 'Koha::Libraries', value => { branchip => '129.0.0.1' } } );
1438
    ( $userid, $cookie, $sessionID, $flags, $template ) =
1439
        C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } );
1440
    $session = C4::Auth::get_session($sessionID);
1441
    is(
1442
        $session->param('branch'), $other_library->branchcode,
1443
        "Which branch is chosen when home branch has no IP and more than 1 library matches?"
1444
    );
1445
1426
    $schema->storage->txn_rollback;
1446
    $schema->storage->txn_rollback;
1427
1447
1428
};
1448
};
1429
- 

Return to bug 36908