test Virtual LDAP implementation on top of Koha scheme
[virtual-ldap] / t / ldap-rewrite.pl
index e5cc3eb..5e88dbf 100755 (executable)
@@ -3,7 +3,7 @@
 use warnings;
 use strict;
 
-use Test::More tests => 8;
+use Test::More tests => 9;
 use Data::Dump qw(dump);
 
 BEGIN {
@@ -11,7 +11,7 @@ BEGIN {
 }
 
 our $config;
-ok( require "t/config.pl", 'config.pl' );
+ok( require( ( shift @ARGV || 't/config.pl' ) ), 'config.pl' );
 
 sub ldap_check_error {
        my $o = shift;
@@ -28,7 +28,18 @@ ok( my $search = $ldap->search( %{ $config->{search} } ), 'search ' . dump( $con
 ldap_check_error $search;
 
 foreach my $entry ( $search->entries ) {
+
        diag dump $entry;
+
+       my $missing = 0;
+       my @required = @{ $config->{attributes_required} };
+       foreach my $attr ( @required ) {
+               next if grep { /^\Q$attr\E$/i } $entry->attributes;
+               $missing++;
+               diag "$missing missing $attr\n";
+       }
+
+       ok( ! $missing, "attributes " . dump( @required ) );
 }
 
 ok( $ldap->unbind, 'unbind' );