3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2004 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 if test $BACKSQL = "sqlno" ; then
20 echo "SQL backend not available, test skipped"
24 if test $RDBMS = "rdbmsno" ; then
25 echo "SQL test not requested, test skipped"
29 if test "${RDBMSWRITE}" != "yes"; then
30 echo "write test disabled for ${RDBMS}; set SLAPD_USE_SQLWRITE=yes to enable"
36 echo "Starting slapd on TCP/IP port $PORT1..."
37 . $CONFFILTER $BACKEND $MONITORDB < $SQLCONF > $CONF1
38 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
40 if test $WAIT != 0 ; then
46 echo "Testing SQL backend write operations..."
47 for i in 0 1 2 3 4 5; do
48 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
49 'objectclass=*' > /dev/null 2>&1
51 if test $RC = 0 ; then
54 echo "Waiting 5 seconds for slapd to start..."
58 if test $RC != 0 ; then
59 echo "ldapsearch failed ($RC)!"
60 test $KILLSERVERS != no && kill -HUP $KILLPIDS
64 BASEDN="dc=example,dc=com"
66 # list here the RDBMSes whose mapping allows writes
68 MANAGERDN="cn=Manager,${BASEDN}"
70 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
71 -h $LOCALHOST -p $PORT1 > \
72 $TESTOUT 2>&1 << EOMODS
75 # Adding an organization...
76 dn: o=An Org,${BASEDN}
78 objectClass: organization
81 # Adding an organization with an "auxiliary" objectClass..
82 dn: dc=subnet,${BASEDN}
84 objectClass: organization
90 dn: cn=Lev Tolstoij,${BASEDN}
92 objectClass: inetOrgPerson
96 telephoneNumber: +39 02 XXXX YYYY
97 telephoneNumber: +39 02 XXXX ZZZZ
99 # Adding a person with an "auxiliary" objectClass...
100 dn: cn=Some One,${BASEDN}
102 objectClass: inetOrgPerson
103 objectClass: simpleSecurityObject
107 telephoneNumber: +1 800 900 1234
108 telephoneNumber: +1 800 900 1235
109 userPassword: someone
111 # Adding a person in another subtree...
112 dn: cn=SubNet User,dc=subnet,${BASEDN}
114 objectClass: inetOrgPerson
119 # Adding a document...
120 dn: documentTitle=War and Peace,${BASEDN}
122 objectClass: document
123 description: Historical novel
124 documentTitle: War and Peace
125 documentAuthor: cn=Lev Tolstoij,dc=example,dc=com
126 documentIdentifier: document 3
131 if test $RC != 0 ; then
132 echo "ldapmodify failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 echo "Testing modify..."
138 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
139 -h $LOCALHOST -p $PORT1 > \
140 $TESTOUT 2>&1 << EOMODS
143 # Deleting all telephone numbers...
144 dn: cn=Some One,${BASEDN}
146 delete: telephoneNumber
149 # Adding a telephone number...
150 dn: cn=Mitya Kovalev,${BASEDN}
153 telephoneNumber: +1 800 123 4567
156 # Deleting a specific telephone number and adding a new one...
157 dn: cn=Lev Tolstoij,${BASEDN}
159 delete: telephoneNumber
160 telephoneNumber: +39 02 XXXX YYYY
163 telephoneNumber: +39 333 ZZZ 1234
166 # Adding an author to a document...
167 dn: documentTitle=book1,${BASEDN}
170 documentAuthor: cn=Lev Tolstoij,${BASEDN}
173 # Adding an author to another document...
174 dn: documentTitle=book2,${BASEDN}
177 documentAuthor: cn=Lev Tolstoij,${BASEDN}
180 # Adding an "auxiliary" objectClass...
181 dn: cn=Mitya Kovalev,${BASEDN}
184 objectClass: simpleSecurityObject
187 # Deleting an "auxiliary" objectClass...
188 dn: cn=Some One,${BASEDN}
191 objectClass: simpleSecurityObject
199 if test $RC != 0 ; then
200 echo "ldapmodify failed ($RC)!"
201 test $KILLSERVERS != no && kill -HUP $KILLPIDS
205 echo "Testing delete..."
206 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
207 -h $LOCALHOST -p $PORT1 > \
208 $TESTOUT 2>&1 << EOMODS
211 # Deleting a person...
212 dn: cn=Torvlobnor Puzdoy,${BASEDN}
215 # Deleting a document...
216 dn: documentTitle=book1,dc=example,dc=com
219 # Deleting a person with an "auxiliary" objectClass...
220 dn: cn=Akakiy Zinberstein,dc=example,dc=com
226 if test $RC != 0 ; then
227 echo "ldapmodify failed ($RC)!"
228 test $KILLSERVERS != no && kill -HUP $KILLPIDS
232 echo "Testing rename..."
233 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
234 -h $LOCALHOST -p $PORT1 > \
235 $TESTOUT 2>&1 << EOMODS
238 # Renaming an organization
239 dn: o=An Org,${BASEDN}
241 newrdn: o=Another Org
247 if test $RC != 0 ; then
248 echo "ldapmodify failed ($RC)!"
249 test $KILLSERVERS != no && kill -HUP $KILLPIDS
253 BINDDN="cn=Mitya Kovalev,${BASEDN}"
256 echo "Testing passwd change..."
257 $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
258 -D "${BINDDN}" -w ${BINDPW} -s ${NEWPW} \
259 "$BINDDN" >> $TESTOUT 2>&1
262 if test $RC != 0 ; then
263 echo "ldappasswd failed ($RC)!"
264 test $KILLSERVERS != no && kill -HUP $KILLPIDS
268 echo -n "Testing bind with new secret... "
269 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $NEWPW
271 if test $RC != 0 ; then
272 echo "ldapwhoami failed ($RC)!"
273 test $KILLSERVERS != no && kill -HUP $KILLPIDS
277 BINDDN="cn=Some One,${BASEDN}"
279 echo -n "Testing bind with newly added user... "
280 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $BINDPW
282 if test $RC != 0 ; then
283 echo "ldapwhoami failed ($RC)!"
284 test $KILLSERVERS != no && kill -HUP $KILLPIDS
288 echo "Using ldapsearch to retrieve all the entries..."
289 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
290 "objectClass=*" > $SEARCHOUT 2>&1
293 if test $RC != 0 ; then
294 echo "ldapsearch failed ($RC)!"
295 test $KILLSERVERS != no && kill -HUP $KILLPIDS
299 echo "Filtering ldapsearch results..."
300 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
301 echo "Filtering modified ldif..."
302 . $LDIFFILTER < $SQLWRITE > $LDIFFLT
303 echo "Comparing filter output..."
304 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
306 if test $? != 0 ; then
307 echo "comparison failed - SQL mods search didn't succeed"
308 test $KILLSERVERS != no && kill -HUP $KILLPIDS
314 echo "apparently ${RDBMS} does not support writes; skipping..."
318 test $KILLSERVERS != no && kill -HUP $KILLPIDS
320 echo ">>>>> Test succeeded"