Lines 1570-1592
subtest 'checkpw for users with shared cardnumber / userid ' => sub {
Link Here
|
1570 |
plan tests => 8; |
1570 |
plan tests => 8; |
1571 |
|
1571 |
|
1572 |
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); |
1572 |
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); |
1573 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
1573 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
1574 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); |
1574 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); |
1575 |
$patron_1->set_password( { password => "OnePassword" } ); |
1575 |
$patron_1->set_password( { password => "OnePassword" } ); |
1576 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { userid => $patron_1->cardnumber } } ); |
1576 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { userid => $patron_1->cardnumber } } ); |
1577 |
$patron_2->set_password( { password => "PasswordTwo" } ); |
1577 |
$patron_2->set_password( { password => "PasswordTwo" } ); |
1578 |
|
1578 |
|
1579 |
my ( $checkpw, $cardnumber, $userid, $patron ) = checkpw( $patron_1->cardnumber, "OnePassword", undef, undef, 1 ); |
1579 |
my ( $checkpw, $cardnumber, $userid, $patron ) = checkpw( $patron_1->cardnumber, "OnePassword", undef, undef, 1 ); |
1580 |
ok( $checkpw, 'checkpw returns true for right password when logging in via cardnumber' ); |
1580 |
ok( $checkpw, 'checkpw returns true for right password when logging in via cardnumber' ); |
1581 |
is( $cardnumber, $patron_1->cardnumber, 'checkpw returns correct cardnumber' ); |
1581 |
is( $cardnumber, $patron_1->cardnumber, 'checkpw returns correct cardnumber' ); |
1582 |
is( $userid, $patron_1->userid, 'checkpw returns correct userid' ); |
1582 |
is( $userid, $patron_1->userid, 'checkpw returns correct userid' ); |
1583 |
is( $patron->id, $patron_1->id, 'checkpw returns correct patron' ); |
1583 |
is( $patron->id, $patron_1->id, 'checkpw returns correct patron' ); |
1584 |
|
1584 |
|
1585 |
( $checkpw, $cardnumber, $userid, $patron ) = checkpw( $patron_2->userid, "PasswordTwo", undef, undef, 1 ); |
1585 |
( $checkpw, $cardnumber, $userid, $patron ) = checkpw( $patron_2->userid, "PasswordTwo", undef, undef, 1 ); |
1586 |
ok( $checkpw, 'checkpw returns true for right password when logging in via userid' ); |
1586 |
ok( $checkpw, 'checkpw returns true for right password when logging in via userid' ); |
1587 |
is( $cardnumber, $patron_2->cardnumber, 'checkpw returns correct cardnumber' ); |
1587 |
is( $cardnumber, $patron_2->cardnumber, 'checkpw returns correct cardnumber' ); |
1588 |
is( $userid, $patron_2->userid, 'checkpw returns correct userid' ); |
1588 |
is( $userid, $patron_2->userid, 'checkpw returns correct userid' ); |
1589 |
is( $patron->id, $patron_2->id, 'checkpw returns correct patron' ); |
1589 |
is( $patron->id, $patron_2->id, 'checkpw returns correct patron' ); |
1590 |
|
1590 |
|
1591 |
}; |
1591 |
}; |
1592 |
|
1592 |
|