xref: /netbsd-src/external/bsd/openldap/dist/contrib/slapd-modules/variant/tests/scripts/test011-referral (revision e670fd5c413e99c2f6a37901bb21c537fcd322d2)
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 2016-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*e670fd5cSchristos## ACKNOWLEDGEMENTS:
17*e670fd5cSchristos## This module was written in 2016 by Ondřej Kuzník for Symas Corp.
18*e670fd5cSchristos
19*e670fd5cSchristosecho "running defines.sh"
20*e670fd5cSchristos. $SRCDIR/scripts/defines.sh
21*e670fd5cSchristos
22*e670fd5cSchristos. ${SCRIPTDIR}/common.sh
23*e670fd5cSchristos
24*e670fd5cSchristosTESTDN="cn=Gern Jensen,ou=Information Technology Division,ou=People,$BASEDN"
25*e670fd5cSchristos
26*e670fd5cSchristosecho "Adding referral..."
27*e670fd5cSchristos$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \
28*e670fd5cSchristos	>> $TESTOUT 2>&1 <<EOMOD
29*e670fd5cSchristosdn: $TESTDN
30*e670fd5cSchristoschangetype: add
31*e670fd5cSchristosobjectclass: referral
32*e670fd5cSchristosobjectclass: extensibleObject
33*e670fd5cSchristosref: ldap://hostB HostB
34*e670fd5cSchristosEOMOD
35*e670fd5cSchristosRC=$?
36*e670fd5cSchristosif test $RC != 0 ; then
37*e670fd5cSchristos	echo "ldapmodify failed ($RC)!"
38*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
39*e670fd5cSchristos	exit $RC
40*e670fd5cSchristosfi
41*e670fd5cSchristos
42*e670fd5cSchristosecho "Configuring referral as variant..."
43*e670fd5cSchristos. $CONFFILTER $BACKEND $MONITORDB < data/additional-config.ldif | \
44*e670fd5cSchristos$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \
45*e670fd5cSchristos	>> $TESTOUT 2>&1
46*e670fd5cSchristosRC=$?
47*e670fd5cSchristosif test $RC != 0 ; then
48*e670fd5cSchristos	echo "ldapmodify failed ($RC)!"
49*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
50*e670fd5cSchristos	exit $RC
51*e670fd5cSchristosfi
52*e670fd5cSchristos
53*e670fd5cSchristosecho "Retrieving a referral variant..."
54*e670fd5cSchristosecho "# Retrieving a referral variant..." >> $SEARCHOUT
55*e670fd5cSchristos$LDAPSEARCH -LLL -b "$BASEDN" -H $URI1 \
56*e670fd5cSchristos	'(cn=Gern Jensen)' >> $SEARCHOUT 2>&1
57*e670fd5cSchristosRC=$?
58*e670fd5cSchristosif test $RC != 0 ; then
59*e670fd5cSchristos	echo "ldapsearch: unexpected result ($RC)!"
60*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
61*e670fd5cSchristos	exit $RC
62*e670fd5cSchristosfi
63*e670fd5cSchristos
64*e670fd5cSchristosecho "Retrieving a referral variant (returns a referral)..."
65*e670fd5cSchristosecho "# Retrieving a referral variant (returns a referral)..." >> $SEARCHOUT
66*e670fd5cSchristos$LDAPSEARCH -b "$TESTDN" -H $URI1 \
67*e670fd5cSchristos	>> $SEARCHOUT 2>&1
68*e670fd5cSchristosRC=$?
69*e670fd5cSchristosif test $RC != 10 ; then
70*e670fd5cSchristos	echo "ldapsearch: unexpected result ($RC)! (referral expected)"
71*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
72*e670fd5cSchristos	exit $RC
73*e670fd5cSchristosfi
74*e670fd5cSchristos
75*e670fd5cSchristosecho "Modifying a referral variant (returns a referral)..."
76*e670fd5cSchristos$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \
77*e670fd5cSchristos	>> $TESTOUT 2>&1 <<EOMOD
78*e670fd5cSchristosdn: $TESTDN
79*e670fd5cSchristoschangetype: modify
80*e670fd5cSchristosdelete: description
81*e670fd5cSchristosEOMOD
82*e670fd5cSchristosRC=$?
83*e670fd5cSchristosif test $RC != 10 ; then
84*e670fd5cSchristos	echo "ldapmodify: unexpected result ($RC)! (referral expected)"
85*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
86*e670fd5cSchristos	exit $RC
87*e670fd5cSchristosfi
88*e670fd5cSchristos
89*e670fd5cSchristosecho "Comparing a referral variant (returns a referral)..."
90*e670fd5cSchristos$LDAPCOMPARE -H $URI1 "$TESTDN" \
91*e670fd5cSchristos	"description:The Example, Inc. at Anytown" >> $TESTOUT 2>&1
92*e670fd5cSchristosRC=$?
93*e670fd5cSchristosif test $RC != 10; then
94*e670fd5cSchristos	echo "ldapcompare: unexpected result ($RC)! (referral expected)"
95*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
96*e670fd5cSchristos	exit 1
97*e670fd5cSchristosfi
98*e670fd5cSchristos
99*e670fd5cSchristosecho "Reconfiguring variant underneath a referral..."
100*e670fd5cSchristos$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \
101*e670fd5cSchristos	>> $TESTOUT 2>&1 <<EOMOD
102*e670fd5cSchristosdn: name={4}test002,olcOverlay={0}variant,olcDatabase={1}$BACKEND,cn=config
103*e670fd5cSchristoschangetype: modify
104*e670fd5cSchristosreplace: olcVariantEntry
105*e670fd5cSchristosolcVariantEntry: cn=child,$TESTDN
106*e670fd5cSchristosEOMOD
107*e670fd5cSchristosRC=$?
108*e670fd5cSchristosif test $RC != 0 ; then
109*e670fd5cSchristos	echo "ldapmodify failed ($RC)!"
110*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
111*e670fd5cSchristos	exit $RC
112*e670fd5cSchristosfi
113*e670fd5cSchristos
114*e670fd5cSchristosecho "Retrieving a variant under a referral (returns a referral)..."
115*e670fd5cSchristosecho "# Retrieving a variant under a referral (returns a referral)..." >> $SEARCHOUT
116*e670fd5cSchristos$LDAPSEARCH -b "cn=child,$TESTDN" -H $URI1 \
117*e670fd5cSchristos	>> $SEARCHOUT 2>&1
118*e670fd5cSchristosRC=$?
119*e670fd5cSchristosif test $RC != 10 ; then
120*e670fd5cSchristos	echo "ldapsearch: unexpected result ($RC)! (referral expected)"
121*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
122*e670fd5cSchristos	exit $RC
123*e670fd5cSchristosfi
124*e670fd5cSchristos
125*e670fd5cSchristosecho "Modifying a variant under a referral (returns a referral)..."
126*e670fd5cSchristos$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \
127*e670fd5cSchristos	>> $TESTOUT 2>&1 <<EOMOD
128*e670fd5cSchristosdn: cn=child,$TESTDN
129*e670fd5cSchristoschangetype: modify
130*e670fd5cSchristosdelete: description
131*e670fd5cSchristosEOMOD
132*e670fd5cSchristosRC=$?
133*e670fd5cSchristosif test $RC != 10 ; then
134*e670fd5cSchristos	echo "ldapmodify: unexpected result ($RC)! (referral expected)"
135*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
136*e670fd5cSchristos	exit $RC
137*e670fd5cSchristosfi
138*e670fd5cSchristos
139*e670fd5cSchristosecho "Comparing a variant under a referral (returns a referral)..."
140*e670fd5cSchristos$LDAPCOMPARE -H $URI1 "cn=child,$TESTDN" \
141*e670fd5cSchristos	"description:The Example, Inc. at Anytown" >> $TESTOUT 2>&1
142*e670fd5cSchristosRC=$?
143*e670fd5cSchristosif test $RC != 10; then
144*e670fd5cSchristos	echo "ldapcompare: unexpected result ($RC)! (referral expected)"
145*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
146*e670fd5cSchristos	exit 1
147*e670fd5cSchristosfi
148*e670fd5cSchristos
149*e670fd5cSchristostest $KILLSERVERS != no && kill -HUP $KILLPIDS
150*e670fd5cSchristos
151*e670fd5cSchristosLDIF=data/test011-out.ldif
152*e670fd5cSchristos
153*e670fd5cSchristosecho "Filtering ldapsearch results..."
154*e670fd5cSchristos$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
155*e670fd5cSchristosecho "Filtering expected entries..."
156*e670fd5cSchristos$LDIFFILTER < $LDIF > $LDIFFLT
157*e670fd5cSchristosecho "Comparing filter output..."
158*e670fd5cSchristos$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
159*e670fd5cSchristos
160*e670fd5cSchristosif test $? != 0 ; then
161*e670fd5cSchristos	echo "Comparison failed"
162*e670fd5cSchristos	exit 1
163*e670fd5cSchristosfi
164*e670fd5cSchristos
165*e670fd5cSchristosecho ">>>>> Test succeeded"
166*e670fd5cSchristos
167*e670fd5cSchristostest $KILLSERVERS != no && wait
168*e670fd5cSchristos
169*e670fd5cSchristosexit 0
170