Lines 1447-1469
subtest 'checkpw for users with shared cardnumber / userid ' => sub {
Link Here
|
1447 |
plan tests => 8; |
1447 |
plan tests => 8; |
1448 |
|
1448 |
|
1449 |
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); |
1449 |
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); |
1450 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
1450 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
1451 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); |
1451 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); |
1452 |
$patron_1->set_password( { password => "OnePassword" } ); |
1452 |
$patron_1->set_password( { password => "OnePassword" } ); |
1453 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { userid => $patron_1->cardnumber } } ); |
1453 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { userid => $patron_1->cardnumber } } ); |
1454 |
$patron_2->set_password( { password => "PasswordTwo" } ); |
1454 |
$patron_2->set_password( { password => "PasswordTwo" } ); |
1455 |
|
1455 |
|
1456 |
my ( $checkpw, $cardnumber, $userid, $patron ) = checkpw( $patron_1->cardnumber, "OnePassword", undef, undef, 1 ); |
1456 |
my ( $checkpw, $cardnumber, $userid, $patron ) = checkpw( $patron_1->cardnumber, "OnePassword", undef, undef, 1 ); |
1457 |
ok( $checkpw, 'checkpw returns true for right password when logging in via cardnumber' ); |
1457 |
ok( $checkpw, 'checkpw returns true for right password when logging in via cardnumber' ); |
1458 |
is( $cardnumber, $patron_1->cardnumber, 'checkpw returns correct cardnumber' ); |
1458 |
is( $cardnumber, $patron_1->cardnumber, 'checkpw returns correct cardnumber' ); |
1459 |
is( $userid, $patron_1->userid, 'checkpw returns correct userid' ); |
1459 |
is( $userid, $patron_1->userid, 'checkpw returns correct userid' ); |
1460 |
is( $patron->id, $patron_1->id, 'checkpw returns correct patron' ); |
1460 |
is( $patron->id, $patron_1->id, 'checkpw returns correct patron' ); |
1461 |
|
1461 |
|
1462 |
( $checkpw, $cardnumber, $userid, $patron ) = checkpw( $patron_2->userid, "PasswordTwo", undef, undef, 1 ); |
1462 |
( $checkpw, $cardnumber, $userid, $patron ) = checkpw( $patron_2->userid, "PasswordTwo", undef, undef, 1 ); |
1463 |
ok( $checkpw, 'checkpw returns true for right password when logging in via userid' ); |
1463 |
ok( $checkpw, 'checkpw returns true for right password when logging in via userid' ); |
1464 |
is( $cardnumber, $patron_2->cardnumber, 'checkpw returns correct cardnumber' ); |
1464 |
is( $cardnumber, $patron_2->cardnumber, 'checkpw returns correct cardnumber' ); |
1465 |
is( $userid, $patron_2->userid, 'checkpw returns correct userid' ); |
1465 |
is( $userid, $patron_2->userid, 'checkpw returns correct userid' ); |
1466 |
is( $patron->id, $patron_2->id, 'checkpw returns correct patron' ); |
1466 |
is( $patron->id, $patron_2->id, 'checkpw returns correct patron' ); |
1467 |
|
1467 |
|
1468 |
}; |
1468 |
}; |
1469 |
|
1469 |
|