3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2004-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 if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
17 echo "Test does not support $BACKEND"
21 echo "running defines.sh"
22 . $SRCDIR/scripts/defines.sh
24 if test $REFINT = refintno; then
25 echo "Referential Integrity overlay not available, test skipped"
29 mkdir -p $TESTDIR $DBDIR1
31 echo "Running slapadd to build slapd database..."
32 . $CONFFILTER $BACKEND $MONITORDB < $REFINTCONF > $CONF1
33 $SLAPADD -f $CONF1 -l $LDIFREFINT
35 if test $RC != 0 ; then
36 echo "slapadd failed ($RC)!"
40 echo "Starting slapd on TCP/IP port $PORT1..."
41 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
43 if test $WAIT != 0 ; then
49 echo "Testing slapd referential integrity operations..."
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 echo "Searching unmodified database..."
69 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 | \
70 $EGREP_CMD "(manager|secretary):" | sed "s/george/foster/g" | \
71 sort > $SEARCHOUT 2>&1
74 if test $RC != 0 ; then
75 echo "ldapsearch failed ($RC)!"
76 test $KILLSERVERS != no && kill -HUP $KILLPIDS
80 echo "Testing modrdn..."
81 $LDAPMODRDN -D "$REFINTDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD > \
82 /dev/null 2>&1 'uid=george,ou=users,o=refint' 'uid=foster'
83 #$LDAPMODRDN -D "$REFINTDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD \
84 # 'uid=george,ou=users,o=refint' 'uid=foster'
87 if test $RC != 0 ; then
88 echo "ldapmodrdn failed ($RC)!"
89 test $KILLSERVERS != no && kill -HUP $KILLPIDS
93 echo "Using ldapsearch to check dependents new rdn..."
95 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 | \
96 $EGREP_CMD "(manager|secretary):" | sort > $SEARCHFLT 2>&1
99 if test $RC != 0 ; then
100 echo "ldapsearch failed ($RC)!"
101 test $KILLSERVERS != no && kill -HUP $KILLPIDS
105 echo "Comparing ldapsearch results against original..."
106 $CMP $SEARCHOUT $SEARCHOUT > $CMPOUT
108 if test $? != 0 ; then
109 echo "comparison failed - modify operations did not complete correctly"
110 test $KILLSERVERS != no && kill -HUP $KILLPIDS
114 echo "Testing delete..."
115 $LDAPMODIFY -v -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
116 $TESTOUT 2>&1 << EDEL
118 dn: uid=foster,ou=users,o=refint
123 if test $RC != 0 ; then
124 echo "ldapmodify failed ($RC)!"
125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
129 echo "Using ldapsearch to verify dependents have been deleted..."
130 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 | \
131 $EGREP_CMD "(manager|secretary):" > $SEARCHFLT 2>&1
134 if test $RC != 0 ; then
135 echo "ldapsearch failed ($RC)!"
136 test $KILLSERVERS != no && kill -HUP $KILLPIDS
140 RC=`grep -c foster $SEARCHFLT`
141 if test $RC != 0 ; then
142 echo "dependent modify failed - dependents were not deleted"
143 test $KILLSERVERS != no && kill -HUP $KILLPIDS
147 echo "Additional test records..."
149 $LDAPADD -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
150 $TESTOUT 2>&1 << ETEST
151 dn: uid=special,ou=users,o=refint
152 objectClass: inetOrgPerson
156 businessCategory: nothing
158 departmentNumber: 933
160 employeeNumber: 41491
163 member: uid=alice,ou=users,o=refint
166 echo "Testing delete when referential attribute is a MUST..."
167 $LDAPMODIFY -v -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
168 $TESTOUT 2>&1 << EDEL
170 dn: uid=alice,ou=users,o=refint
175 if test $RC != 0 ; then
176 echo "ldapmodify failed ($RC)!"
177 test $KILLSERVERS != no && kill -HUP $KILLPIDS
185 test $KILLSERVERS != no && kill -HUP $KILLPIDS
187 echo ">>>>> Test succeeded"