2 # $OpenLDAP: pkg/ldap/tests/scripts/test009-referral,v 1.38.2.4 2008/02/11 23:26:51 kurt Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 echo "running defines.sh"
17 .
$SRCDIR/scripts
/defines.sh
20 # Test default referral
23 mkdir
-p $TESTDIR $DBDIR1 $DBDIR2
25 echo "Running slapadd to build slapd database..."
26 .
$CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
27 $SLAPADD -f $CONF1 -l $LDIFORDERED
29 if test $RC != 0 ; then
30 echo "slapadd failed ($RC)!"
34 echo "Starting master slapd on TCP/IP port $PORT1..."
35 $SLAPD -n master
-f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
37 if test $WAIT != 0 ; then
42 echo "Starting slave slapd on TCP/IP port $PORT2..."
43 .
$CONFFILTER $BACKEND $MONITORDB < $REFSLAVECONF > $CONF2
44 $SLAPD -n slave
-f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
46 if test $WAIT != 0 ; then
47 echo SLAVEPID
$SLAVEPID
51 KILLPIDS
="$PID $SLAVEPID"
55 echo "Testing for master slapd..."
56 for i
in 0 1 2 3 4 5; do
57 $LDAPSEARCH -s base
-b "$MONITOR" -h $LOCALHOST -p $PORT1 \
58 'objectclass=*' > /dev
/null
2>&1
60 if test $RC = 0 ; then
63 echo "Waiting 5 seconds for master slapd to start..."
67 if test $RC != 0 ; then
68 echo "ldapsearch failed ($RC)!"
69 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
73 echo "Testing for slave slapd..."
74 for i
in 0 1 2 3 4 5; do
75 $LDAPSEARCH -s base
-b "$MONITOR" -h $LOCALHOST -p $PORT2 \
76 'objectclass=*' > /dev
/null
2>&1
78 if test $RC = 0 ; then
81 echo "Waiting 5 seconds for slave slapd to start..."
85 cat /dev
/null
> $SEARCHOUT
87 echo "Testing exact searching..."
88 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
89 'sn=jensen' >> $SEARCHOUT 2>&1
91 if test $RC != 0 ; then
92 echo "ldapsearch failed ($RC)!"
93 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
97 echo "Testing approximate searching..."
98 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
99 '(sn=jENSEN)' name
>> $SEARCHOUT 2>&1
101 if test $RC != 0 ; then
102 echo "ldapsearch failed ($RC)!"
103 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
107 echo "Testing OR searching..."
108 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
109 '(|(objectclass=groupofnames)(objectClass=groupofuniquenames)(sn=jones))' >> $SEARCHOUT 2>&1
111 if test $RC != 0 ; then
112 echo "ldapsearch failed ($RC)!"
113 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
117 echo "Testing AND matching and ends-with searching..."
118 $LDAPSEARCH -C -S "" -b "ou=groups,$BASEDN" -s one
-h $LOCALHOST -p $PORT2 \
119 '(&(objectclass=groupofnames)(cn=A*))' >> $SEARCHOUT 2>&1
121 if test $RC != 0 ; then
122 echo "ldapsearch failed ($RC)!"
123 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
127 echo "Testing NOT searching..."
128 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
129 '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
131 if test $RC != 0 ; then
132 echo "ldapsearch failed ($RC)!"
133 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
137 echo "Testing objectClass/attributeType inheritance ..."
138 $LDAPSEARCH -M -a never
-S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
139 '(&(objectClass=inetorgperson)(userid=uham))' \
140 "2.5.4.0" "userid" >> $SEARCHOUT 2>&1
142 if test $RC != 0 ; then
143 echo "ldapsearch failed ($RC)!"
144 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
148 echo "Testing dontUseCopy control..."
149 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
151 'sn=jensen' >> $SEARCHOUT
153 if test $RC = 10 ; then
154 echo "ldapsearch failed as expected ($RC)"
156 echo "ldapsearch did not error as expected ($RC)!"
157 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
161 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
163 LDIF
=$SEARCHOUTMASTER
165 echo "Filtering ldapsearch results..."
166 .
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
167 echo "Filtering original ldif used to create database..."
168 .
$LDIFFILTER < $LDIF > $LDIFFLT
169 echo "Comparing filter output..."
170 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
172 if test $?
!= 0 ; then
173 echo "Comparison failed"
177 echo ">>>>> Test succeeded"
179 test $KILLSERVERS != no
&& wait