3 |
use warnings; |
use warnings; |
4 |
use strict; |
use strict; |
5 |
|
|
6 |
use Test::More tests => 37; |
use Test::More tests => 76; |
7 |
use Data::Dump qw(dump); |
use Data::Dump qw(dump); |
8 |
|
|
9 |
BEGIN { |
BEGIN { |
10 |
use_ok 'Net::LDAP'; |
use_ok 'Net::LDAP'; |
11 |
} |
} |
12 |
|
|
13 |
|
our $config; |
14 |
|
ok( require( ( shift @ARGV || 't/config.pl' ) ), 'config.pl' ); |
15 |
|
|
16 |
|
diag "config ",dump($config); |
17 |
|
|
18 |
sub ldap_check_error { |
sub ldap_check_error { |
19 |
my $o = shift; |
my $o = shift; |
20 |
ok( ! $o->code, 'no errror' ); |
ok( ! $o->code, 'no errror' ); |
26 |
ok( my $bind = $ldap->bind, 'bind' ); |
ok( my $bind = $ldap->bind, 'bind' ); |
27 |
ldap_check_error $bind; |
ldap_check_error $bind; |
28 |
|
|
|
my @test_searches = ( qw/ |
|
|
uid=dpavlin@ffzg.hr |
|
|
pager=E00401001F77E218 |
|
|
/ ); |
|
|
|
|
29 |
sub check_search_attributes { |
sub check_search_attributes { |
30 |
my $search = shift; |
my $search = shift; |
31 |
|
|
35 |
} |
} |
36 |
} |
} |
37 |
|
|
38 |
foreach my $search ( @test_searches ) { |
sub search { |
39 |
|
my ($ldap,$search) = @_; |
40 |
|
ok( my $result = $ldap->search( filter => $search ), "search $search" ); |
41 |
|
ldap_check_error $result; |
42 |
|
ok( $result->entries, 'have results' ); |
43 |
|
return $result; |
44 |
|
} |
45 |
|
|
46 |
ok( my $search = $ldap->search( filter => $search ), "search $search" ); |
foreach my $search ( qw/ |
47 |
ldap_check_error $search; |
uid=dpavlin@ffzg.hr |
48 |
ok( $search->entries, 'have results' ); |
pager=E00401001F77E218 |
49 |
check_search_attributes $search => 'uid', 'mail', 'pager', 'memberOf'; |
/ ) { |
50 |
|
my $entries = search $ldap => $search; |
51 |
|
check_search_attributes $entries => 'uid', 'mail', 'pager', 'memberOf'; |
52 |
|
|
53 |
|
$entries = search $ldap => "(&(objectclass=HrEduPerson)($search))"; |
54 |
|
check_search_attributes $entries => 'uid', 'mail', 'pager', 'memberOf'; |
55 |
} |
} |
56 |
|
|
57 |
|
search $ldap => $_ foreach ( qw/ |
58 |
|
objectclass=organizationalUnit |
59 |
|
objectclass=group |
60 |
|
/ ); |
61 |
|
|
62 |
ok( $ldap->unbind, 'unbind' ); |
ok( $ldap->unbind, 'unbind' ); |