|
Lines 51-56
my $auth_by_bind = 1;
Link Here
|
| 51 |
my $anonymous_bind = 1; |
51 |
my $anonymous_bind = 1; |
| 52 |
my $user = 'cn=Manager,dc=metavore,dc=com'; |
52 |
my $user = 'cn=Manager,dc=metavore,dc=com'; |
| 53 |
my $pass = 'metavore'; |
53 |
my $pass = 'metavore'; |
|
|
54 |
my $attrs = {}; |
| 54 |
|
55 |
|
| 55 |
# Variables controlling LDAP behaviour |
56 |
# Variables controlling LDAP behaviour |
| 56 |
my $desired_authentication_result = 'success'; |
57 |
my $desired_authentication_result = 'success'; |
|
Lines 137-143
can_ok(
Link Here
|
| 137 |
|
138 |
|
| 138 |
subtest 'checkpw_ldap tests' => sub { |
139 |
subtest 'checkpw_ldap tests' => sub { |
| 139 |
|
140 |
|
| 140 |
plan tests => 4; |
141 |
plan tests => 5; |
| 141 |
|
142 |
|
| 142 |
## Connection fail tests |
143 |
## Connection fail tests |
| 143 |
$desired_connection_result = 'error'; |
144 |
$desired_connection_result = 'error'; |
|
Lines 372-377
qr/LDAP Auth rejected : invalid password for user 'hola'./,
Link Here
|
| 372 |
is( $ret, -1, 'checkpw_ldap returns -1 if bind fails (Bug 8148)' ); |
373 |
is( $ret, -1, 'checkpw_ldap returns -1 if bind fails (Bug 8148)' ); |
| 373 |
|
374 |
|
| 374 |
}; |
375 |
}; |
|
|
376 |
|
| 377 |
subtest "'update' config tets" => sub { |
| 378 |
|
| 379 |
plan tests => 4; |
| 380 |
|
| 381 |
$schema->storage->txn_begin; |
| 382 |
|
| 383 |
my $cardnumber = '123456789'; |
| 384 |
my $userid = '987654321'; |
| 385 |
|
| 386 |
# test safety cleanup |
| 387 |
Koha::Patrons->search( [ { cardnumber => $cardnumber }, { userid => $userid } ] )->delete; |
| 388 |
|
| 389 |
my $patron = $builder->build_object( |
| 390 |
{ |
| 391 |
class => 'Koha::Patrons', |
| 392 |
value => { cardnumber => $cardnumber, userid => $userid }, |
| 393 |
} |
| 394 |
); |
| 395 |
|
| 396 |
# avoid noise |
| 397 |
t::lib::Mocks::mock_preference( 'ExtendedPatronAttributes', 0 ); |
| 398 |
$welcome = 0; |
| 399 |
$replicate = 0; |
| 400 |
|
| 401 |
# the scenario |
| 402 |
$update = 1; |
| 403 |
|
| 404 |
$anonymous_bind = 0; |
| 405 |
$desired_count_result = 1; |
| 406 |
$desired_authentication_result = 'success'; |
| 407 |
$desired_admin_bind_result = 'success'; |
| 408 |
$desired_search_result = 'success'; |
| 409 |
$desired_bind_result = 'success'; |
| 410 |
|
| 411 |
$attrs = { |
| 412 |
branch => [ $patron->branchcode ], |
| 413 |
employeetype => [ $patron->categorycode ], |
| 414 |
givenname => [ $patron->firstname ], |
| 415 |
mail => [ $patron->email ], |
| 416 |
postaladdress => [ $patron->address ], |
| 417 |
sn => [ $patron->surname ], |
| 418 |
uid => [ $patron->userid ], |
| 419 |
userpassword => ['some password'], |
| 420 |
}; |
| 421 |
|
| 422 |
reload_ldap_module(); |
| 423 |
|
| 424 |
my ( $ret_val, $ret_cardnumber, $ret_userid ) = |
| 425 |
C4::Auth_with_ldap::checkpw_ldap( $patron->userid, password => 'hey' ); |
| 426 |
|
| 427 |
ok( $ret_val, 'Authentication success returns 1' ); |
| 428 |
is( $ret_cardnumber, $cardnumber, "The correct 'cardnumber' is returned" ); |
| 429 |
is( $ret_userid, $userid, "The correct 'userid' is returned" ); |
| 430 |
|
| 431 |
$patron->discard_changes; |
| 432 |
is( $patron->cardnumber, $cardnumber, 'The cardnumber is not mistakenly changed to userid when not mapped' ); |
| 433 |
|
| 434 |
$schema->storage->txn_rollback; |
| 435 |
}; |
| 375 |
}; |
436 |
}; |
| 376 |
|
437 |
|
| 377 |
subtest 'search_method tests' => sub { |
438 |
subtest 'search_method tests' => sub { |
|
Lines 542-548
sub mock_net_ldap_message {
Link Here
|
| 542 |
sub mock_net_ldap_entry { |
603 |
sub mock_net_ldap_entry { |
| 543 |
my ( $dn, $exists ) = @_; |
604 |
my ( $dn, $exists ) = @_; |
| 544 |
|
605 |
|
| 545 |
my $mocked_entry = Test::MockObject->new(); |
606 |
my $mocked_entry = Test::MockObject->new( { attrs => $attrs } ); |
| 546 |
$mocked_entry->mock( 'dn', sub { return $dn; } ); |
607 |
$mocked_entry->mock( 'dn', sub { return $dn; } ); |
| 547 |
$mocked_entry->mock( 'exists', sub { return $exists } ); |
608 |
$mocked_entry->mock( 'exists', sub { return $exists } ); |
| 548 |
|
609 |
|
| 549 |
- |
|
|