xref: /netbsd-src/external/bsd/openldap/dist/contrib/slapd-modules/variant/tests/scripts/test005-modify (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*e670fd5cSchristosecho "Modifying entry..."
25*e670fd5cSchristos$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \
26*e670fd5cSchristos	-f data/test005-changes.ldif >> $TESTOUT 2>&1
27*e670fd5cSchristosRC=$?
28*e670fd5cSchristosif test $RC != 0 ; then
29*e670fd5cSchristos	echo "ldapmodify failed ($RC)!"
30*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
31*e670fd5cSchristos	exit $RC
32*e670fd5cSchristosfi
33*e670fd5cSchristos
34*e670fd5cSchristos# for now, overlay returns success just after the modifications to the main
35*e670fd5cSchristos# entry succeed, ignoring the rest should they fail
36*e670fd5cSchristosecho "Modifying a nonexistent variant of an existing entry..."
37*e670fd5cSchristos$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \
38*e670fd5cSchristos	-f data/test005-variant-missing.ldif >> $TESTOUT 2>&1
39*e670fd5cSchristosRC=$?
40*e670fd5cSchristosif test $RC != 0 ; then
41*e670fd5cSchristos	echo "ldapmodify failed ($RC)!"
42*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
43*e670fd5cSchristos	exit $RC
44*e670fd5cSchristosfi
45*e670fd5cSchristos
46*e670fd5cSchristosecho "Configuring nonexistent entry as variant..."
47*e670fd5cSchristos. $CONFFILTER $BACKEND $MONITORDB < data/additional-config.ldif | \
48*e670fd5cSchristos$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \
49*e670fd5cSchristos	>> $TESTOUT 2>&1
50*e670fd5cSchristosRC=$?
51*e670fd5cSchristosif test $RC != 0 ; then
52*e670fd5cSchristos	echo "ldapmodify failed ($RC)!"
53*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
54*e670fd5cSchristos	exit $RC
55*e670fd5cSchristosfi
56*e670fd5cSchristos
57*e670fd5cSchristosecho "Modifying an existing variant of above missing entry..."
58*e670fd5cSchristos$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \
59*e670fd5cSchristos	-f data/test005-modify-missing.ldif >> $TESTOUT 2>&1
60*e670fd5cSchristosRC=$?
61*e670fd5cSchristoscase $RC in
62*e670fd5cSchristos0)
63*e670fd5cSchristos	echo "ldapmodify should have failed ($RC)!"
64*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
65*e670fd5cSchristos	exit 1
66*e670fd5cSchristos	;;
67*e670fd5cSchristos32)
68*e670fd5cSchristos	echo "ldapmodify failed ($RC)"
69*e670fd5cSchristos	;;
70*e670fd5cSchristos*)
71*e670fd5cSchristos	echo "ldapmodify failed ($RC)!"
72*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
73*e670fd5cSchristos	exit $RC
74*e670fd5cSchristos	;;
75*e670fd5cSchristosesac
76*e670fd5cSchristos
77*e670fd5cSchristosecho "Reading affected entries back..."
78*e670fd5cSchristosecho "# Reading affected entries back..." >> $SEARCHOUT
79*e670fd5cSchristos$LDAPSEARCH -b "$BASEDN" -H $URI1 \
80*e670fd5cSchristos	'(|(description=*heard*)(st=*)(ou=alabama)(ou=*IT*))' \
81*e670fd5cSchristos	>> $SEARCHOUT 2>&1
82*e670fd5cSchristosRC=$?
83*e670fd5cSchristosif test $RC != 0 ; then
84*e670fd5cSchristos	echo "ldapsearch failed ($RC)!"
85*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
86*e670fd5cSchristos	exit $RC
87*e670fd5cSchristosfi
88*e670fd5cSchristos
89*e670fd5cSchristosecho >>$SEARCHOUT
90*e670fd5cSchristos$LDAPSEARCH -H $URI1 -s base \
91*e670fd5cSchristos	-b "cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN" \
92*e670fd5cSchristos	>> $SEARCHOUT 2>&1
93*e670fd5cSchristosRC=$?
94*e670fd5cSchristosif test $RC != 0 ; then
95*e670fd5cSchristos	echo "ldapsearch failed ($RC)!"
96*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
97*e670fd5cSchristos	exit $RC
98*e670fd5cSchristosfi
99*e670fd5cSchristos
100*e670fd5cSchristostest $KILLSERVERS != no && kill -HUP $KILLPIDS
101*e670fd5cSchristos
102*e670fd5cSchristosLDIF=data/test005-out.ldif
103*e670fd5cSchristos
104*e670fd5cSchristosecho "Filtering ldapsearch results..."
105*e670fd5cSchristos$LDIFFILTER -s e < $SEARCHOUT > $SEARCHFLT
106*e670fd5cSchristosecho "Filtering expected entries..."
107*e670fd5cSchristos$LDIFFILTER -s e < $LDIF > $LDIFFLT
108*e670fd5cSchristosecho "Comparing filter output..."
109*e670fd5cSchristos$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
110*e670fd5cSchristos
111*e670fd5cSchristosif test $? != 0 ; then
112*e670fd5cSchristos	echo "Comparison failed"
113*e670fd5cSchristos	exit 1
114*e670fd5cSchristosfi
115*e670fd5cSchristos
116*e670fd5cSchristosecho ">>>>> Test succeeded"
117*e670fd5cSchristos
118*e670fd5cSchristostest $KILLSERVERS != no && wait
119*e670fd5cSchristos
120*e670fd5cSchristosexit 0
121