3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2007 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 cat /dev/null > $SEARCHOUT
66 BASEDN="dc=example,dc=com"
68 echo "Using ldapsearch to retrieve all the entries..."
69 echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
70 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
71 "objectClass=*" >> $SEARCHOUT 2>&1
74 if test $RC != 0 ; then
75 echo "ldapsearch failed ($RC)!"
76 test $KILLSERVERS != no && kill -HUP $KILLPIDS
81 # list here the RDBMSes whose mapping allows writes
83 MANAGERDN="cn=Manager,${BASEDN}"
85 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
86 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
89 # Adding an organization...
90 dn: o=An Org,${BASEDN}
92 objectClass: organization
95 # Adding an organization with an "auxiliary" objectClass..
96 dn: dc=subnet,${BASEDN}
98 objectClass: organization
103 # Adding another organization with an "auxiliary" objectClass..
104 dn: dc=subnet2,${BASEDN}
106 objectClass: organization
107 objectClass: dcObject
112 dn: cn=Lev Tolstoij,${BASEDN}
114 objectClass: inetOrgPerson
118 telephoneNumber: +39 02 XXXX YYYY
119 telephoneNumber: +39 02 XXXX ZZZZ
122 # Adding a person with an "auxiliary" objectClass...
123 dn: cn=Some One,${BASEDN}
125 objectClass: inetOrgPerson
126 objectClass: simpleSecurityObject
130 telephoneNumber: +1 800 900 1234
131 telephoneNumber: +1 800 900 1235
132 userPassword: someone
134 # Adding a person in another subtree...
135 dn: cn=SubNet User,dc=subnet,${BASEDN}
137 objectClass: inetOrgPerson
142 # Adding a document...
143 dn: documentTitle=War and Peace,${BASEDN}
145 objectClass: document
146 description: Historical novel
147 documentTitle: War and Peace
148 documentAuthor: cn=Lev Tolstoij,dc=example,dc=com
149 documentIdentifier: document 3
153 if test $RC != 0 ; then
154 echo "ldapmodify failed ($RC)!"
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
159 echo "Using ldapsearch to retrieve all the entries..."
160 echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
161 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
162 "objectClass=*" >> $SEARCHOUT 2>&1
165 if test $RC != 0 ; then
166 echo "ldapsearch failed ($RC)!"
167 test $KILLSERVERS != no && kill -HUP $KILLPIDS
171 echo "Testing modify..."
172 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
173 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
176 # Deleting all telephone numbers...
177 dn: cn=Some One,${BASEDN}
179 delete: telephoneNumber
182 # Adding a telephone number...
183 dn: cn=Mitya Kovalev,${BASEDN}
186 telephoneNumber: +1 800 123 4567
189 # Deleting a specific telephone number and adding a new one...
190 dn: cn=Lev Tolstoij,${BASEDN}
192 delete: telephoneNumber
193 telephoneNumber: +39 02 XXXX YYYY
196 telephoneNumber: +39 333 ZZZ 1234
199 # Adding an author to a document...
200 dn: documentTitle=book1,${BASEDN}
203 documentAuthor: cn=Lev Tolstoij,${BASEDN}
206 # Adding an author to another document...
207 dn: documentTitle=book2,${BASEDN}
210 documentAuthor: cn=Lev Tolstoij,${BASEDN}
213 # Adding an "auxiliary" objectClass...
214 dn: cn=Mitya Kovalev,${BASEDN}
217 objectClass: simpleSecurityObject
220 # Deleting an "auxiliary" objectClass...
221 dn: cn=Some One,${BASEDN}
224 objectClass: simpleSecurityObject
227 # Deleting userPasswords
228 dn: cn=Lev Tolstoij,${BASEDN}
235 if test $RC != 0 ; then
236 echo "ldapmodify failed ($RC)!"
237 test $KILLSERVERS != no && kill -HUP $KILLPIDS
241 echo "Using ldapsearch to retrieve all the entries..."
242 echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
243 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
244 "objectClass=*" >> $SEARCHOUT 2>&1
247 if test $RC != 0 ; then
248 echo "ldapsearch failed ($RC)!"
249 test $KILLSERVERS != no && kill -HUP $KILLPIDS
253 echo "Testing delete..."
254 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
255 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
258 # Deleting a person...
259 dn: cn=Torvlobnor Puzdoy,${BASEDN}
262 # Deleting a document...
263 dn: documentTitle=book1,${BASEDN}
266 # Deleting an organization with an "auxiliary" objectClass...
267 dn: dc=subnet2,${BASEDN}
272 if test $RC != 0 ; then
273 echo "ldapmodify failed ($RC)!"
274 test $KILLSERVERS != no && kill -HUP $KILLPIDS
278 echo "Using ldapsearch to retrieve all the entries..."
279 echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
280 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
281 "objectClass=*" >> $SEARCHOUT 2>&1
284 if test $RC != 0 ; then
285 echo "ldapsearch failed ($RC)!"
286 test $KILLSERVERS != no && kill -HUP $KILLPIDS
290 echo "Testing rename..."
291 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
292 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
295 # Renaming an organization...
296 dn: o=An Org,${BASEDN}
298 newrdn: o=Renamed Org
301 # Moving a person to another subtree...
302 dn: cn=Lev Tolstoij,${BASEDN}
304 newrdn: cn=Lev Tolstoij
306 newsuperior: dc=subnet,${BASEDN}
309 dn: documentTitle=book2,${BASEDN}
311 newrdn: documentTitle=Renamed Book
316 if test $RC != 0 ; then
317 echo "ldapmodify failed ($RC)!"
318 test $KILLSERVERS != no && kill -HUP $KILLPIDS
322 echo "Using ldapsearch to retrieve all the entries..."
323 echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
324 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
325 "objectClass=*" >> $SEARCHOUT 2>&1
328 if test $RC != 0 ; then
329 echo "ldapsearch failed ($RC)!"
330 test $KILLSERVERS != no && kill -HUP $KILLPIDS
334 echo "Adding a child to a referral (should fail)..."
335 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
336 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
339 dn: cn=Should Fail,ou=Referral,${BASEDN}
341 objectClass: inetOrgPerson
344 telephoneNumber: +39 02 23456789
348 if test $RC = 0 ; then
349 echo "ldapmodify should have failed ($RC)!"
350 test $KILLSERVERS != no && kill -HUP $KILLPIDS
354 echo "Modifying a referral (should fail)..."
355 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
356 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
359 dn: ou=Referral,${BASEDN}
362 ref: ldap://localhost:9009/
367 if test $RC = 0 ; then
368 echo "ldapmodify should have failed ($RC)!"
369 test $KILLSERVERS != no && kill -HUP $KILLPIDS
373 echo "Renaming a referral (should fail)..."
374 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
375 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
378 dn: ou=Referral,${BASEDN}
380 newrdn: ou=Renamed Referral
385 if test $RC = 0 ; then
386 echo "ldapmodify should have failed ($RC)!"
387 test $KILLSERVERS != no && kill -HUP $KILLPIDS
391 echo "Deleting a referral (should fail)..."
392 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
393 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
396 dn: ou=Referral,${BASEDN}
401 if test $RC = 0 ; then
402 echo "ldapmodify should have failed ($RC)!"
403 test $KILLSERVERS != no && kill -HUP $KILLPIDS
407 echo "Adding a referral..."
408 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
409 -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
412 dn: ou=Another Referral,${BASEDN}
414 objectClass: referral
415 objectClass: extensibleObject
417 ref: ldap://localhost:9009/
421 if test $RC != 0 ; then
422 echo "ldapmodify failed ($RC)!"
423 test $KILLSERVERS != no && kill -HUP $KILLPIDS
427 echo "Modifying a referral with manageDSAit..."
428 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
429 -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
432 dn: ou=Referral,${BASEDN}
435 ref: ldap://localhost:9009/
440 if test $RC != 0 ; then
441 echo "ldapmodify failed ($RC)!"
442 test $KILLSERVERS != no && kill -HUP $KILLPIDS
446 echo "Using ldapsearch to retrieve the modified entry..."
447 echo "# Using ldapsearch to retrieve the modified entry..." >> $SEARCHOUT
448 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "ou=Referral,$BASEDN" -M \
449 "objectClass=*" '*' ref >> $SEARCHOUT 2>&1
452 if test $RC != 0 ; then
453 echo "ldapsearch failed ($RC)!"
454 test $KILLSERVERS != no && kill -HUP $KILLPIDS
458 echo "Renaming a referral with manageDSAit..."
459 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
460 -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
463 dn: ou=Referral,${BASEDN}
465 newrdn: ou=Renamed Referral
470 if test $RC != 0 ; then
471 echo "ldapmodify failed ($RC)!"
472 test $KILLSERVERS != no && kill -HUP $KILLPIDS
476 echo "Using ldapsearch to retrieve the renamed entry..."
477 echo "# Using ldapsearch to retrieve the renamed entry..." >> $SEARCHOUT
478 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "ou=Renamed Referral,$BASEDN" -M \
479 "objectClass=*" '*' ref >> $SEARCHOUT 2>&1
482 if test $RC != 0 ; then
483 echo "ldapsearch failed ($RC)!"
484 test $KILLSERVERS != no && kill -HUP $KILLPIDS
488 echo "Deleting a referral with manageDSAit..."
489 $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
490 -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
493 dn: ou=Renamed Referral,${BASEDN}
498 if test $RC != 0 ; then
499 echo "ldapmodify failed ($RC)!"
500 test $KILLSERVERS != no && kill -HUP $KILLPIDS
504 BINDDN="cn=Mitya Kovalev,${BASEDN}"
507 echo "Testing passwd change..."
508 $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
509 -D "${BINDDN}" -w ${BINDPW} -s ${NEWPW} \
510 "$BINDDN" >> $TESTOUT 2>&1
513 if test $RC != 0 ; then
514 echo "ldappasswd failed ($RC)!"
515 test $KILLSERVERS != no && kill -HUP $KILLPIDS
519 echo -n "Testing bind with new secret... "
520 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $NEWPW
522 if test $RC != 0 ; then
523 echo "ldapwhoami failed ($RC)!"
524 test $KILLSERVERS != no && kill -HUP $KILLPIDS
528 BINDDN="cn=Some One,${BASEDN}"
530 echo -n "Testing bind with newly added user... "
531 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $BINDPW
533 if test $RC != 0 ; then
534 echo "ldapwhoami failed ($RC)!"
535 test $KILLSERVERS != no && kill -HUP $KILLPIDS
539 echo "Using ldapsearch to retrieve all the entries..."
540 echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
541 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
542 "objectClass=*" >> $SEARCHOUT 2>&1
545 if test $RC != 0 ; then
546 echo "ldapsearch failed ($RC)!"
547 test $KILLSERVERS != no && kill -HUP $KILLPIDS
551 echo "Filtering ldapsearch results..."
552 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
553 echo "Filtering modified ldif..."
554 . $LDIFFILTER < $SQLWRITE > $LDIFFLT
555 echo "Comparing filter output..."
556 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
558 if test $? != 0 ; then
559 echo "comparison failed - SQL mods search didn't succeed"
560 test $KILLSERVERS != no && kill -HUP $KILLPIDS
566 echo "apparently ${RDBMS} does not support writes; skipping..."
570 test $KILLSERVERS != no && kill -HUP $KILLPIDS
572 echo ">>>>> Test succeeded"