3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2006 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>.
18 echo "running defines.sh"
19 . $SRCDIR/scripts/defines.sh
21 mkdir -p $TESTDIR $DBDIR1
23 echo "Running slapadd to build slapd database..."
24 . $CONFFILTER $BACKEND $MONITORDB < $RCONF > $CONF1
25 $SLAPADD -f $CONF1 -l $LDIFREF
27 if test $RC != 0 ; then
28 echo "slapadd failed ($RC)!"
32 echo "Starting slapd on TCP/IP port $PORT1..."
33 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
35 if test $WAIT != 0 ; then
43 echo "Testing slapd searching..."
44 for i in 0 1 2 3 4 5; do
45 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
46 '(objectclass=*)' > /dev/null 2>&1
48 if test $RC = 0 ; then
51 echo "Waiting 5 seconds for slapd to start..."
55 if test $RC != 0 ; then
56 echo "ldapsearch failed ($RC)!"
57 test $KILLSERVERS != no && kill -HUP $KILLPIDS
61 cat /dev/null > $SEARCHOUT
63 echo "Testing ManageDsaIT searching at $REFDN..."
64 $LDAPRSEARCH -S "" -MM -b "$REFDN" -h $LOCALHOST -p $PORT1 \
65 '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
67 if test $RC != 0 ; then
68 echo "ldapsearch failed ($RC)!"
69 test $KILLSERVERS != no && kill -HUP $KILLPIDS
73 echo "Testing ManageDsaIT searching at referral object..."
74 $LDAPRSEARCH -S "" -MM -b "o=abc,$REFDN" -h $LOCALHOST -p $PORT1 \
75 '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
77 if test $RC != 0 ; then
78 echo "ldapsearch failed ($RC)!"
79 test $KILLSERVERS != no && kill -HUP $KILLPIDS
83 echo "Testing ManageDsaIT searching below referral object..."
84 $LDAPRSEARCH -S "" -MM -b "uid=xxx,o=abc,$REFDN" -h $LOCALHOST -p $PORT1 \
85 '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
87 if test $RC != $RCODE ; then
88 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
89 test $KILLSERVERS != no && kill -HUP $KILLPIDS
94 echo "Testing base searching at $XREFDN..."
95 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
97 if test $RC != 0 ; then
98 echo "ldapsearch failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 echo "Testing one-level searching at $XREFDN..."
104 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
106 if test $RC != 0 ; then
107 echo "ldapsearch failed ($RC)!"
108 test $KILLSERVERS != no && kill -HUP $KILLPIDS
112 echo "Testing subtree searching at $XREFDN..."
113 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
115 if test $RC != 0 ; then
116 echo "ldapsearch failed ($RC)!"
117 test $KILLSERVERS != no && kill -HUP $KILLPIDS
121 XREFDN="o=abc,$REFDN"
122 echo "Testing base searching at $XREFDN..."
123 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
125 if test $RC != $RCODE ; then
126 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
127 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 echo "Testing one-level searching at $XREFDN..."
132 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
134 if test $RC != $RCODE ; then
135 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
136 test $KILLSERVERS != no && kill -HUP $KILLPIDS
140 echo "Testing subtree searching at $XREFDN..."
141 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
143 if test $RC != $RCODE ; then
144 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
145 test $KILLSERVERS != no && kill -HUP $KILLPIDS
149 XREFDN="uid=xxx,o=abc,$REFDN"
150 echo "Testing base searching at $XREFDN..."
151 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
153 if test $RC != $RCODE ; then
154 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
159 echo "Testing one-level searching at $XREFDN..."
160 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
162 if test $RC != $RCODE ; then
163 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
164 test $KILLSERVERS != no && kill -HUP $KILLPIDS
168 echo "Testing subtree searching at $XREFDN..."
169 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
171 if test $RC != $RCODE ; then
172 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
173 test $KILLSERVERS != no && kill -HUP $KILLPIDS
177 test $KILLSERVERS != no && kill -HUP $KILLPIDS
179 LDIF=$SEARCHOUTMASTER
180 echo "Filtering ldapsearch results..."
181 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
182 echo "Filtering expected LDIF for comparison..."
183 . $LDIFFILTER < $REFERRALOUT > $LDIFFLT
184 echo "Comparing filter output..."
185 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
187 if test $? != 0 ; then
188 echo "Comparison failed"
192 echo ">>>>> Test succeeded"
194 test $KILLSERVERS != no && wait