1 1.1 lukem #! /bin/sh 2 1.1.1.4 tron # $OpenLDAP$ 3 1.1 lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4 1.1 lukem ## 5 1.1.1.10 christos ## Copyright 2004-2024 The OpenLDAP Foundation. 6 1.1 lukem ## All rights reserved. 7 1.1 lukem ## 8 1.1 lukem ## Redistribution and use in source and binary forms, with or without 9 1.1 lukem ## modification, are permitted only as authorized by the OpenLDAP 10 1.1 lukem ## Public License. 11 1.1 lukem ## 12 1.1 lukem ## A copy of this license is available in the file LICENSE in the 13 1.1 lukem ## top-level directory of the distribution or, alternatively, at 14 1.1 lukem ## <http://www.OpenLDAP.org/license.html>. 15 1.1 lukem 16 1.1 lukem echo "running defines.sh" 17 1.1 lukem . $SRCDIR/scripts/defines.sh 18 1.1 lukem 19 1.1 lukem if test $REFINT = refintno; then 20 1.1 lukem echo "Referential Integrity overlay not available, test skipped" 21 1.1 lukem exit 0 22 1.1.1.10 christos fi 23 1.1.1.10 christos 24 1.1.1.10 christos if test $BACKEND = wt ; then 25 1.1.1.10 christos echo "back-wt does not support subtree rename" 26 1.1.1.10 christos exit 0 27 1.1.1.10 christos fi 28 1.1 lukem 29 1.1 lukem mkdir -p $TESTDIR $DBDIR1 30 1.1 lukem 31 1.1 lukem echo "Running slapadd to build slapd database..." 32 1.1.1.9 christos . $CONFFILTER $BACKEND < $REFINTCONF > $CONF1 33 1.1 lukem $SLAPADD -f $CONF1 -l $LDIFREFINT 34 1.1 lukem RC=$? 35 1.1 lukem if test $RC != 0 ; then 36 1.1 lukem echo "slapadd failed ($RC)!" 37 1.1 lukem exit $RC 38 1.1 lukem fi 39 1.1 lukem 40 1.1 lukem echo "Starting slapd on TCP/IP port $PORT1..." 41 1.1.1.9 christos $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 & 42 1.1 lukem PID=$! 43 1.1 lukem if test $WAIT != 0 ; then 44 1.1 lukem echo PID $PID 45 1.1 lukem read foo 46 1.1 lukem fi 47 1.1 lukem KILLPIDS="$PID" 48 1.1 lukem 49 1.1 lukem sleep 1 50 1.1 lukem 51 1.1 lukem echo "Testing slapd referential integrity operations..." 52 1.1 lukem for i in 0 1 2 3 4 5; do 53 1.1.1.9 christos $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ 54 1.1 lukem 'objectclass=*' > /dev/null 2>&1 55 1.1 lukem RC=$? 56 1.1 lukem if test $RC = 0 ; then 57 1.1 lukem break 58 1.1 lukem fi 59 1.1 lukem echo "Waiting 5 seconds for slapd to start..." 60 1.1 lukem sleep 5 61 1.1 lukem done 62 1.1 lukem 63 1.1 lukem if test $RC != 0 ; then 64 1.1 lukem echo "ldapsearch failed ($RC)!" 65 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 66 1.1 lukem exit $RC 67 1.1 lukem fi 68 1.1 lukem 69 1.1 lukem echo "Searching unmodified database..." 70 1.1 lukem 71 1.1.1.9 christos $LDAPSEARCH -S "" -b "o=refint" -H $URI1 > $SEARCHOUT 2>&1 72 1.1 lukem RC=$? 73 1.1 lukem if test $RC != 0 ; then 74 1.1 lukem echo "ldapsearch failed ($RC)!" 75 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 76 1.1 lukem exit $RC 77 1.1 lukem fi 78 1.1 lukem 79 1.1 lukem $EGREP_CMD "(manager|secretary):" $SEARCHOUT | sed "s/george/foster/g" | \ 80 1.1 lukem sort > $TESTOUT 2>&1 81 1.1 lukem 82 1.1 lukem echo "Testing modrdn..." 83 1.1.1.9 christos $LDAPMODRDN -D "$REFINTDN" -r -H $URI1 -w $PASSWD > \ 84 1.1 lukem /dev/null 2>&1 'uid=george,ou=users,o=refint' 'uid=foster' 85 1.1.1.9 christos #$LDAPMODRDN -D "$REFINTDN" -r -H $URI1 -w $PASSWD \ 86 1.1 lukem # 'uid=george,ou=users,o=refint' 'uid=foster' 87 1.1 lukem 88 1.1 lukem RC=$? 89 1.1 lukem if test $RC != 0 ; then 90 1.1 lukem echo "ldapmodrdn failed ($RC)!" 91 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 92 1.1 lukem exit $RC 93 1.1 lukem fi 94 1.1 lukem 95 1.1 lukem sleep 1; 96 1.1 lukem 97 1.1 lukem echo "Using ldapsearch to check dependents new rdn..." 98 1.1 lukem 99 1.1.1.9 christos $LDAPSEARCH -S "" -b "o=refint" -H $URI1 > $SEARCHOUT 2>&1 100 1.1 lukem 101 1.1 lukem RC=$? 102 1.1 lukem if test $RC != 0 ; then 103 1.1 lukem echo "ldapsearch failed ($RC)!" 104 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 105 1.1 lukem exit $RC 106 1.1 lukem fi 107 1.1 lukem 108 1.1 lukem $EGREP_CMD "(manager|secretary):" $SEARCHOUT | sort > $SEARCHFLT 2>&1 109 1.1 lukem 110 1.1 lukem echo "Comparing ldapsearch results against original..." 111 1.1 lukem $CMP $TESTOUT $SEARCHFLT > $CMPOUT 112 1.1 lukem 113 1.1 lukem if test $? != 0 ; then 114 1.1 lukem echo "comparison failed - modify operations did not complete correctly" 115 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 116 1.1 lukem exit 1 117 1.1 lukem fi 118 1.1 lukem 119 1.1 lukem echo "Testing delete..." 120 1.1.1.9 christos $LDAPMODIFY -v -D "$REFINTDN" -H $URI1 -w $PASSWD > \ 121 1.1 lukem $TESTOUT 2>&1 << EDEL 122 1.1 lukem version: 1 123 1.1 lukem dn: uid=foster,ou=users,o=refint 124 1.1 lukem changetype: delete 125 1.1 lukem EDEL 126 1.1 lukem 127 1.1 lukem RC=$? 128 1.1 lukem if test $RC != 0 ; then 129 1.1 lukem echo "ldapmodify failed ($RC)!" 130 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 131 1.1 lukem exit $RC 132 1.1 lukem fi 133 1.1 lukem 134 1.1 lukem sleep 1; 135 1.1 lukem 136 1.1 lukem echo "Using ldapsearch to verify dependents have been deleted..." 137 1.1.1.9 christos $LDAPSEARCH -S "" -b "o=refint" -H $URI1 > $SEARCHOUT 2>&1 138 1.1 lukem 139 1.1 lukem RC=$? 140 1.1 lukem if test $RC != 0 ; then 141 1.1 lukem echo "ldapsearch failed ($RC)!" 142 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 143 1.1 lukem exit $RC 144 1.1 lukem fi 145 1.1 lukem 146 1.1 lukem $EGREP_CMD "(manager|secretary):" $SEARCHOUT > $SEARCHFLT 2>&1 147 1.1 lukem 148 1.1 lukem RC=`grep -c foster $SEARCHFLT` 149 1.1 lukem if test $RC != 0 ; then 150 1.1 lukem echo "dependent modify failed - dependents were not deleted" 151 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 152 1.1 lukem exit 1 153 1.1 lukem fi 154 1.1 lukem 155 1.1 lukem echo "Additional test records..." 156 1.1 lukem 157 1.1.1.9 christos $LDAPADD -D "$REFINTDN" -H $URI1 -w $PASSWD > \ 158 1.1 lukem $TESTOUT 2>&1 << ETEST 159 1.1 lukem dn: uid=special,ou=users,o=refint 160 1.1 lukem objectClass: inetOrgPerson 161 1.1 lukem objectClass: extensibleObject 162 1.1 lukem uid: special 163 1.1 lukem sn: special 164 1.1 lukem cn: special 165 1.1 lukem businessCategory: nothing 166 1.1 lukem carLicense: FOO 167 1.1 lukem departmentNumber: 933 168 1.1 lukem displayName: special 169 1.1 lukem employeeNumber: 41491 170 1.1 lukem employeeType: vendor 171 1.1 lukem givenName: special 172 1.1 lukem member: uid=alice,ou=users,o=refint 173 1.1 lukem ETEST 174 1.1 lukem 175 1.1 lukem RC=$? 176 1.1 lukem if test $RC != 0 ; then 177 1.1 lukem echo "ldapadd failed ($RC)!" 178 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 179 1.1 lukem exit $RC 180 1.1 lukem fi 181 1.1 lukem 182 1.1 lukem echo "Testing delete when referential attribute is a MUST..." 183 1.1.1.9 christos $LDAPMODIFY -v -D "$REFINTDN" -H $URI1 -w $PASSWD > \ 184 1.1 lukem $TESTOUT 2>&1 << EDEL 185 1.1 lukem version: 1 186 1.1 lukem dn: uid=alice,ou=users,o=refint 187 1.1 lukem changetype: delete 188 1.1 lukem EDEL 189 1.1 lukem 190 1.1 lukem RC=$? 191 1.1 lukem if test $RC != 0 ; then 192 1.1 lukem echo "ldapmodify failed ($RC)!" 193 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 194 1.1 lukem exit $RC 195 1.1 lukem fi 196 1.1 lukem 197 1.1.1.9 christos $LDAPMODIFY -v -D "$REFINTDN" -H $URI1 -w $PASSWD > \ 198 1.1.1.9 christos $TESTOUT 2>&1 << EDEL 199 1.1 lukem version: 1 200 1.1 lukem dn: cn=group,o=refint 201 1.1 lukem changetype: add 202 1.1 lukem objectClass: groupOfNames 203 1.1 lukem cn: group 204 1.1 lukem member: uid=bill,ou=users,o=refint 205 1.1 lukem member: uid=bob,ou=users,o=refint 206 1.1 lukem member: uid=dave,ou=users,o=refint 207 1.1 lukem member: uid=jorge,ou=users,o=refint 208 1.1 lukem member: uid=theman,ou=users,o=refint 209 1.1 lukem member: uid=richard,ou=users,o=refint 210 1.1 lukem EDEL 211 1.1 lukem 212 1.1.1.9 christos RC=$? 213 1.1.1.9 christos if test $RC != 0 ; then 214 1.1.1.9 christos echo "ldapmodify failed ($RC)!" 215 1.1.1.9 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 216 1.1.1.9 christos exit $RC 217 1.1.1.9 christos fi 218 1.1 lukem 219 1.1.1.9 christos sleep 1; 220 1.1 lukem 221 1.1.1.9 christos $LDAPSEARCH -S "" -b "o=refint" -H $URI1 \ 222 1.1.1.9 christos manager member secretary > $SEARCHOUT 2>&1 223 1.1.1.9 christos RC=$? 224 1.1.1.9 christos if test $RC != 0 ; then 225 1.1.1.9 christos echo "ldapsearch failed ($RC)!" 226 1.1.1.9 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 227 1.1.1.9 christos exit $RC 228 1.1.1.9 christos fi 229 1.1 lukem 230 1.1.1.9 christos $EGREP_CMD "(manager|member|secretary):" $SEARCHOUT \ 231 1.1.1.9 christos | sed "s/ou=users/ou=people/g" | \ 232 1.1.1.9 christos sort > $TESTOUT 2>&1 233 1.1 lukem 234 1.1.1.9 christos echo "testing subtree rename" 235 1.1.1.9 christos $LDAPMODRDN -D "$REFINTDN" -r -H $URI1 -w $PASSWD > \ 236 1.1.1.9 christos /dev/null 2>&1 'ou=users,o=refint' 'ou=people' 237 1.1.1.9 christos RC=$? 238 1.1.1.9 christos if test $RC != 0 ; then 239 1.1.1.9 christos echo "ldapmodrdn failed ($RC)!" 240 1.1.1.9 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 241 1.1.1.9 christos exit $RC 242 1.1.1.9 christos fi 243 1.1 lukem 244 1.1.1.9 christos sleep 1; 245 1.1 lukem 246 1.1.1.9 christos echo "Using ldapsearch to check dependents new rdn..." 247 1.1 lukem 248 1.1.1.9 christos $LDAPSEARCH -S "" -b "o=refint" -H $URI1 \ 249 1.1.1.9 christos manager member secretary > $SEARCHOUT 2>&1 250 1.1.1.9 christos 251 1.1.1.9 christos RC=$? 252 1.1.1.9 christos if test $RC != 0 ; then 253 1.1.1.9 christos echo "ldapsearch failed ($RC)!" 254 1.1.1.9 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 255 1.1.1.9 christos exit $RC 256 1.1.1.9 christos fi 257 1.1 lukem 258 1.1.1.9 christos $EGREP_CMD "(manager|member|secretary):" $SEARCHOUT \ 259 1.1.1.9 christos | sort > $SEARCHFLT 2>&1 260 1.1 lukem 261 1.1.1.9 christos echo "Comparing ldapsearch results against original..." 262 1.1.1.9 christos $CMP $TESTOUT $SEARCHFLT > $CMPOUT 263 1.1 lukem 264 1.1.1.9 christos if test $? != 0 ; then 265 1.1.1.9 christos echo "comparison failed - subtree rename operations did not complete correctly" 266 1.1.1.9 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 267 1.1.1.9 christos exit 1 268 1.1 lukem fi 269 1.1 lukem 270 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 271 1.1 lukem 272 1.1 lukem echo ">>>>> Test succeeded" 273 1.1 lukem 274 1.1 lukem test $KILLSERVERS != no && wait 275 1.1 lukem 276 1.1 lukem exit 0 277