3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2009 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>.
17 test $BACKEND = null && RCODE=0
19 echo "running defines.sh"
20 . $SRCDIR/scripts/defines.sh
22 mkdir -p $TESTDIR $DBDIR1
24 echo "Running slapadd to build slapd database..."
25 . $CONFFILTER $BACKEND $MONITORDB < $RCONF > $CONF1
26 $SLAPADD -f $CONF1 -l $LDIFREF
28 if test $RC != 0 ; then
29 echo "slapadd failed ($RC)!"
33 echo "Starting slapd on TCP/IP port $PORT1..."
34 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
36 if test $WAIT != 0 ; then
44 echo "Testing slapd searching..."
45 for i in 0 1 2 3 4 5; do
46 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
47 '(objectclass=*)' > /dev/null 2>&1
49 if test $RC = 0 ; then
52 echo "Waiting 5 seconds for slapd to start..."
56 if test $RC != 0 ; then
57 echo "ldapsearch failed ($RC)!"
58 test $KILLSERVERS != no && kill -HUP $KILLPIDS
62 cat /dev/null > $SEARCHOUT
64 echo "Testing ManageDsaIT searching at $REFDN..."
65 $LDAPRSEARCH -S "" -MM -b "$REFDN" -h $LOCALHOST -p $PORT1 \
66 '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
68 if test $RC != 0 ; then
69 echo "ldapsearch failed ($RC)!"
70 test $KILLSERVERS != no && kill -HUP $KILLPIDS
74 echo "Testing ManageDsaIT searching at referral object..."
75 $LDAPRSEARCH -S "" -MM -b "o=abc,$REFDN" -h $LOCALHOST -p $PORT1 \
76 '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
78 if test $RC != 0 ; then
79 echo "ldapsearch failed ($RC)!"
80 test $KILLSERVERS != no && kill -HUP $KILLPIDS
84 echo "Testing ManageDsaIT searching below referral object..."
85 $LDAPRSEARCH -S "" -MM -b "uid=xxx,o=abc,$REFDN" -h $LOCALHOST -p $PORT1 \
86 '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
88 if test $RC != $RCODE ; then
89 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
90 test $KILLSERVERS != no && kill -HUP $KILLPIDS
95 echo "Testing base searching at $XREFDN..."
96 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
98 if test $RC != 0 ; then
99 echo "ldapsearch failed ($RC)!"
100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
104 echo "Testing one-level searching at $XREFDN..."
105 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
107 if test $RC != 0 ; then
108 echo "ldapsearch failed ($RC)!"
109 test $KILLSERVERS != no && kill -HUP $KILLPIDS
113 echo "Testing subtree searching at $XREFDN..."
114 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
116 if test $RC != 0 ; then
117 echo "ldapsearch failed ($RC)!"
118 test $KILLSERVERS != no && kill -HUP $KILLPIDS
122 XREFDN="o=abc,$REFDN"
123 echo "Testing base searching at $XREFDN..."
124 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
126 if test $RC != $RCODE ; then
127 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
128 test $KILLSERVERS != no && kill -HUP $KILLPIDS
132 echo "Testing one-level searching at $XREFDN..."
133 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
135 if test $RC != $RCODE ; then
136 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
137 test $KILLSERVERS != no && kill -HUP $KILLPIDS
141 echo "Testing subtree searching at $XREFDN..."
142 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
144 if test $RC != $RCODE ; then
145 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
146 test $KILLSERVERS != no && kill -HUP $KILLPIDS
150 XREFDN="uid=xxx,o=abc,$REFDN"
151 echo "Testing base searching at $XREFDN..."
152 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
154 if test $RC != $RCODE ; then
155 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
156 test $KILLSERVERS != no && kill -HUP $KILLPIDS
160 echo "Testing one-level searching at $XREFDN..."
161 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
163 if test $RC != $RCODE ; then
164 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
165 test $KILLSERVERS != no && kill -HUP $KILLPIDS
169 echo "Testing subtree searching at $XREFDN..."
170 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
172 if test $RC != $RCODE ; then
173 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
174 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178 test $KILLSERVERS != no && kill -HUP $KILLPIDS
180 LDIF=$SEARCHOUTMASTER
181 echo "Filtering ldapsearch results..."
182 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
183 echo "Filtering expected LDIF for comparison..."
184 $LDIFFILTER < $REFERRALOUT > $LDIFFLT
185 echo "Comparing filter output..."
186 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
188 if test $? != 0 ; then
189 echo "Comparison failed"
193 echo ">>>>> Test succeeded"
195 test $KILLSERVERS != no && wait