2 use Test::More tests => 12;
5 use Net::LDAP::Server::Test;
9 # these tests pulled nearly verbatim from the Net::LDAP synopsis
14 dnc => 'ou=internal,dc=foo',
15 debug => $ENV{PERL_DEBUG} || 0,
18 my $host = 'ldap://localhost:' . $opts{port};
20 ok( my $server = Net::LDAP::Server::Test->new( $opts{port} ),
23 ok( my $ldap = Net::LDAP->new( $host, %opts, ), "new LDAP connection" );
26 croak "Unable to connect to LDAP server $host: $@";
29 ok( my $rc = $ldap->bind(), "LDAP bind()" );
31 ok( my $mesg = $ldap->search( # perform a search
33 filter => "(&(sn=Barr) (o=Texas Instruments))"
38 $mesg->code && croak $mesg->error;
41 foreach my $entry ( $mesg->entries ) {
47 is( $count, 13, "$count entries found in search" );
49 ok( $mesg = $ldap->unbind, "LDAP unbind()" );
54 my $entry = Net::LDAP::Entry->new;
55 $entry->dn('ou=foobar');
59 cn => [qw(value1 value2)]
63 ok( $server = Net::LDAP::Server::Test->new( $opts{port}, \@mydata ),
64 "spawn new server with our own data" );
66 ok( $ldap = Net::LDAP->new( $host, %opts, ), "new LDAP connection" );
69 croak "Unable to connect to LDAP server $host: $@";
72 ok( $rc = $ldap->bind(), "LDAP bind()" );
74 ok( $mesg = $ldap->search( # perform a search
76 filter => "(&(sn=Barr) (o=Texas Instruments))"
81 $mesg->code && croak $mesg->error;
84 foreach my $entry ( $mesg->entries ) {
90 is( $count, 1, "$count entries found in search" );
92 ok( $mesg = $ldap->unbind, "LDAP unbind()" );