3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 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 $REFINT = refintno; then
20 echo "Referential Integrity overlay not available, test skipped"
24 mkdir -p $TESTDIR $DBDIR1
26 echo "Running slapadd to build slapd database..."
27 . $CONFFILTER $BACKEND $MONITORDB < $REFINTCONF > $CONF1
28 $SLAPADD -f $CONF1 -l $LDIFREFINT
30 if test $RC != 0 ; then
31 echo "slapadd failed ($RC)!"
35 echo "Starting slapd on TCP/IP port $PORT1..."
36 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
38 if test $WAIT != 0 ; then
44 echo "Testing slapd referential integrity operations..."
45 for i in 0 1 2 3 4 5; do
46 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
47 'objectclass=*' > /dev/null 2>&1
49 if test $RC = 0 ; then
52 echo "Waiting 5 seconds for slapd to start..."
56 if test $RC != 0 ; then
57 echo "ldapsearch failed ($RC)!"
58 test $KILLSERVERS != no && kill -HUP $KILLPIDS
62 echo "Searching unmodified database..."
64 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 | \
65 egrep "(manager|secretary):" | sed "s/george/foster/g" | \
66 sort > $SEARCHOUT 2>&1
69 if test $RC != 0 ; then
70 echo "ldapsearch failed ($RC)!"
71 test $KILLSERVERS != no && kill -HUP $KILLPIDS
75 echo "Testing modrdn..."
76 $LDAPMODRDN -D "$REFINTDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD > \
77 /dev/null 2>&1 'uid=george,ou=users,o=refint' 'uid=foster'
78 #$LDAPMODRDN -D "$REFINTDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD \
79 # 'uid=george,ou=users,o=refint' 'uid=foster'
82 if test $RC != 0 ; then
83 echo "ldapmodrdn failed ($RC)!"
84 test $KILLSERVERS != no && kill -HUP $KILLPIDS
88 echo "Using ldapsearch to check dependents new rdn..."
90 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 | \
91 egrep "(manager|secretary):" | sort > $SEARCHFLT 2>&1
94 if test $RC != 0 ; then
95 echo "ldapsearch failed ($RC)!"
96 test $KILLSERVERS != no && kill -HUP $KILLPIDS
100 echo "Comparing ldapsearch results against original..."
101 $CMP $SEARCHOUT $SEARCHOUT > $CMPOUT
103 if test $? != 0 ; then
104 echo "comparison failed - modify operations did not complete correctly"
108 echo "Testing delete..."
109 $LDAPMODIFY -v -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
110 $TESTOUT 2>&1 << EDEL
112 dn: uid=foster,ou=users,o=refint
117 if test $RC != 0 ; then
118 echo "ldapmodify failed ($RC)!"
119 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 echo "Using ldapsearch to verify dependents have been deleted..."
124 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 | \
125 egrep "(manager|secretary):" > $SEARCHFLT 2>&1
128 if test $RC != 0 ; then
129 echo "ldapsearch failed ($RC)!"
130 test $KILLSERVERS != no && kill -HUP $KILLPIDS
134 RC=`grep -c foster $SEARCHFLT`
135 if test $RC != 0 ; then
136 echo "dependent modify failed - dependents were not deleted"
140 echo "Additional test records..."
142 $LDAPADD -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
143 $TESTOUT 2>&1 << ETEST
144 dn: uid=special,ou=users,o=refint
145 objectClass: inetOrgPerson
149 businessCategory: nothing
151 departmentNumber: 933
153 employeeNumber: 41491
156 member: uid=alice,ou=users,o=refint
159 echo "Testing delete when referential attribute is a MUST..."
160 $LDAPMODIFY -v -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
161 $TESTOUT 2>&1 << EDEL
163 dn: uid=alice,ou=users,o=refint
168 if test $RC != 0 ; then
169 echo "ldapmodify failed ($RC)!"
170 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178 test $KILLSERVERS != no && kill -HUP $KILLPIDS
180 echo ">>>>> Test succeeded"