Bug 36575: Unit tests for checkpw_ldap

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Tomás Cohen Arazi 2024-05-30 14:51:11 +00:00 committed by Katrin Fischer
parent 8ab3989654
commit 4b6781c9a3
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

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 {