]> git.sur5r.net Git - openldap/blob - tests/data/regressions/its8663/its8663
ITS#8663 - Regression test
[openldap] / tests / data / regressions / its8663 / its8663
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2018 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 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if test $MEMBEROF = memberofno; then
20         echo "memberof overlay not available, test skipped"
21         exit 0
22 fi
23
24 echo ""
25 echo "  This test tracks a case where it was not possible to modify the memberof overlay configuration"
26 echo "  when the provider is dynamically configured for replication."
27 echo "  See http://www.openldap.org/its/index.cgi/?findid=8663 for more information"
28 echo ""
29
30 PRODIR=$TESTDIR/pro
31 CFPRO=$PRODIR/slapd.d
32
33 mkdir -p $TESTDIR $DBDIR1 $PRODIR $CFPRO
34
35 $SLAPPASSWD -g -n >$CONFIGPWF
36
37 ITS=8663
38 ITSDIR=$DATADIR/regressions/its$ITS
39
40 echo "Starting provider slapd on TCP/IP port $PORT1..."
41 . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd-provider.ldif > $CONFLDIF
42 $SLAPADD -F $CFPRO -n 0 -l $CONFLDIF
43 $SLAPD -F $CFPRO -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
44 PID=$!
45 if test $WAIT != 0 ; then
46         echo PID $PID
47         read foo
48 fi
49 KILLPIDS="$PID"
50
51 sleep 1
52
53 echo "Using ldapsearch to check that provider slapd is running..."
54 for i in 0 1 2 3 4 5; do
55         $LDAPSEARCH -s base -b "" -H $URI1 \
56                 'objectclass=*' > /dev/null 2>&1
57         RC=$?
58         if test $RC = 0 ; then
59                 break
60         fi
61         echo "Waiting 5 seconds for slapd to start..."
62         sleep 5
63 done
64
65 if test $RC != 0 ; then
66         echo "ldapsearch failed ($RC)!"
67         test $KILLSERVERS != no && kill -HUP $KILLPIDS
68         exit $RC
69 fi
70
71 echo "Populating database on provider..."
72 $LDAPADD -D $MANAGERDN -H $URI1 -w $PASSWD << EOMODS >> $TESTOUT 2>&1
73 dn: dc=example,dc=com
74 changetype: add
75 objectClass: domain
76 objectClass: top
77 dc: example
78
79 dn: ou=LDAPRoles,dc=example,dc=com
80 objectClass: top
81 objectClass: organizationalUnit
82 ou: LDAPRoles
83
84 dn: dc=users,dc=example,dc=com
85 changetype: add
86 dc: users
87 objectClass: domain
88 objectClass: top
89
90 dn: uid=johndoe,dc=users,dc=example,dc=com
91 changetype: add
92 objectClass: inetOrgPerson
93 objectClass: top
94 sn: Doe
95 cn: Johndoe
96 uid: johndoe
97
98 dn: cn=replicator,ou=LDAPRoles,dc=example,dc=com
99 objectClass: top
100 objectClass: simpleSecurityObject
101 objectClass: organizationalRole
102 userPassword: secret
103 cn: replicator
104 EOMODS
105
106 RC=$?
107 if test $RC != 0 ; then
108         echo "ldapadd failed ($RC)!"
109         test $KILLSERVERS != no && kill -HUP $KILLPIDS
110         exit $RC
111 fi
112
113 if [ "$MEMBEROF" = memberofmod ]; then
114         echo "Configuring memberof module on the provider..."
115         $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
116 dn: cn=module,cn=config
117 objectClass: olcModuleList
118 cn: module
119 olcModulePath: $TESTWD/../servers/slapd/overlays
120 olcModuleLoad: memberof.la
121 EOF
122         RC=$?
123         if test $RC != 0 ; then
124                 echo "ldapadd failed for moduleLoad ($RC)!"
125                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126                 exit $RC
127         fi
128 fi
129
130 echo "Configuring memberof on the provider..."
131 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
132 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
133 changetype: add
134 objectClass: olcOverlayConfig
135 objectClass: olcConfig
136 objectClass: top
137 objectClass: olcMemberOf
138 olcMemberOfGroupOC: groupOfNames
139 olcMemberOfMemberAD: member
140 olcMemberOfMemberOfAD: memberOf
141 olcMemberOfDN: cn=Manager,dc=example,dc=com
142 olcMemberOfDangling: ignore
143 olcMemberOfDanglingError: 13
144 olcMemberOfRefInt: FALSE
145 olcOverlay: {0}memberof
146 EOF
147
148 RC=$?
149 if test $RC != 0 ; then
150         echo "ldapmodify failed ($RC)!"
151         test $KILLSERVERS != no && kill -HUP $KILLPIDS
152         exit $RC
153 fi
154
155 sleep 1
156
157 echo "Setting olcMemberOfRefInt to TRUE on the provider..."
158 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
159 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
160 changetype: modify
161 replace: olcMemberOfRefInt
162 olcMemberOfRefInt: TRUE
163 EOF
164
165 RC=$?
166 if test $RC != 0 ; then
167         echo "ldapmodify failed ($RC)!"
168         test $KILLSERVERS != no && kill -HUP $KILLPIDS
169         exit $RC
170 fi
171
172 sleep 1
173
174 echo "Changing olcMemberOfDangling to error on the provider..."
175 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
176 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
177 changetype: modify
178 replace: olcMemberOfDangling
179 olcMemberOfDangling: error
180 EOF
181
182 RC=$?
183 if test $RC != 0 ; then
184         echo "ldapmodify failed ($RC)!"
185         test $KILLSERVERS != no && kill -HUP $KILLPIDS
186         exit $RC
187 fi
188
189 sleep 1
190
191 echo "Changing olcMemberOfDanglingError to 20 on the provider..."
192 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
193 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
194 changetype: modify
195 replace: olcMemberOfDanglingError
196 olcMemberOfDanglingError: 20
197 EOF
198
199 RC=$?
200 if test $RC != 0 ; then
201         echo "ldapmodify failed ($RC)!"
202         test $KILLSERVERS != no && kill -HUP $KILLPIDS
203         exit $RC
204 fi
205
206 sleep 1
207
208 echo "Setting olcMemberOfDN to cn=config on the provider..."
209 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
210 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
211 changetype: modify
212 replace: olcMemberOfDN
213 olcMemberOfDN: cn=config
214 EOF
215
216 RC=$?
217 if test $RC != 0 ; then
218         echo "ldapmodify failed ($RC)!"
219         test $KILLSERVERS != no && kill -HUP $KILLPIDS
220         exit $RC
221 fi
222
223 sleep 1
224
225 echo "Changing olcMemberOfGroupOC to groupOfUniqueNames on the provider..."
226 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
227 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
228 changetype: modify
229 replace: olcMemberOfGroupOC
230 olcMemberOfGroupOC: groupOfNames
231 EOF
232
233 RC=$?
234 if test $RC != 0 ; then
235         echo "ldapmodify failed ($RC)!"
236         test $KILLSERVERS != no && kill -HUP $KILLPIDS
237         exit $RC
238 fi
239
240 sleep 1
241
242 echo "Changing olcMemberOfMemberAD to uniqueMember on the provider..."
243 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
244 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
245 changetype: modify
246 replace: olcMemberOfMemberAD
247 olcMemberOfMemberAD: uniqueMember
248 EOF
249
250 RC=$?
251 if test $RC != 0 ; then
252         echo "ldapmodify failed ($RC)!"
253         test $KILLSERVERS != no && kill -HUP $KILLPIDS
254         exit $RC
255 fi
256
257 echo "Changing olcMemberOfMemberOfAD to owner on the provider..."
258 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
259 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
260 changetype: modify
261 replace: olcMemberOfMemberOfAD
262 olcMemberOfMemberOfAD: owner
263 EOF
264
265 RC=$?
266 if test $RC != 0 ; then
267         echo "ldapmodify failed ($RC)!"
268         test $KILLSERVERS != no && kill -HUP $KILLPIDS
269         exit $RC
270 fi
271
272 test $KILLSERVERS != no && kill -HUP $KILLPIDS
273
274 echo
275 echo ">>>>> Test succeeded"
276
277 test $KILLSERVERS != no && wait
278
279 exit 0