Update of /cvsroot/perl-ldap/ldap/t
In directory sc8-pr-cvs1:/tmp/cvs-serv19753/t
Modified Files:
common.pl
Added Files:
56ipc.t 57url.t
Log Message:
Add support for URIs to be passed to ->new. ldap: ldaps: and ldapi:
are supported.
Change Net::LDAPS and Net::LDAPI to be very thin wrappers over new URI code
Tests added for ldapi and URIs based on code from Ziya Suzen
--- NEW FILE: 56ipc.t ---
#!perl
BEGIN {
require "t/common.pl";
start_server(ipc => 1);
}
print "1..12\n";
$ldap = client();
ok($ldap, "client");
$mesg = $ldap->bind($MANAGERDN, password => $PASSWD);
ok(!$mesg->code, "bind: " . $mesg->code . ": " . $mesg->error);
ok(ldif_populate($ldap, "data/50-in.ldif"), "data/50-in.ldif");
$mesg = $ldap->search(base => $BASEDN, filter => 'objectclass=*');
ok(!$mesg->code, "search: " . $mesg->code . ": " . $mesg->error);
compare_ldif("50",$mesg,$mesg->sorted);
$ldap = client(ipc => 1);
ok($ldap, "ipc client");
$mesg = $ldap->search(base => $BASEDN, filter => 'objectclass=*');
ok(!$mesg->code, "search: " . $mesg->code . ": " . $mesg->error);
compare_ldif("50",$mesg,$mesg->sorted);
--- NEW FILE: 57url.t ---
#!perl
BEGIN {
require "t/common.pl";
start_server();
}
my $num_tests = @URL * 5 + 7;
print "1..$num_tests\n";
$ldap = client();
ok($ldap, "client");
$mesg = $ldap->bind($MANAGERDN, password => $PASSWD);
ok(!$mesg->code, "bind: " . $mesg->code . ": " . $mesg->error);
ok(ldif_populate($ldap, "data/50-in.ldif"), "data/50-in.ldif");
$mesg = $ldap->search(base => $BASEDN, filter => 'objectclass=*');
ok(!$mesg->code, "search: " . $mesg->code . ": " . $mesg->error);
compare_ldif("50",$mesg,$mesg->sorted);
for my $url (@URL) {
$ldap = client(url => $url);
ok($ldap, "$url client");
$mesg = $ldap->search(base => $BASEDN, filter => 'objectclass=*');
ok(!$mesg->code, "search: " . $mesg->code . ": " . $mesg->error);
compare_ldif("50",$mesg,$mesg->sorted);
}
Index: common.pl
===================================================================
RCS file: /cvsroot/perl-ldap/ldap/t/common.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- common.pl 4 Feb 2002 18:59:04 -0000 1.5
+++ common.pl 8 May 2003 19:46:23 -0000 1.6
@@ -9,7 +9,7 @@
# If your host cannot be contacted as localhost, change this
$HOST ||= '127.0.0.1';
- # Where to but temporary files while testing
+ # Where to put temporary files while testing
# the Makefile is setup to delete temp/ when make clean is run
$TEMPDIR = "./temp";
@@ -21,6 +21,7 @@
$JAJDN = "cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US";
$BABSDN = "cn=Barbara Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US";
$PORT = 9009;
+ @URL = ();
my @server_opts;
($SERVER_TYPE,@server_opts) = split(/\+/, $SERVER_TYPE || 'none');
@@ -32,10 +33,13 @@
}
elsif ($SERVER_TYPE eq 'openldap2') {
$SSL_PORT = 9010 if grep { $_ eq 'ssl' } @server_opts;
+ ($IPC_SOCK = "$TEMPDIR/ldapi_sock") =~ s,/,%2f,g if grep { $_ eq 'ipc' } @server_opts;
+ $SASL = 1 if grep { $_ eq 'sasl' } @server_opts;
$CONF_IN = "./data/slapd2-conf.in";
- my $url = "ldap://${HOST}:$PORT/";
- $url .= " ldaps://${HOST}:$SSL_PORT/" if $SSL_PORT;
- @LDAPD = ($SERVER_EXE, '-f',$CONF,'-h',$url,qw(-d 1));
+ push @URL, "ldap://${HOST}:$PORT/";
+ push @URL, "ldaps://${HOST}:$SSL_PORT/" if $SSL_PORT;
+ push @URL, "ldapi://$IPC_SOCK/" if $IPC_SOCK;
+ @LDAPD = ($SERVER_EXE, '-f',$CONF,'-h', "@URL",qw(-d 1));
$LDAP_VERSION = 3;
}
@@ -56,9 +60,10 @@
unless ($LDAP_VERSION >= $arg{version}
and $LDAPD[0] and -x $LDAPD[0]
- and (!$arg{ssl} or $SSL_PORT))
+ and (!$arg{ssl} or $SSL_PORT)
+ and (!$arg{ipc} or $IPC_SOCK))
{
- print "1..0\n";
+ print "1..0 # Skip No server\n";
exit;
}
@@ -69,6 +74,7 @@
while(<CONFI>) {
s/\$(\w+)/${$1}/g;
s/^TLS/#TLS/ unless $SSL_PORT;
+ s/^(sasl.*)/#\1/ unless $SASL;
print CONFO;
}
close(CONFI);
@@ -79,6 +85,8 @@
mkdir($TESTDB,0777);
die "$TESTDB is not a directory" unless -d $TESTDB;
+ warn "@LDAPD" if $ENV{TEST_VERBOSE};
+
my $log = $TEMPDIR . "/" . basename($0,'.t');
unless ($pid = fork) {
@@ -118,6 +126,20 @@
sleep 1;
}
}
+ elsif ($arg{ipc}) {
+ require Net::LDAPI;
+ until($ldap = Net::LDAPI->new($IPC_SOCK)) {
+ die "ldapi://$IPC_SOCK/ $@" if ++$count > 10;
+ sleep 1;
+ }
+ }
+ elsif ($arg{url}) {
+ print "Trying $arg{url}\n";
+ until($ldap = Net::LDAP->new($arg{url})) {
+ die "$arg{url} $@" if ++$count > 10;
+ sleep 1;
+ }
+ }
else {
until($ldap = Net::LDAP->new($HOST, port => $PORT)) {
die "ldap://$HOST:$PORT/ $@" if ++$count > 10;
@@ -214,7 +236,5 @@
print "ok $number # skip $reason\n";
}
}
-
-1;
1;
|