Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

apply rt #74426

  • Loading branch information...
commit b3f912b2296736000b58cf341a18beaf4a39f47c 1 parent a333d2f
@karpet authored
Showing with 37 additions and 2 deletions.
  1. +4 −2 lib/Net/LDAP/Server/Test.pm
  2. +33 −0 t/03-socket.t
View
6 lib/Net/LDAP/Server/Test.pm
@@ -797,6 +797,8 @@ listing on I<port> and handling requests using Net::LDAP::Server.
I<port> defaults to 10636.
+I<port> may be an IO::Socket::INET object listening to a local port.
+
I<key_value_args> may be:
=over
@@ -846,10 +848,10 @@ sub new {
}
elsif ( $pid == 0 ) {
- warn "Creating new LDAP server on port $port ... \n" if $ENV{LDAP_DEBUG};
+ warn "Creating new LDAP server on port " . (ref $port ? $port->sockport : $port) . " ... \n" if $ENV{LDAP_DEBUG};
# the child (server)
- my $sock = IO::Socket::INET->new(
+ my $sock = ref $port ? $port : IO::Socket::INET->new(
Listen => 5,
Proto => 'tcp',
Reuse => 1,
View
33 t/03-socket.t
@@ -0,0 +1,33 @@
+use Test::More tests => 2;
+
+use strict;
+use warnings;
+use Carp;
+
+use Net::LDAP;
+use Net::LDAP::Server::Test;
+use Net::LDAP::Entry;
+use IO::Socket::INET;
+
+#
+# these tests pulled nearly verbatim from the Net::LDAP synopsis
+#
+
+my %opts = (
+ port => '10636',
+ dnc => 'ou=internal,dc=foo',
+ debug => $ENV{PERL_DEBUG} || 0,
+);
+
+my $host = 'ldap://localhost:' . $opts{port};
+
+my $socket = IO::Socket::INET->new(
+ Listen => 5,
+ Proto => 'tcp',
+ Reuse => 1,
+ LocalPort => $opts{port},
+);
+ok( my $server = Net::LDAP::Server::Test->new( $socket ),
+ "spawn new server with socket passed" );
+
+ok( my $ldap = Net::LDAP->new( $host, %opts, ), "new LDAP connection" );
Please sign in to comment.
Something went wrong with that request. Please try again.