1 1.1 christos #! /bin/sh 2 1.1 christos # $OpenLDAP$ 3 1.1 christos ## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4 1.1 christos ## 5 1.1.1.2 christos ## Copyright 1998-2024 The OpenLDAP Foundation. 6 1.1 christos ## All rights reserved. 7 1.1 christos ## 8 1.1 christos ## Redistribution and use in source and binary forms, with or without 9 1.1 christos ## modification, are permitted only as authorized by the OpenLDAP 10 1.1 christos ## Public License. 11 1.1 christos ## 12 1.1 christos ## A copy of this license is available in the file LICENSE in the 13 1.1 christos ## top-level directory of the distribution or, alternatively, at 14 1.1 christos ## <http://www.OpenLDAP.org/license.html>. 15 1.1 christos 16 1.1 christos echo "running defines.sh" 17 1.1 christos . $SRCDIR/scripts/defines.sh 18 1.1 christos 19 1.1 christos # requires MSAD_URI, MSAD_SUFFIX, MSAD_ADMINDN, MSAD_ADMINPW 20 1.1 christos if test -z "$MSAD_URI"; then 21 1.1 christos echo "No MSAD envvars set, test skipped" 22 1.1 christos exit 0 23 1.1 christos fi 24 1.1 christos if test $SYNCPROV = syncprovno; then 25 1.1 christos echo "Syncrepl provider overlay not available, test skipped" 26 1.1 christos exit 0 27 1.1 christos fi 28 1.1 christos 29 1.1 christos mkdir -p $TESTDIR $DBDIR2 30 1.1 christos 31 1.1 christos URI1=$MSAD_URI 32 1.1 christos BASEDN="ou=OpenLDAPtest,$MSAD_SUFFIX" 33 1.1 christos DC=`echo $MSAD_SUFFIX | sed -e 's/dc=//' -e 's/,.*//'` 34 1.1 christos 35 1.1 christos # 36 1.1 christos # Test replication: 37 1.1 christos # - populate MSAD over ldap 38 1.1 christos # - start consumer 39 1.1 christos # - perform some modifies and deletes 40 1.1 christos # - attempt to modify the consumer (referral) 41 1.1 christos # - retrieve database over ldap and compare against expected results 42 1.1 christos # 43 1.1 christos 44 1.1 christos # Notes: 45 1.1 christos # We use a separate OU under the MSAD suffix to contain our test objects, 46 1.1 christos # since we can't just wipe out the entire directory when starting over. 47 1.1 christos # The replication search filter is thus more convoluted than would normally 48 1.1 christos # be needed. Typically it would only need (|(objectclass=user)(objectclass=group)) 49 1.1 christos # 50 1.1 christos # MSAD does referential integrity by default, so to get 1-to-1 modifications 51 1.1 christos # we must add users before creating groups that reference them, and we 52 1.1 christos # should delete group memberships before deleting users. If we delete 53 1.1 christos # users first, MSAD will automatically remove them from their groups, 54 1.1 christos # but won't notify us of these changed groups. 55 1.1 christos # We could use the refint overlay to duplicate this behavior, but that's 56 1.1 christos # beyond the scope of this test. 57 1.1 christos 58 1.1 christos echo "Using ldapsearch to check that MSAD is running..." 59 1.1 christos $LDAPSEARCH -D $MSAD_ADMINDN -w $MSAD_ADMINPW -s base -b "$MSAD_SUFFIX" -H $MSAD_URI 'objectclass=*' > /dev/null 2>&1 60 1.1 christos RC=$? 61 1.1 christos if test $RC != 0 ; then 62 1.1 christos echo "ldapsearch failed ($RC)!" 63 1.1 christos exit $RC 64 1.1 christos fi 65 1.1 christos 66 1.1 christos echo "Using ldapdelete to delete old MSAD test tree, if any..." 67 1.1 christos $LDAPDELETE -D "$MSAD_ADMINDN" -H $MSAD_URI -w $MSAD_ADMINPW -r "$BASEDN" 68 1.1 christos RC=$? 69 1.1 christos 70 1.1 christos echo "Using ldapadd to create the test context entry in MSAD..." 71 1.1 christos sed -e "s/dc=example,dc=com/$MSAD_SUFFIX/" < $LDIFDIRSYNCCP | \ 72 1.1 christos $LDAPADD -D "$MSAD_ADMINDN" -H $MSAD_URI -w $MSAD_ADMINPW > /dev/null 2>&1 73 1.1 christos 74 1.1 christos RC=$? 75 1.1 christos if test $RC != 0 ; then 76 1.1 christos echo "ldapadd failed ($RC)!" 77 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 78 1.1 christos exit $RC 79 1.1 christos fi 80 1.1 christos 81 1.1 christos echo "Starting consumer slapd on TCP/IP port $PORT2..." 82 1.1 christos . $CONFFILTER $BACKEND < $DIRSYNC1CONF | . $CONFDIRSYNC > $CONF2 83 1.1 christos $SLAPADD -f $CONF2 <<EOMODS 84 1.1 christos dn: $MSAD_SUFFIX 85 1.1 christos dc: $DC 86 1.1 christos objectclass: organization 87 1.1 christos objectclass: dcObject 88 1.1 christos o: OpenLDAP Testing 89 1.1 christos 90 1.1 christos EOMODS 91 1.1.1.2 christos RC=$? 92 1.1.1.2 christos if test $RC != 0 ; then 93 1.1.1.2 christos echo "slapadd failed ($RC)!" 94 1.1.1.2 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 95 1.1.1.2 christos exit $RC 96 1.1.1.2 christos fi 97 1.1.1.2 christos 98 1.1 christos $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 & 99 1.1 christos CONSUMERPID=$! 100 1.1 christos if test $WAIT != 0 ; then 101 1.1 christos echo CONSUMERPID $CONSUMERPID 102 1.1 christos read foo 103 1.1 christos fi 104 1.1 christos KILLPIDS="$KILLPIDS $CONSUMERPID" 105 1.1 christos 106 1.1 christos sleep 1 107 1.1 christos 108 1.1 christos echo "Using ldapsearch to check that consumer slapd is running..." 109 1.1 christos for i in 0 1 2 3 4 5; do 110 1.1 christos $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \ 111 1.1 christos 'objectclass=*' > /dev/null 2>&1 112 1.1 christos RC=$? 113 1.1 christos if test $RC = 0 ; then 114 1.1 christos break 115 1.1 christos fi 116 1.1 christos echo "Waiting 5 seconds for slapd to start..." 117 1.1 christos sleep 5 118 1.1 christos done 119 1.1 christos 120 1.1 christos if test $RC != 0 ; then 121 1.1 christos echo "ldapsearch failed ($RC)!" 122 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 123 1.1 christos exit $RC 124 1.1 christos fi 125 1.1 christos 126 1.1 christos 127 1.1 christos echo "Using ldapsearch to check that consumer received context entry..." 128 1.1 christos for i in 0 1 2 3 4 5; do 129 1.1 christos $LDAPSEARCH -s base -b "$BASEDN" -H $URI2 \ 130 1.1 christos 'objectclass=*' > /dev/null 2>&1 131 1.1 christos RC=$? 132 1.1 christos if test $RC = 0 ; then 133 1.1 christos break 134 1.1 christos fi 135 1.1 christos echo "Waiting 5 seconds for syncrepl to catch up..." 136 1.1 christos sleep 5 137 1.1 christos done 138 1.1 christos 139 1.1 christos if test $RC != 0 ; then 140 1.1 christos echo "ldapsearch failed ($RC)!" 141 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 142 1.1 christos exit $RC 143 1.1 christos fi 144 1.1 christos 145 1.1 christos echo "Using ldapadd to populate MSAD..." 146 1.1 christos sed -e "s/dc=example,dc=com/$BASEDN/" < $LDIFDIRSYNCNOCP | \ 147 1.1 christos $LDAPADD -D "$MSAD_ADMINDN" -H $MSAD_URI -w $MSAD_ADMINPW > /dev/null 2>&1 148 1.1 christos RC=$? 149 1.1 christos if test $RC != 0 ; then 150 1.1 christos echo "ldapadd failed ($RC)!" 151 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 152 1.1 christos exit $RC 153 1.1 christos fi 154 1.1 christos 155 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 156 1.1 christos sleep $SLEEP1 157 1.1 christos 158 1.1 christos echo "Using ldapmodify to modify provider directory..." 159 1.1 christos 160 1.1 christos # 161 1.1 christos # Do some modifications 162 1.1 christos # 163 1.1 christos 164 1.1 christos $LDAPMODIFY -v -H $MSAD_URI -D "$MSAD_ADMINDN" -w $MSAD_ADMINPW > \ 165 1.1 christos $TESTOUT 2>&1 << EOMODS 166 1.1 christos dn: cn=James A Jones 1, ou=Alumni Association, ou=People, $BASEDN 167 1.1 christos changetype: modify 168 1.1 christos add: carLicense 169 1.1 christos carLicense: Orange Juice 170 1.1 christos - 171 1.1 christos delete: sn 172 1.1 christos sn: Jones 173 1.1 christos - 174 1.1 christos add: sn 175 1.1 christos sn: Jones 176 1.1 christos 177 1.1 christos dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, $BASEDN 178 1.1 christos changetype: modify 179 1.1 christos replace: carLicense 180 1.1 christos carLicense: Iced Tea 181 1.1 christos carLicense: Mad Dog 20/20 182 1.1 christos 183 1.1 christos dn: cn=ITD Staff,ou=Groups,$BASEDN 184 1.1 christos changetype: modify 185 1.1 christos delete: uniquemember 186 1.1 christos uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, $BASEDN 187 1.1 christos uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, $BASEDN 188 1.1 christos - 189 1.1 christos add: uniquemember 190 1.1 christos uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, $BASEDN 191 1.1 christos uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, $BASEDN 192 1.1 christos 193 1.1 christos dn: cn=All Staff,ou=Groups,$BASEDN 194 1.1 christos changetype: modify 195 1.1 christos replace: description 196 1.1 christos description: The whole universe 197 1.1 christos - 198 1.1 christos delete: member 199 1.1 christos member: cn=James A Jones 2,ou=Information Technology Division,ou=People,$BASEDN 200 1.1 christos 201 1.1 christos dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, $BASEDN 202 1.1 christos changetype: add 203 1.1 christos objectclass: inetorgperson 204 1.1 christos objectclass: domainrelatedobject 205 1.1 christos cn: Gern Jensen 206 1.1 christos sn: Jensen 207 1.1 christos uid: gjensen 208 1.1 christos title: Chief Investigator, ITD 209 1.1 christos postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103 210 1.1 christos seealso: cn=All Staff, ou=Groups, $BASEDN 211 1.1 christos carLicense: Coffee 212 1.1 christos homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104 213 1.1 christos description: Very odd 214 1.1 christos facsimiletelephonenumber: +1 313 555 7557 215 1.1 christos telephonenumber: +1 313 555 8343 216 1.1 christos mail: gjensen@mailgw.example.com 217 1.1 christos homephone: +1 313 555 8844 218 1.1 christos associateddomain: test.openldap.org 219 1.1 christos 220 1.1 christos dn: ou=Retired, ou=People, $BASEDN 221 1.1 christos changetype: add 222 1.1 christos objectclass: organizationalUnit 223 1.1 christos ou: Retired 224 1.1 christos 225 1.1 christos dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, $BASEDN 226 1.1 christos changetype: add 227 1.1 christos objectclass: inetorgperson 228 1.1 christos objectclass: domainrelatedobject 229 1.1 christos cn: Rosco P. Coltrane 230 1.1 christos sn: Coltrane 231 1.1 christos uid: rosco 232 1.1 christos associateddomain: test.openldap.org 233 1.1 christos 234 1.1 christos dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, $BASEDN 235 1.1 christos changetype: modrdn 236 1.1 christos newrdn: cn=Rosco P. Coltrane 237 1.1 christos deleteoldrdn: 1 238 1.1 christos newsuperior: ou=Retired, ou=People, $BASEDN 239 1.1 christos 240 1.1 christos dn: ou=testdomain1,$BASEDN 241 1.1 christos changetype: modrdn 242 1.1 christos newrdn: ou=itsdomain1 243 1.1 christos deleteoldrdn: 1 244 1.1 christos 245 1.1 christos dn: ou=itsdomain1,$BASEDN 246 1.1 christos changetype: modify 247 1.1 christos replace: description 248 1.1 christos description: Example, Inc. ITS test domain 249 1.1 christos 250 1.1 christos EOMODS 251 1.1 christos 252 1.1 christos RC=$? 253 1.1 christos if test $RC != 0 ; then 254 1.1 christos echo "ldapmodify failed ($RC)!" 255 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 256 1.1 christos exit $RC 257 1.1 christos fi 258 1.1 christos 259 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 260 1.1 christos sleep $SLEEP1 261 1.1 christos 262 1.1 christos echo "Performing modrdn alone on the provider..." 263 1.1 christos $LDAPMODIFY -v -H $MSAD_URI -D "$MSAD_ADMINDN" -w $MSAD_ADMINPW > \ 264 1.1 christos $TESTOUT 2>&1 << EOMODS 265 1.1 christos dn: ou=testdomain2,$BASEDN 266 1.1 christos changetype: modrdn 267 1.1 christos newrdn: ou=itsdomain2 268 1.1 christos deleteoldrdn: 1 269 1.1 christos 270 1.1 christos EOMODS 271 1.1 christos 272 1.1 christos RC=$? 273 1.1 christos if test $RC != 0 ; then 274 1.1 christos echo "ldapmodify failed ($RC)!" 275 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 276 1.1 christos exit $RC 277 1.1 christos fi 278 1.1 christos 279 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 280 1.1 christos sleep $SLEEP1 281 1.1 christos 282 1.1 christos echo "Performing modify alone on the provider..." 283 1.1 christos $LDAPMODIFY -v -H $MSAD_URI -D "$MSAD_ADMINDN" -w $MSAD_ADMINPW > \ 284 1.1 christos $TESTOUT 2>&1 << EOMODS 285 1.1 christos dn: ou=itsdomain2,$BASEDN 286 1.1 christos changetype: modify 287 1.1 christos replace: description 288 1.1 christos description: Example, Inc. itsdomain2 test domain 289 1.1 christos 290 1.1 christos EOMODS 291 1.1 christos 292 1.1 christos RC=$? 293 1.1 christos if test $RC != 0 ; then 294 1.1 christos echo "ldapmodify failed ($RC)!" 295 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 296 1.1 christos exit $RC 297 1.1 christos fi 298 1.1 christos 299 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 300 1.1 christos sleep $SLEEP1 301 1.1 christos 302 1.1 christos echo "Performing larger modify on the provider..." 303 1.1 christos $LDAPMODIFY -v -H $MSAD_URI -D "$MSAD_ADMINDN" -w $MSAD_ADMINPW > \ 304 1.1 christos $TESTOUT 2>&1 << EOMODS 305 1.1 christos dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, $BASEDN 306 1.1 christos changetype: delete 307 1.1 christos 308 1.1 christos dn: cn=Alumni Assoc Staff,ou=Groups,$BASEDN 309 1.1 christos changetype: modify 310 1.1 christos replace: description 311 1.1 christos description: blablabla 312 1.1 christos - 313 1.1 christos replace: member 314 1.1 christos member: cn=Manager,$BASEDN 315 1.1 christos member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,$BASEDN 316 1.1 christos member: cn=James A Jones 1,ou=Alumni Association,ou=People,$BASEDN 317 1.1 christos member: cn=Jane Doe,ou=Alumni Association,ou=People,$BASEDN 318 1.1 christos member: cn=Jennifer Smith,ou=Alumni Association,ou=People,$BASEDN 319 1.1 christos member: cn=Mark Elliot,ou=Alumni Association,ou=People,$BASEDN 320 1.1 christos member: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN 321 1.1 christos 322 1.1 christos EOMODS 323 1.1 christos 324 1.1 christos RC=$? 325 1.1 christos if test $RC != 0 ; then 326 1.1 christos echo "ldapmodify failed ($RC)!" 327 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 328 1.1 christos exit $RC 329 1.1 christos fi 330 1.1 christos 331 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 332 1.1 christos sleep $SLEEP1 333 1.1 christos 334 1.1 christos OPATTRS="entryUUID creatorsName createTimestamp modifiersName modifyTimestamp" 335 1.1 christos 336 1.1 christos echo "Using ldapsearch to read all the entries from the provider..." 337 1.1 christos $LDAPSEARCH -D $MSAD_ADMINDN -w $MSAD_ADMINPW -S "" -H $MSAD_URI -b "$MSAD_SUFFIX" -E \!dirsync=0/0 -o ldif_wrap=120 \ 338 1.1 christos '(associatedDomain=test.openldap.org)' > $PROVIDEROUT 2>&1 339 1.1 christos RC=$? 340 1.1 christos 341 1.1 christos if test $RC != 0 ; then 342 1.1 christos echo "ldapsearch failed at provider ($RC)!" 343 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 344 1.1 christos exit $RC 345 1.1 christos fi 346 1.1 christos 347 1.1 christos echo "Using ldapsearch to read all the entries from the consumer..." 348 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 -o ldif_wrap=120 \ 349 1.1 christos '(objectclass=*)' > $CONSUMEROUT 2>&1 350 1.1 christos RC=$? 351 1.1 christos 352 1.1 christos if test $RC != 0 ; then 353 1.1 christos echo "ldapsearch failed at consumer ($RC)!" 354 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 355 1.1 christos exit $RC 356 1.1 christos fi 357 1.1 christos 358 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 359 1.1 christos 360 1.1 christos echo "Filtering provider results..." 361 1.1 christos $LDIFFILTER -s a < $PROVIDEROUT | sed -e 's/CN=/cn=/g' -e 's/OU=/ou=/g' -e 's/DC=/dc=/g' > $PROVIDERFLT 362 1.1 christos echo "Filtering consumer results..." 363 1.1 christos $LDIFFILTER -s a < $CONSUMEROUT > $CONSUMERFLT 364 1.1 christos 365 1.1 christos echo "Comparing retrieved entries from provider and consumer..." 366 1.1 christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT 367 1.1 christos 368 1.1 christos if test $? != 0 ; then 369 1.1 christos echo "test failed - provider and consumer databases differ" 370 1.1 christos exit 1 371 1.1 christos fi 372 1.1 christos 373 1.1 christos echo ">>>>> Test succeeded" 374 1.1 christos 375 1.1 christos test $KILLSERVERS != no && wait 376 1.1 christos 377 1.1 christos exit 0 378