6 use Test::More tests => 9;
7 use Data::Dump qw(dump);
14 ok( require( ( shift @ARGV || 't/config.pl' ) ), 'config.pl' );
16 sub ldap_check_error {
18 ok( ! $o->code, 'no errror' );
19 diag $o->error if $o->code;
22 ok( my $ldap = Net::LDAP->new( $config->{server} ), 'new Net::LDAP ' . dump( $config->{server} ) );
24 ok( my $bind = $ldap->bind( $config->{bind_as}, password => $config->{password} ), 'bind ' . $config->{bind_as} );
25 ldap_check_error $bind;
27 $config->{search}->{filter} = $ENV{FILTER} if $ENV{FILTER};
29 ok( my $search = $ldap->search( %{ $config->{search} } ), 'search ' . dump( $config->{search} ) );
30 ldap_check_error $search;
32 foreach my $entry ( $search->entries ) {
34 diag dump $entry if $ENV{FILTER};
38 my @required = @{ $config->{attributes_required} };
39 foreach my $attr ( @required ) {
40 next if grep { /^\Q$attr\E$/i } $entry->attributes;
42 diag "$missing missing $attr\n";
45 ok( ! $missing, "attributes " . dump( @required ) );
48 ok( $ldap->unbind, 'unbind' );