1#! /bin/sh 2## $OpenLDAP$ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 2016-2021 The OpenLDAP Foundation. 6## All rights reserved. 7## 8## Redistribution and use in source and binary forms, with or without 9## modification, are permitted only as authorized by the OpenLDAP 10## Public License. 11## 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>. 15## 16## ACKNOWLEDGEMENTS: 17## This module was written in 2016 by Ondřej Kuzník for Symas Corp. 18 19echo "running defines.sh" 20. $SRCDIR/scripts/defines.sh 21 22. ${SCRIPTDIR}/common.sh 23 24TESTDN="cn=Gern Jensen,ou=Information Technology Division,ou=People,$BASEDN" 25 26echo "Adding referral..." 27$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 28 >> $TESTOUT 2>&1 <<EOMOD 29dn: $TESTDN 30changetype: add 31objectclass: referral 32objectclass: extensibleObject 33ref: ldap://hostB HostB 34EOMOD 35RC=$? 36if test $RC != 0 ; then 37 echo "ldapmodify failed ($RC)!" 38 test $KILLSERVERS != no && kill -HUP $KILLPIDS 39 exit $RC 40fi 41 42echo "Configuring referral as variant..." 43. $CONFFILTER $BACKEND $MONITORDB < data/additional-config.ldif | \ 44$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 45 >> $TESTOUT 2>&1 46RC=$? 47if test $RC != 0 ; then 48 echo "ldapmodify failed ($RC)!" 49 test $KILLSERVERS != no && kill -HUP $KILLPIDS 50 exit $RC 51fi 52 53echo "Retrieving a referral variant..." 54echo "# Retrieving a referral variant..." >> $SEARCHOUT 55$LDAPSEARCH -LLL -b "$BASEDN" -H $URI1 \ 56 '(cn=Gern Jensen)' >> $SEARCHOUT 2>&1 57RC=$? 58if test $RC != 0 ; then 59 echo "ldapsearch: unexpected result ($RC)!" 60 test $KILLSERVERS != no && kill -HUP $KILLPIDS 61 exit $RC 62fi 63 64echo "Retrieving a referral variant (returns a referral)..." 65echo "# Retrieving a referral variant (returns a referral)..." >> $SEARCHOUT 66$LDAPSEARCH -b "$TESTDN" -H $URI1 \ 67 >> $SEARCHOUT 2>&1 68RC=$? 69if test $RC != 10 ; then 70 echo "ldapsearch: unexpected result ($RC)! (referral expected)" 71 test $KILLSERVERS != no && kill -HUP $KILLPIDS 72 exit $RC 73fi 74 75echo "Modifying a referral variant (returns a referral)..." 76$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 77 >> $TESTOUT 2>&1 <<EOMOD 78dn: $TESTDN 79changetype: modify 80delete: description 81EOMOD 82RC=$? 83if test $RC != 10 ; then 84 echo "ldapmodify: unexpected result ($RC)! (referral expected)" 85 test $KILLSERVERS != no && kill -HUP $KILLPIDS 86 exit $RC 87fi 88 89echo "Comparing a referral variant (returns a referral)..." 90$LDAPCOMPARE -H $URI1 "$TESTDN" \ 91 "description:The Example, Inc. at Anytown" >> $TESTOUT 2>&1 92RC=$? 93if test $RC != 10; then 94 echo "ldapcompare: unexpected result ($RC)! (referral expected)" 95 test $KILLSERVERS != no && kill -HUP $KILLPIDS 96 exit 1 97fi 98 99echo "Reconfiguring variant underneath a referral..." 100$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 101 >> $TESTOUT 2>&1 <<EOMOD 102dn: name={4}test002,olcOverlay={0}variant,olcDatabase={1}$BACKEND,cn=config 103changetype: modify 104replace: olcVariantEntry 105olcVariantEntry: cn=child,$TESTDN 106EOMOD 107RC=$? 108if test $RC != 0 ; then 109 echo "ldapmodify failed ($RC)!" 110 test $KILLSERVERS != no && kill -HUP $KILLPIDS 111 exit $RC 112fi 113 114echo "Retrieving a variant under a referral (returns a referral)..." 115echo "# Retrieving a variant under a referral (returns a referral)..." >> $SEARCHOUT 116$LDAPSEARCH -b "cn=child,$TESTDN" -H $URI1 \ 117 >> $SEARCHOUT 2>&1 118RC=$? 119if test $RC != 10 ; then 120 echo "ldapsearch: unexpected result ($RC)! (referral expected)" 121 test $KILLSERVERS != no && kill -HUP $KILLPIDS 122 exit $RC 123fi 124 125echo "Modifying a variant under a referral (returns a referral)..." 126$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 127 >> $TESTOUT 2>&1 <<EOMOD 128dn: cn=child,$TESTDN 129changetype: modify 130delete: description 131EOMOD 132RC=$? 133if test $RC != 10 ; then 134 echo "ldapmodify: unexpected result ($RC)! (referral expected)" 135 test $KILLSERVERS != no && kill -HUP $KILLPIDS 136 exit $RC 137fi 138 139echo "Comparing a variant under a referral (returns a referral)..." 140$LDAPCOMPARE -H $URI1 "cn=child,$TESTDN" \ 141 "description:The Example, Inc. at Anytown" >> $TESTOUT 2>&1 142RC=$? 143if test $RC != 10; then 144 echo "ldapcompare: unexpected result ($RC)! (referral expected)" 145 test $KILLSERVERS != no && kill -HUP $KILLPIDS 146 exit 1 147fi 148 149test $KILLSERVERS != no && kill -HUP $KILLPIDS 150 151LDIF=data/test011-out.ldif 152 153echo "Filtering ldapsearch results..." 154$LDIFFILTER < $SEARCHOUT > $SEARCHFLT 155echo "Filtering expected entries..." 156$LDIFFILTER < $LDIF > $LDIFFLT 157echo "Comparing filter output..." 158$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 159 160if test $? != 0 ; then 161 echo "Comparison failed" 162 exit 1 163fi 164 165echo ">>>>> Test succeeded" 166 167test $KILLSERVERS != no && wait 168 169exit 0 170