1*e670fd5cSchristos#! /bin/sh 2*e670fd5cSchristos# $OpenLDAP$ 3*e670fd5cSchristos## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4*e670fd5cSchristos## 5*e670fd5cSchristos## Copyright 1998-2021 The OpenLDAP Foundation. 6*e670fd5cSchristos## All rights reserved. 7*e670fd5cSchristos## 8*e670fd5cSchristos## Redistribution and use in source and binary forms, with or without 9*e670fd5cSchristos## modification, are permitted only as authorized by the OpenLDAP 10*e670fd5cSchristos## Public License. 11*e670fd5cSchristos## 12*e670fd5cSchristos## A copy of this license is available in the file LICENSE in the 13*e670fd5cSchristos## top-level directory of the distribution or, alternatively, at 14*e670fd5cSchristos## <http://www.OpenLDAP.org/license.html>. 15*e670fd5cSchristos 16*e670fd5cSchristosecho "running defines.sh" 17*e670fd5cSchristos. $SRCDIR/scripts/defines.sh 18*e670fd5cSchristos 19*e670fd5cSchristosDSADM=`command -v dsadm` 20*e670fd5cSchristosif test -z "$DSADM"; then 21*e670fd5cSchristos echo "DSEE dsadm not in path, test skipped" 22*e670fd5cSchristos exit 0 23*e670fd5cSchristosfi 24*e670fd5cSchristos 25*e670fd5cSchristosmkdir -p $TESTDIR $DBDIR2 26*e670fd5cSchristos 27*e670fd5cSchristos# 28*e670fd5cSchristos# Test replication: 29*e670fd5cSchristos# - start provider 30*e670fd5cSchristos# - start consumer 31*e670fd5cSchristos# - populate over ldap 32*e670fd5cSchristos# - perform some modifies and deleted 33*e670fd5cSchristos# - attempt to modify the consumer (referral) 34*e670fd5cSchristos# - retrieve database over ldap and compare against expected results 35*e670fd5cSchristos# 36*e670fd5cSchristos 37*e670fd5cSchristosDSEEPW=secret21 38*e670fd5cSchristosDSEEDN="cn=Directory Manager" 39*e670fd5cSchristosDSEEPWF=$TESTDIR/dseepw 40*e670fd5cSchristos 41*e670fd5cSchristosecho "secret21" > $DSEEPWF 42*e670fd5cSchristos 43*e670fd5cSchristosecho "Setting up DSEE provider slapd on TCP/IP port $PORT1..." 44*e670fd5cSchristosdsadm create -p $PORT1 -w $DSEEPWF $DBDIR1 45*e670fd5cSchristosdsadm start $DBDIR1 46*e670fd5cSchristosdsconf create-suffix -c -p $PORT1 -w $DSEEPWF $BASEDN 47*e670fd5cSchristosdsconf set-server-prop -p $PORT1 -w $DSEEPWF moddn-enabled:on 48*e670fd5cSchristosdsconf set-server-prop -p $PORT1 -w $DSEEPWF retro-cl-enabled:on 49*e670fd5cSchristosdsadm restart $DBDIR1 50*e670fd5cSchristosKILLPIDS=`basename $DBDIR1/locks/server/*` 51*e670fd5cSchristos 52*e670fd5cSchristossleep 1 53*e670fd5cSchristos 54*e670fd5cSchristosecho "Using ldapsearch to check that provider slapd is running..." 55*e670fd5cSchristosfor i in 0 1 2 3 4 5; do 56*e670fd5cSchristos $LDAPSEARCH -s base -b "$BASEDN" -H $URI1 \ 57*e670fd5cSchristos 'objectclass=*' > /dev/null 2>&1 58*e670fd5cSchristos RC=$? 59*e670fd5cSchristos if test $RC = 0 ; then 60*e670fd5cSchristos break 61*e670fd5cSchristos fi 62*e670fd5cSchristos echo "Waiting 5 seconds for slapd to start..." 63*e670fd5cSchristos sleep 5 64*e670fd5cSchristosdone 65*e670fd5cSchristos 66*e670fd5cSchristosif test $RC != 0 ; then 67*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 68*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 69*e670fd5cSchristos exit $RC 70*e670fd5cSchristosfi 71*e670fd5cSchristos 72*e670fd5cSchristosecho "Starting consumer slapd on TCP/IP port $PORT2..." 73*e670fd5cSchristos. $CONFFILTER $BACKEND < $DSEESYNC1CONF > $CONF2 74*e670fd5cSchristos$SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 & 75*e670fd5cSchristosCONSUMERPID=$! 76*e670fd5cSchristosif test $WAIT != 0 ; then 77*e670fd5cSchristos echo CONSUMERPID $CONSUMERPID 78*e670fd5cSchristos read foo 79*e670fd5cSchristosfi 80*e670fd5cSchristosKILLPIDS="$KILLPIDS $CONSUMERPID" 81*e670fd5cSchristos 82*e670fd5cSchristossleep 1 83*e670fd5cSchristos 84*e670fd5cSchristosecho "Using ldapsearch to check that consumer slapd is running..." 85*e670fd5cSchristosfor i in 0 1 2 3 4 5; do 86*e670fd5cSchristos $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \ 87*e670fd5cSchristos 'objectclass=*' > /dev/null 2>&1 88*e670fd5cSchristos RC=$? 89*e670fd5cSchristos if test $RC = 0 ; then 90*e670fd5cSchristos break 91*e670fd5cSchristos fi 92*e670fd5cSchristos echo "Waiting 5 seconds for slapd to start..." 93*e670fd5cSchristos sleep 5 94*e670fd5cSchristosdone 95*e670fd5cSchristos 96*e670fd5cSchristosif test $RC != 0 ; then 97*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 98*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 99*e670fd5cSchristos exit $RC 100*e670fd5cSchristosfi 101*e670fd5cSchristos 102*e670fd5cSchristos# using LDIFDIRSYNCNOCP to avoid custom OpenLDAP schema 103*e670fd5cSchristosecho "Using ldapadd to populate the provider directory..." 104*e670fd5cSchristos$LDAPADD -D "$DSEEDN" -H $URI1 -w $DSEEPW < \ 105*e670fd5cSchristos $LDIFDIRSYNCNOCP > /dev/null 2>&1 106*e670fd5cSchristosRC=$? 107*e670fd5cSchristosif test $RC != 0 ; then 108*e670fd5cSchristos echo "ldapadd failed ($RC)!" 109*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 110*e670fd5cSchristos exit $RC 111*e670fd5cSchristosfi 112*e670fd5cSchristos 113*e670fd5cSchristosecho "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 114*e670fd5cSchristossleep $SLEEP1 115*e670fd5cSchristos 116*e670fd5cSchristosecho "Using ldapmodify to modify provider directory..." 117*e670fd5cSchristos 118*e670fd5cSchristos# 119*e670fd5cSchristos# Do some modifications 120*e670fd5cSchristos# 121*e670fd5cSchristos 122*e670fd5cSchristos$LDAPMODIFY -v -D "$DSEEDN" -H $URI1 -w $DSEEPW > \ 123*e670fd5cSchristos $TESTOUT 2>&1 << EOMODS 124*e670fd5cSchristosdn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com 125*e670fd5cSchristoschangetype: modify 126*e670fd5cSchristosadd: carLicense 127*e670fd5cSchristoscarLicense: Orange Juice 128*e670fd5cSchristos- 129*e670fd5cSchristosdelete: sn 130*e670fd5cSchristossn: Jones 131*e670fd5cSchristos- 132*e670fd5cSchristosadd: sn 133*e670fd5cSchristossn: Jones 134*e670fd5cSchristos 135*e670fd5cSchristosdn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com 136*e670fd5cSchristoschangetype: modify 137*e670fd5cSchristosreplace: carLicense 138*e670fd5cSchristoscarLicense: Iced Tea 139*e670fd5cSchristoscarLicense: Mad Dog 20/20 140*e670fd5cSchristos 141*e670fd5cSchristosdn: cn=ITD Staff,ou=Groups,dc=example,dc=com 142*e670fd5cSchristoschangetype: modify 143*e670fd5cSchristosdelete: uniquemember 144*e670fd5cSchristosuniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com 145*e670fd5cSchristosuniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com 146*e670fd5cSchristos- 147*e670fd5cSchristosadd: uniquemember 148*e670fd5cSchristosuniquemember: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com 149*e670fd5cSchristosuniquemember: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com 150*e670fd5cSchristos 151*e670fd5cSchristosdn: cn=All Staff,ou=Groups,dc=example,dc=com 152*e670fd5cSchristoschangetype: modify 153*e670fd5cSchristosdelete: description 154*e670fd5cSchristos 155*e670fd5cSchristosdn: cn=Gern Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com 156*e670fd5cSchristoschangetype: add 157*e670fd5cSchristosobjectclass: inetOrgPerson 158*e670fd5cSchristoscn: Gern Jensen 159*e670fd5cSchristossn: Jensen 160*e670fd5cSchristosuid: gjensen 161*e670fd5cSchristostitle: Chief Investigator, ITD 162*e670fd5cSchristospostaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103 163*e670fd5cSchristosseealso: cn=All Staff,ou=Groups,dc=example,dc=com 164*e670fd5cSchristoscarLicense: Coffee 165*e670fd5cSchristoshomepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104 166*e670fd5cSchristosdescription: Very odd 167*e670fd5cSchristosfacsimiletelephonenumber: +1 313 555 7557 168*e670fd5cSchristostelephonenumber: +1 313 555 8343 169*e670fd5cSchristosmail: gjensen@mailgw.example.com 170*e670fd5cSchristoshomephone: +1 313 555 8844 171*e670fd5cSchristos 172*e670fd5cSchristosdn: ou=Retired,ou=People,dc=example,dc=com 173*e670fd5cSchristoschangetype: add 174*e670fd5cSchristosobjectclass: organizationalUnit 175*e670fd5cSchristosou: Retired 176*e670fd5cSchristos 177*e670fd5cSchristosdn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com 178*e670fd5cSchristoschangetype: add 179*e670fd5cSchristosobjectclass: inetOrgPerson 180*e670fd5cSchristoscn: Rosco P. Coltrane 181*e670fd5cSchristossn: Coltrane 182*e670fd5cSchristosuid: rosco 183*e670fd5cSchristos 184*e670fd5cSchristosdn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com 185*e670fd5cSchristoschangetype: modrdn 186*e670fd5cSchristosnewrdn: cn=Rosco P. Coltrane 187*e670fd5cSchristosdeleteoldrdn: 1 188*e670fd5cSchristosnewsuperior: ou=Retired,ou=People,dc=example,dc=com 189*e670fd5cSchristos 190*e670fd5cSchristosdn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com 191*e670fd5cSchristoschangetype: delete 192*e670fd5cSchristos 193*e670fd5cSchristosdn: ou=testdomain1,dc=example,dc=com 194*e670fd5cSchristoschangetype: modrdn 195*e670fd5cSchristosnewrdn: ou=itsdomain1 196*e670fd5cSchristosdeleteoldrdn: 1 197*e670fd5cSchristos 198*e670fd5cSchristosdn: ou=itsdomain1,dc=example,dc=com 199*e670fd5cSchristoschangetype: modify 200*e670fd5cSchristosreplace: description 201*e670fd5cSchristosdescription: Example, Inc. ITS test domain 202*e670fd5cSchristos 203*e670fd5cSchristosEOMODS 204*e670fd5cSchristos 205*e670fd5cSchristosRC=$? 206*e670fd5cSchristosif test $RC != 0 ; then 207*e670fd5cSchristos echo "ldapmodify failed ($RC)!" 208*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 209*e670fd5cSchristos exit $RC 210*e670fd5cSchristosfi 211*e670fd5cSchristos 212*e670fd5cSchristosecho "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 213*e670fd5cSchristossleep $SLEEP1 214*e670fd5cSchristos 215*e670fd5cSchristosecho "Performing modrdn alone on the provider..." 216*e670fd5cSchristos$LDAPMODIFY -v -D "$DSEEDN" -H $URI1 -w $DSEEPW > \ 217*e670fd5cSchristos $TESTOUT 2>&1 << EOMODS 218*e670fd5cSchristosdn: ou=testdomain2,dc=example,dc=com 219*e670fd5cSchristoschangetype: modrdn 220*e670fd5cSchristosnewrdn: ou=itsdomain2 221*e670fd5cSchristosdeleteoldrdn: 1 222*e670fd5cSchristos 223*e670fd5cSchristosEOMODS 224*e670fd5cSchristos 225*e670fd5cSchristosRC=$? 226*e670fd5cSchristosif test $RC != 0 ; then 227*e670fd5cSchristos echo "ldapmodify failed ($RC)!" 228*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 229*e670fd5cSchristos exit $RC 230*e670fd5cSchristosfi 231*e670fd5cSchristos 232*e670fd5cSchristosecho "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 233*e670fd5cSchristossleep $SLEEP1 234*e670fd5cSchristos 235*e670fd5cSchristosecho "Performing modify alone on the provider..." 236*e670fd5cSchristos$LDAPMODIFY -v -D "$DSEEDN" -H $URI1 -w $DSEEPW > \ 237*e670fd5cSchristos $TESTOUT 2>&1 << EOMODS 238*e670fd5cSchristosdn: ou=itsdomain2,dc=example,dc=com 239*e670fd5cSchristoschangetype: modify 240*e670fd5cSchristosreplace: description 241*e670fd5cSchristosdescription: Example, Inc. itsdomain2 test domain 242*e670fd5cSchristos 243*e670fd5cSchristosEOMODS 244*e670fd5cSchristos 245*e670fd5cSchristosRC=$? 246*e670fd5cSchristosif test $RC != 0 ; then 247*e670fd5cSchristos echo "ldapmodify failed ($RC)!" 248*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 249*e670fd5cSchristos exit $RC 250*e670fd5cSchristosfi 251*e670fd5cSchristos 252*e670fd5cSchristosecho "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 253*e670fd5cSchristossleep $SLEEP1 254*e670fd5cSchristos 255*e670fd5cSchristosecho "Performing larger modify on the provider..." 256*e670fd5cSchristos$LDAPMODIFY -v -D "$DSEEDN" -H $URI1 -w $DSEEPW > \ 257*e670fd5cSchristos $TESTOUT 2>&1 << EOMODS 258*e670fd5cSchristosdn: cn=Alumni Assoc Staff,ou=Groups,dc=example,dc=com 259*e670fd5cSchristoschangetype: modify 260*e670fd5cSchristosreplace: cn 261*e670fd5cSchristoscn: Alumni Assoc Staff 262*e670fd5cSchristos- 263*e670fd5cSchristosreplace: description 264*e670fd5cSchristosdescription: blablabla 265*e670fd5cSchristos- 266*e670fd5cSchristosreplace: member 267*e670fd5cSchristosmember: cn=Manager,dc=example,dc=com 268*e670fd5cSchristosmember: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com 269*e670fd5cSchristosmember: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com 270*e670fd5cSchristosmember: cn=Jane Doe,ou=Alumni Association,ou=People,dc=example,dc=com 271*e670fd5cSchristosmember: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com 272*e670fd5cSchristosmember: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com 273*e670fd5cSchristosmember: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com 274*e670fd5cSchristos 275*e670fd5cSchristosEOMODS 276*e670fd5cSchristos 277*e670fd5cSchristosRC=$? 278*e670fd5cSchristosif test $RC != 0 ; then 279*e670fd5cSchristos echo "ldapmodify failed ($RC)!" 280*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 281*e670fd5cSchristos exit $RC 282*e670fd5cSchristosfi 283*e670fd5cSchristos 284*e670fd5cSchristosecho "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 285*e670fd5cSchristossleep $SLEEP1 286*e670fd5cSchristos 287*e670fd5cSchristosOPATTRS="creatorsName createTimestamp modifiersName modifyTimestamp" 288*e670fd5cSchristos 289*e670fd5cSchristosecho "Using ldapsearch to read all the entries from the provider..." 290*e670fd5cSchristos$LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \ 291*e670fd5cSchristos -D "$DSEEDN" -w $DSEEPW \ 292*e670fd5cSchristos '(objectclass=*)' '*' $OPATTRS > $PROVIDEROUT 2>&1 293*e670fd5cSchristosRC=$? 294*e670fd5cSchristos 295*e670fd5cSchristosif test $RC != 0 ; then 296*e670fd5cSchristos echo "ldapsearch failed at provider ($RC)!" 297*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 298*e670fd5cSchristos exit $RC 299*e670fd5cSchristosfi 300*e670fd5cSchristos 301*e670fd5cSchristosecho "Using ldapsearch to read all the entries from the consumer..." 302*e670fd5cSchristos$LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \ 303*e670fd5cSchristos '(objectclass=*)' '*' $OPATTRS > $CONSUMEROUT 2>&1 304*e670fd5cSchristosRC=$? 305*e670fd5cSchristos 306*e670fd5cSchristosif test $RC != 0 ; then 307*e670fd5cSchristos echo "ldapsearch failed at consumer ($RC)!" 308*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 309*e670fd5cSchristos exit $RC 310*e670fd5cSchristosfi 311*e670fd5cSchristos 312*e670fd5cSchristostest $KILLSERVERS != no && kill -HUP $KILLPIDS 313*e670fd5cSchristos 314*e670fd5cSchristosecho "Filtering provider results..." 315*e670fd5cSchristos$LDIFFILTER -s a < $PROVIDEROUT > $PROVIDERFLT 316*e670fd5cSchristosecho "Filtering consumer results..." 317*e670fd5cSchristos$LDIFFILTER -s a < $CONSUMEROUT > $CONSUMERFLT 318*e670fd5cSchristos 319*e670fd5cSchristosecho "Comparing retrieved entries from provider and consumer..." 320*e670fd5cSchristos$CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT 321*e670fd5cSchristos 322*e670fd5cSchristosif test $? != 0 ; then 323*e670fd5cSchristos echo "test failed - provider and consumer databases differ" 324*e670fd5cSchristos exit 1 325*e670fd5cSchristosfi 326*e670fd5cSchristos 327*e670fd5cSchristosecho ">>>>> Test succeeded" 328*e670fd5cSchristos 329*e670fd5cSchristostest $KILLSERVERS != no && wait 330*e670fd5cSchristos 331*e670fd5cSchristosexit 0 332