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>.
20 echo "Test does not support $BACKEND backend"
24 echo "running defines.sh"
25 . $SRCDIR/scripts/defines.sh
27 mkdir -p $TESTDIR $DBDIR1
29 echo "Running slapadd to build slapd database..."
30 . $CONFFILTER $BACKEND $MONITORDB < $ACLCONF > $CONF1
31 $SLAPADD -f $CONF1 -l $LDIFORDERED
33 if test $RC != 0 ; then
34 echo "slapadd failed ($RC)!"
38 echo "Starting slapd on TCP/IP port $PORT1..."
39 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
41 if test $WAIT != 0 ; then
49 echo "Testing slapd access control..."
50 for i in 0 1 2 3 4 5; do
51 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
52 'objectclass=*' > /dev/null 2>&1
54 if test $RC = 0 ; then
57 echo "Waiting 5 seconds for slapd to start..."
61 if test $RC != 0 ; then
62 echo "ldapsearch failed ($RC)!"
63 test $KILLSERVERS != no && kill -HUP $KILLPIDS
67 cat /dev/null > $SEARCHOUT
69 echo "# Try to read an entry inside the Alumni Association container.
70 # It should give us noSuchObject if we're not bound..." \
72 # FIXME: temporarily remove the "No such object" message to make
73 # the test succeed even if SLAP_ACL_HONOR_DISCLOSE is not #define'd
74 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 "(objectclass=*)" \
75 2>&1 | grep -v "^No such object" >> $SEARCHOUT
77 echo "# ... and should return all attributes if we're bound as anyone
80 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 \
81 -D "$BABSDN" -w bjensen "(objectclass=*)" >> $SEARCHOUT 2>&1
84 echo "# Checking exact/regex attrval clause" >> $SEARCHOUT
85 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
86 -D "$BABSDN" -w bjensen \
87 -b "$MELLIOTDN" -s base "(objectclass=*)" cn >> $SEARCHOUT 2>&1
88 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
89 -D "$BJORNSDN" -w bjorn \
90 -b "$MELLIOTDN" -s base "(objectclass=*)" cn >> $SEARCHOUT 2>&1
92 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
93 -D "$BABSDN" -w bjensen \
94 -b "$JOHNDDN" -s base "(objectclass=*)" cn >> $SEARCHOUT 2>&1
95 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
96 -D "$BJORNSDN" -w bjorn \
97 -b "$JOHNDDN" -s base "(objectclass=*)" cn >> $SEARCHOUT 2>&1
99 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
100 -D "$BABSDN" -w bjensen \
101 -b "$BJORNSDN" -s base "(objectclass=*)" cn >> $SEARCHOUT 2>&1
102 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
103 -D "$BJORNSDN" -w bjorn \
104 -b "$BABSDN" -s base "(objectclass=*)" cn >> $SEARCHOUT 2>&1
107 # Check group access. Try to modify Babs' entry. Two attempts:
108 # 1) bound as "James A Jones 1" - should fail
109 # 2) bound as "Bjorn Jensen" - should succeed
111 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
112 $TESTOUT 2>&1 << EOMODS5
123 echo "ldapmodify should have failed ($RC)!"
124 test $KILLSERVERS != no && kill -HUP $KILLPIDS
128 echo "ldapmodify failed ($RC)!"
129 test $KILLSERVERS != no && kill -HUP $KILLPIDS
134 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
135 $TESTOUT 2>&1 << EOMODS6
139 homephone: +1 313 555 5444
146 echo "ldapmodify failed ($RC)!"
147 test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 # Try to add a "member" attribute to the "ITD Staff" group. It should
154 # fail when we add some DN other than our own, and should succeed when
157 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj > \
158 $TESTOUT 2>&1 << EOMODS1
160 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
163 uniquemember: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
170 echo "ldapmodify should have failed ($RC)!"
171 test $KILLSERVERS != no && kill -HUP $KILLPIDS
175 echo "ldapmodify failed ($RC)!"
176 test $KILLSERVERS != no && kill -HUP $KILLPIDS
181 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
182 $TESTOUT 2>&1 << EOMODS2
185 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
188 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
195 echo "ldapmodify failed ($RC)!"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
202 # Try to modify the "ITD Staff" group. Two attempts are made:
203 # 1) bound as "James A Jones 1" - should fail
204 # 2) bound as "Bjorn Jensen" - should succeed
206 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
207 $TESTOUT 2>&1 << EOMODS3
209 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
218 echo "ldapmodify should have failed ($RC)!"
219 test $KILLSERVERS != no && kill -HUP $KILLPIDS
223 echo "ldapmodify failed ($RC)!"
224 test $KILLSERVERS != no && kill -HUP $KILLPIDS
229 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
230 $TESTOUT 2>&1 << EOMODS4
234 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
248 echo "ldapmodify failed ($RC)!"
249 test $KILLSERVERS != no && kill -HUP $KILLPIDS
255 # Try to modify the "ITD Staff" group. Two attempts are made:
256 # 1) bound as "James A Jones 1" - should succeed
257 # 2) bound as "Barbara Jensen" - should fail
258 # should exploit sets
260 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
261 $TESTOUT 2>&1 << EOMODS5
262 dn: cn=Alumni Assoc Staff, ou=Groups, dc=example, dc=com
265 description: added by jaj (should succeed)
273 echo "ldapmodify failed ($RC)!"
274 test $KILLSERVERS != no && kill -HUP $KILLPIDS
279 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
280 $TESTOUT 2>&1 << EOMODS6
281 dn: cn=Alumni Assoc Staff, ou=Groups, dc=example, dc=com
284 description: added by bjensen (should fail)
292 echo "ldapmodify should have failed ($RC)!"
293 test $KILLSERVERS != no && kill -HUP $KILLPIDS
297 echo "ldapmodify failed ($RC)!"
298 test $KILLSERVERS != no && kill -HUP $KILLPIDS
303 $LDAPMODIFY -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
304 $TESTOUT 2>&1 << EOMODS7
305 dn: ou=Add & Delete,dc=example,dc=com
307 objectClass: organizationalUnit
311 if test $RC != 0 ; then
312 echo "ldapmodify failed ($RC)!"
313 test $KILLSERVERS != no && kill -HUP $KILLPIDS
317 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
318 $TESTOUT 2>&1 << EOMODS8
319 dn: cn=Added by Babs (must fail),ou=Add & Delete,dc=example,dc=com
321 objectClass: inetOrgPerson
322 cn: Added by Babs (must fail)
330 echo "ldapmodify should have failed ($RC)!"
331 test $KILLSERVERS != no && kill -HUP $KILLPIDS
335 echo "ldapmodify failed ($RC)!"
336 test $KILLSERVERS != no && kill -HUP $KILLPIDS
341 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
342 $TESTOUT 2>&1 << EOMODS9
343 dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com
345 objectClass: inetOrgPerson
346 cn: Added by Bjorn (must succeed)
349 dn: cn=Added by Bjorn (will be deleted),ou=Add & Delete,dc=example,dc=com
351 objectClass: inetOrgPerson
352 cn: Added by Bjorn (will be deleted)
355 dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com
357 objectClass: inetOrgPerson
358 cn: Added by Bjorn (will be renamed)
361 dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com
364 description: this attribute value has been added __after__entry creation
365 description: this attribute value will be deleted by Babs (must succeed)
366 description: Bjorn will try to delete this attribute value (should fail)
374 echo "ldapmodify failed ($RC)!"
375 test $KILLSERVERS != no && kill -HUP $KILLPIDS
380 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
381 $TESTOUT 2>&1 << EOMODS10
382 dn: cn=Added by Bjorn (will be deleted),ou=Add & Delete,dc=example,dc=com
390 echo "ldapmodify should have failed ($RC)!"
391 test $KILLSERVERS != no && kill -HUP $KILLPIDS
395 echo "ldapmodify failed ($RC)!"
396 test $KILLSERVERS != no && kill -HUP $KILLPIDS
401 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
402 $TESTOUT 2>&1 << EOMODS11
403 dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com
405 newrdn: cn=Added by Bjorn (renamed by Bjorn)
413 echo "ldapmodify should have failed ($RC)!"
414 test $KILLSERVERS != no && kill -HUP $KILLPIDS
418 echo "ldapmodify failed ($RC)!"
419 test $KILLSERVERS != no && kill -HUP $KILLPIDS
424 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
425 $TESTOUT 2>&1 << EOMODS12
426 dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com
428 newrdn: cn=Added by Bjorn (renamed by Babs)
436 echo "ldapmodify should have failed ($RC)!"
437 test $KILLSERVERS != no && kill -HUP $KILLPIDS
441 echo "ldapmodify failed ($RC)!"
442 test $KILLSERVERS != no && kill -HUP $KILLPIDS
447 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
448 $TESTOUT 2>&1 << EOMODS13
449 dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com
451 newrdn: cn=Added by Bjorn (renamed by Jaj)
459 echo "ldapmodify failed ($RC)!"
460 test $KILLSERVERS != no && kill -HUP $KILLPIDS
465 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
466 $TESTOUT 2>&1 << EOMODS14
467 dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com
470 description: Bjorn will try to delete this attribute value (should fail)
478 echo "ldapmodify should have failed ($RC)!"
479 test $KILLSERVERS != no && kill -HUP $KILLPIDS
483 echo "ldapmodify failed ($RC)!"
484 test $KILLSERVERS != no && kill -HUP $KILLPIDS
489 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
490 $TESTOUT 2>&1 << EOMODS15
491 dn: cn=Added by Bjorn (will be deleted),ou=Add & Delete,dc=example,dc=com
494 dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com
497 description: this attribute value will be deleted by Babs (must succeed)
505 echo "ldapmodify failed ($RC)!"
506 test $KILLSERVERS != no && kill -HUP $KILLPIDS
511 echo "Using ldapsearch to retrieve all the entries..."
512 echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
513 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
514 'objectClass=*' >> $SEARCHOUT 2>&1
516 test $KILLSERVERS != no && kill -HUP $KILLPIDS
517 if test $RC != 0 ; then
518 echo "ldapsearch failed ($RC)!"
524 echo "Filtering ldapsearch results..."
525 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
526 echo "Filtering original ldif used to create database..."
527 . $LDIFFILTER < $LDIF > $LDIFFLT
528 echo "Comparing filter output..."
529 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
531 if test $? != 0 ; then
532 echo "comparison failed - operations did not complete correctly"
536 echo ">>>>> Test succeeded"