3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2005 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
19 mkdir -p $TESTDIR $DBDIR1
21 echo "Running slapadd to build slapd database..."
22 . $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF
23 $SLAPADD -f $ADDCONF -l $LDIFORDERED
25 if test $RC != 0 ; then
26 echo "slapadd failed ($RC)!"
30 echo "Running slapindex to index slapd database..."
31 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
34 if test $RC != 0 ; then
35 echo "warning: slapindex failed ($RC)"
36 echo " assuming no indexing support"
39 echo "Starting slapd on TCP/IP port $PORT1..."
40 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
42 if test $WAIT != 0 ; then
50 echo "Testing slapd searching..."
51 for i in 0 1 2 3 4 5; do
52 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
53 'objectclass=*' > /dev/null 2>&1
55 if test $RC = 0 ; then
58 echo "Waiting 5 seconds for slapd to start..."
62 if test $RC != 0 ; then
63 echo "ldapsearch failed ($RC)!"
64 test $KILLSERVERS != no && kill -HUP $KILLPIDS
68 cat /dev/null > $SEARCHOUT
70 echo "Testing exact searching..."
71 echo "# Testing exact searching..." >> $SEARCHOUT
72 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
73 '(sn:=jensen)' >> $SEARCHOUT 2>&1
75 if test $RC != 0 ; then
76 echo "ldapsearch failed ($RC)!"
77 test $KILLSERVERS != no && kill -HUP $KILLPIDS
81 echo "Testing approximate searching..."
82 echo "# Testing approximate searching..." >> $SEARCHOUT
83 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
84 '(sn~=jensen)' name >> $SEARCHOUT 2>&1
86 if test $RC != 0 ; then
87 echo "ldapsearch failed ($RC)!"
88 test $KILLSERVERS != no && kill -HUP $KILLPIDS
92 echo "Testing OR searching..."
93 echo "# Testing OR searching..." >> $SEARCHOUT
94 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
95 '(|(givenName=XX*YY*Z)(cn=)(undef=*)(objectclass=groupofnames)(objectclass=groupofuniquenames)(sn:caseExactMatch:=Jones))' >> $SEARCHOUT 2>&1
97 if test $RC != 0 ; then
98 echo "ldapsearch failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 echo "Testing AND matching and ends-with searching..."
104 echo "# Testing AND matching and ends-with searching..." >> $SEARCHOUT
105 $LDAPSEARCH -S "" -b "ou=groups,$BASEDN" -s one -h $LOCALHOST -p $PORT1 \
106 '(&(|(objectclass=groupofnames)(objectclass=groupofuniquenames))(cn=A*))' >> $SEARCHOUT 2>&1
108 if test $RC != 0 ; then
109 echo "ldapsearch failed ($RC)!"
110 test $KILLSERVERS != no && kill -HUP $KILLPIDS
114 echo "Testing NOT searching..."
115 echo "# Testing NOT searching..." >> $SEARCHOUT
116 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
117 '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
119 if test $RC != 0 ; then
120 echo "ldapsearch failed ($RC)!"
121 test $KILLSERVERS != no && kill -HUP $KILLPIDS
125 echo "Testing objectClass/attributeType inheritance ..."
126 echo "# Testing objectClass/attributeType inheritance ..." >> $SEARCHOUT
127 $LDAPSEARCH -M -a never -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
128 '(&(objectClass=inetorgperson)(userid=uham))' \
129 "2.5.4.0" "userid" >> $SEARCHOUT 2>&1
131 if test $RC != 0 ; then
132 echo "ldapsearch failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 echo "Testing extended RFC2254 searching:"
138 echo "# Testing extended RFC2254 searching:" >> $SEARCHOUT
140 FILTER="(:dn:caseIgnoreIA5Match:=example)"
141 echo " f=$FILTER ..."
142 echo "# f=$FILTER ..." >> $SEARCHOUT
143 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
144 "$FILTER" >> $SEARCHOUT 2>&1
147 if test $RC != 0 ; then
148 echo "ldapsearch failed ($RC)!"
149 test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 FILTER="(:dn:caseExactMatch:=Information Technology Division)"
154 echo " f=$FILTER ..."
155 echo "# f=$FILTER ..." >> $SEARCHOUT
156 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
157 "$FILTER" >> $SEARCHOUT 2>&1
160 if test $RC != 0 ; then
161 echo "ldapsearch failed ($RC)!"
162 test $KILLSERVERS != no && kill -HUP $KILLPIDS
166 FILTER="(name:dn:=whatever)"
167 echo " f=$FILTER ..."
168 echo "# f=$FILTER ..." >> $SEARCHOUT
169 $LDAPSEARCH -S "" -b "" -s base -h $LOCALHOST -p $PORT1 \
170 "$FILTER" >> $SEARCHOUT 2>&1
173 if test $RC != 0 ; then
174 echo "ldapsearch failed ($RC)!"
175 test $KILLSERVERS != no && kill -HUP $KILLPIDS
179 echo "Testing values return filter searching:"
180 echo "# Testing values return filter searching:" >> $SEARCHOUT
182 FILTER="(o=Example, Inc.)"
183 echo " f=$FILTER ..."
184 echo "# f=$FILTER ..." >> $SEARCHOUT
185 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
186 -E '!mv='"$FILTER" "$FILTER" >> $SEARCHOUT 2>&1
188 if test $RC != 0 ; then
189 echo "ldapsearch failed ($RC)!"
190 test $KILLSERVERS != no && kill -HUP $KILLPIDS
194 FILTER="(dc=example)"
195 VRFILTER="((o:caseExactMatch:=Example, Inc.)(dc=example))"
196 echo " f=$FILTER mv=$VRFILTER ..."
197 echo "# f=$FILTER mv=$VRFILTER ..." >> $SEARCHOUT
198 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
199 -E '!mv='"$VRFILTER" "$FILTER" >> $SEARCHOUT 2>&1
201 if test $RC != 0 ; then
202 echo "ldapsearch failed ($RC)!"
203 test $KILLSERVERS != no && kill -HUP $KILLPIDS
207 FILTER="(attributeTypes=0.9.2342.19200300.100.1.25)"
208 echo " f=$FILTER ..."
209 echo "# f=$FILTER ..." >> $SEARCHOUT
210 $LDAPSEARCH -S "" -b "cn=Subschema" -s "base" -h $LOCALHOST -p $PORT1 \
211 -E '!mv='"$FILTER" "$FILTER" "attributeTypes" >> $SEARCHOUT 2>&1
213 if test $RC != 0 ; then
214 echo "ldapsearch failed ($RC)!"
215 test $KILLSERVERS != no && kill -HUP $KILLPIDS
219 test $KILLSERVERS != no && kill -HUP $KILLPIDS
221 LDIF=$SEARCHOUTMASTER
224 echo "Filtering ldapsearch results..."
225 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
226 echo "Filtering original ldif used to create database..."
227 . $LDIFFILTER < $LDIF > $LDIFFLT
228 . $LDIFFILTER < $LDIF2 >> $LDIFFLT
229 echo "Comparing filter output..."
230 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
232 if test $? != 0 ; then
233 echo "Comparison failed"
237 echo ">>>>> Test succeeded"