Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / openldap / dist / tests / scripts / test009-referral
blob16021df5b52c153f07ec1d51095f0675e0e8e615
1 #! /bin/sh
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/>.
4 ##
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
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
28 RC=$?
29 if test $RC != 0 ; then
30 echo "slapadd failed ($RC)!"
31 exit $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 &
36 PID=$!
37 if test $WAIT != 0 ; then
38 echo PID $PID
39 read foo
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 &
45 SLAVEPID=$!
46 if test $WAIT != 0 ; then
47 echo SLAVEPID $SLAVEPID
48 read foo
51 KILLPIDS="$PID $SLAVEPID"
53 sleep 1
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
59 RC=$?
60 if test $RC = 0 ; then
61 break
63 echo "Waiting 5 seconds for master slapd to start..."
64 sleep 5
65 done
67 if test $RC != 0 ; then
68 echo "ldapsearch failed ($RC)!"
69 test $KILLSERVERS != no && kill -HUP $KILLPIDS
70 exit $RC
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
77 RC=$?
78 if test $RC = 0 ; then
79 break
81 echo "Waiting 5 seconds for slave slapd to start..."
82 sleep 5
83 done
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
90 RC=$?
91 if test $RC != 0 ; then
92 echo "ldapsearch failed ($RC)!"
93 test $KILLSERVERS != no && kill -HUP $KILLPIDS
94 exit $RC
97 echo "Testing approximate searching..."
98 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
99 '(sn=jENSEN)' name >> $SEARCHOUT 2>&1
100 RC=$?
101 if test $RC != 0 ; then
102 echo "ldapsearch failed ($RC)!"
103 test $KILLSERVERS != no && kill -HUP $KILLPIDS
104 exit $RC
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
110 RC=$?
111 if test $RC != 0 ; then
112 echo "ldapsearch failed ($RC)!"
113 test $KILLSERVERS != no && kill -HUP $KILLPIDS
114 exit $RC
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
120 RC=$?
121 if test $RC != 0 ; then
122 echo "ldapsearch failed ($RC)!"
123 test $KILLSERVERS != no && kill -HUP $KILLPIDS
124 exit $RC
127 echo "Testing NOT searching..."
128 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
129 '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
130 RC=$?
131 if test $RC != 0 ; then
132 echo "ldapsearch failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
134 exit $RC
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
141 RC=$?
142 if test $RC != 0 ; then
143 echo "ldapsearch failed ($RC)!"
144 test $KILLSERVERS != no && kill -HUP $KILLPIDS
145 exit $RC
148 echo "Testing dontUseCopy control..."
149 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
150 -E \!dontUseCopy \
151 'sn=jensen' >> $SEARCHOUT
152 RC=$?
153 if test $RC = 10 ; then
154 echo "ldapsearch failed as expected ($RC)"
155 else
156 echo "ldapsearch did not error as expected ($RC)!"
157 test $KILLSERVERS != no && kill -HUP $KILLPIDS
158 exit $RC
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"
174 exit 1
177 echo ">>>>> Test succeeded"
179 test $KILLSERVERS != no && wait
181 exit 0