Bug 36575: Unit tests for checkpw_ldap

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Tomás Cohen Arazi 2024-05-30 14:51:11 +00:00 committed by Lucas Gass
parent 822d7f43ab
commit 00d17b700a

View file

@ -138,7 +138,7 @@ can_ok(
subtest 'checkpw_ldap tests' => sub {
plan tests => 5;
plan tests => 6;
## Connection fail tests
$desired_connection_result = 'error';
@ -433,6 +433,41 @@ qr/LDAP Auth rejected : invalid password for user 'hola'./,
$schema->storage->txn_rollback;
};
subtest "!update && !replica return values" => sub {
plan tests => 4;
$schema->storage->txn_begin;
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
# avoid noise
t::lib::Mocks::mock_preference( 'ExtendedPatronAttributes', 0 );
$welcome = 0;
# the scenario
$replicate = 0;
$update = 0;
$anonymous_bind = 0;
$desired_count_result = 1;
$desired_authentication_result = 'success';
$desired_admin_bind_result = 'success';
$desired_search_result = 'success';
$desired_bind_result = 'success';
reload_ldap_module();
my ( $ret_val, $ret_cardnumber, $ret_userid, $ret_patron ) =
C4::Auth_with_ldap::checkpw_ldap( $patron->userid, password => 'hey' );
is( $ret_val, 1 );
is( $ret_cardnumber, $patron->cardnumber );
is( $ret_userid, $patron->userid );
is( $ret_patron->id, $patron->id );
$schema->storage->txn_rollback;
};
};
subtest 'search_method tests' => sub {