test024-unique revision 1.1.1.4 1 1.1 lukem #! /bin/sh
2 1.1.1.4 tron # $OpenLDAP$
3 1.1 lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 1.1 lukem ##
5 1.1.1.4 tron ## Copyright 2004-2014 The OpenLDAP Foundation.
6 1.1 lukem ## All rights reserved.
7 1.1 lukem ##
8 1.1 lukem ## Redistribution and use in source and binary forms, with or without
9 1.1 lukem ## modification, are permitted only as authorized by the OpenLDAP
10 1.1 lukem ## Public License.
11 1.1 lukem ##
12 1.1 lukem ## A copy of this license is available in the file LICENSE in the
13 1.1 lukem ## top-level directory of the distribution or, alternatively, at
14 1.1 lukem ## <http://www.OpenLDAP.org/license.html>.
15 1.1 lukem
16 1.1 lukem echo "running defines.sh"
17 1.1 lukem . $SRCDIR/scripts/defines.sh
18 1.1 lukem
19 1.1 lukem if test $UNIQUE = uniqueno; then
20 1.1 lukem echo "Attribute Uniqueness overlay not available, test skipped"
21 1.1 lukem exit 0
22 1.1 lukem fi
23 1.1 lukem
24 1.1.1.3 adam RCODEconstraint=19
25 1.1.1.3 adam test $BACKEND = null && RCODEconstraint=0
26 1.1.1.3 adam
27 1.1 lukem mkdir -p $TESTDIR $DBDIR1
28 1.1 lukem
29 1.1 lukem $SLAPPASSWD -g -n >$CONFIGPWF
30 1.1 lukem echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
31 1.1 lukem
32 1.1 lukem echo "Running slapadd to build slapd database..."
33 1.1 lukem . $CONFFILTER $BACKEND $MONITORDB < $UNIQUECONF > $CONF1
34 1.1 lukem $SLAPADD -f $CONF1 -l $LDIFUNIQUE
35 1.1 lukem RC=$?
36 1.1 lukem if test $RC != 0 ; then
37 1.1 lukem echo "slapadd failed ($RC)!"
38 1.1 lukem exit $RC
39 1.1 lukem fi
40 1.1 lukem
41 1.1 lukem echo "Starting slapd on TCP/IP port $PORT1..."
42 1.1 lukem mkdir $TESTDIR/confdir
43 1.1 lukem $SLAPD -f $CONF1 -F $TESTDIR/confdir -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
44 1.1 lukem PID=$!
45 1.1 lukem if test $WAIT != 0 ; then
46 1.1 lukem echo PID $PID
47 1.1 lukem read foo
48 1.1 lukem fi
49 1.1 lukem KILLPIDS="$PID"
50 1.1 lukem
51 1.1 lukem sleep 1
52 1.1 lukem
53 1.1 lukem echo "Testing slapd attribute uniqueness operations..."
54 1.1 lukem for i in 0 1 2 3 4 5; do
55 1.1 lukem $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
56 1.1 lukem 'objectclass=*' > /dev/null 2>&1
57 1.1 lukem RC=$?
58 1.1 lukem if test $RC = 0 ; then
59 1.1 lukem break
60 1.1 lukem fi
61 1.1 lukem echo "Waiting 5 seconds for slapd to start..."
62 1.1 lukem sleep 5
63 1.1 lukem done
64 1.1 lukem
65 1.1 lukem if test $RC != 0 ; then
66 1.1 lukem echo "ldapsearch failed ($RC)!"
67 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
68 1.1 lukem exit $RC
69 1.1 lukem fi
70 1.1 lukem
71 1.1 lukem echo "Adding a unique record..."
72 1.1 lukem $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
73 1.1 lukem > /dev/null << EOTUNIQ1
74 1.1 lukem dn: uid=dave,ou=users,o=unique
75 1.1 lukem objectClass: inetOrgPerson
76 1.1 lukem uid: dave
77 1.1 lukem sn: nothere
78 1.1 lukem cn: dave
79 1.1 lukem businessCategory: otest
80 1.1 lukem carLicense: TEST
81 1.1 lukem departmentNumber: 42
82 1.1 lukem # NOTE: use special chars in attr value to be used
83 1.1 lukem # in internal searches ITS#4212
84 1.1 lukem displayName: Dave (ITS#4212)
85 1.1 lukem employeeNumber: 69
86 1.1 lukem employeeType: contractor
87 1.1 lukem givenName: Dave
88 1.1 lukem EOTUNIQ1
89 1.1 lukem RC=$?
90 1.1 lukem if test $RC != 0 ; then
91 1.1 lukem echo "ldapadd failed ($RC)!"
92 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
93 1.1 lukem exit $RC
94 1.1 lukem fi
95 1.1 lukem
96 1.1 lukem echo "Adding a non-unique record..."
97 1.1 lukem $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
98 1.1 lukem $TESTOUT 2>&1 << EOTUNIQ2
99 1.1 lukem dn: uid=bill,ou=users,o=unique
100 1.1 lukem objectClass: inetOrgPerson
101 1.1 lukem uid: bill
102 1.1 lukem sn: johnson
103 1.1 lukem cn: bill
104 1.1 lukem businessCategory: rtest
105 1.1 lukem carLicense: ABC123
106 1.1 lukem departmentNumber: 42
107 1.1 lukem displayName: Bill
108 1.1 lukem employeeNumber: 5150
109 1.1 lukem employeeType: contractor
110 1.1 lukem givenName: Bill
111 1.1 lukem EOTUNIQ2
112 1.1 lukem RC=$?
113 1.1.1.3 adam if test $RC != $RCODEconstraint ; then
114 1.1 lukem echo "unique check failed ($RC)!"
115 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
116 1.1 lukem exit -1
117 1.1 lukem fi
118 1.1 lukem
119 1.1 lukem echo Dynamically retrieving initial configuration...
120 1.1 lukem $LDAPSEARCH -S "" -b olcOverlay='{0}'unique,olcDatabase='{1}'$BACKEND,cn=config -D cn=config -y $CONFIGPWF -h $LOCALHOST -p $PORT1 -LLL | tr -d \\r >$TESTDIR/initial-config.ldif
121 1.1 lukem cat <<EOF >$TESTDIR/initial-reference.ldif
122 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
123 1.1 lukem objectClass: olcOverlayConfig
124 1.1 lukem objectClass: olcUniqueConfig
125 1.1 lukem olcOverlay: {0}unique
126 1.1 lukem olcUniqueBase: o=unique
127 1.1 lukem olcUniqueAttribute: employeeNumber
128 1.1 lukem olcUniqueAttribute: displayName
129 1.1 lukem
130 1.1 lukem EOF
131 1.1 lukem diff $TESTDIR/initial-config.ldif $TESTDIR/initial-reference.ldif > /dev/null 2>&1
132 1.1 lukem RC=$?
133 1.1 lukem if test $RC != 0 ; then
134 1.1 lukem echo "Initial configuration is not reported correctly."
135 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
136 1.1 lukem exit -1
137 1.1 lukem fi
138 1.1 lukem
139 1.1 lukem echo Dynamically trying to add a URI with legacy attrs present...
140 1.1 lukem $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
141 1.1 lukem > $TESTOUT 2>&1 <<EOF
142 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
143 1.1 lukem changetype: modify
144 1.1 lukem add: olcUniqueURI
145 1.1 lukem olcUniqueURI: ldap:///?employeeNumber,displayName?sub
146 1.1 lukem EOF
147 1.1 lukem RC=$?
148 1.1 lukem if test $RC != 80 ; then
149 1.1 lukem echo "legacy and unique_uri allowed together"
150 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
151 1.1 lukem exit -1
152 1.1 lukem fi
153 1.1 lukem
154 1.1 lukem echo Dynamically trying to add legacy ignored attrs with legacy attrs present...
155 1.1 lukem $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
156 1.1 lukem > $TESTOUT 2>&1 <<EOF
157 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
158 1.1 lukem changetype: modify
159 1.1 lukem add: olcUniqueIgnore
160 1.1 lukem olcUniqueIgnore: objectClass
161 1.1 lukem EOF
162 1.1 lukem RC=$?
163 1.1 lukem if test $RC != 80 ; then
164 1.1 lukem echo "legacy attrs and legacy ignore attrs allowed together"
165 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
166 1.1 lukem exit -1
167 1.1 lukem fi
168 1.1 lukem
169 1.1 lukem echo Verifying initial configuration intact...
170 1.1 lukem $LDAPSEARCH -S "" -b olcOverlay='{0}'unique,olcDatabase='{1}'$BACKEND,cn=config -D cn=config -y $CONFIGPWF -h $LOCALHOST -p $PORT1 -LLL | tr -d \\r >$TESTDIR/initial-config-recheck.ldif
171 1.1 lukem diff $TESTDIR/initial-config-recheck.ldif $TESTDIR/initial-reference.ldif > /dev/null 2>&1
172 1.1 lukem RC=$?
173 1.1 lukem if test $RC != 0 ; then
174 1.1 lukem echo "Initial configuration damaged by unsuccessful modifies."
175 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
176 1.1 lukem exit -1
177 1.1 lukem fi
178 1.1 lukem
179 1.1 lukem echo Dynamically removing legacy base...
180 1.1 lukem $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
181 1.1 lukem > $TESTOUT 2>&1 <<EOF
182 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
183 1.1 lukem changetype: modify
184 1.1 lukem delete: olcUniqueBase
185 1.1 lukem EOF
186 1.1 lukem RC=$?
187 1.1 lukem if test $RC != 0 ; then
188 1.1 lukem echo "base removal failed"
189 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
190 1.1 lukem exit -1
191 1.1 lukem fi
192 1.1 lukem
193 1.1 lukem echo Verifying base removal...
194 1.1 lukem $LDAPSEARCH -S "" -b olcOverlay='{0}'unique,olcDatabase='{1}'$BACKEND,cn=config -D cn=config -y $CONFIGPWF -h $LOCALHOST -p $PORT1 -LLL | tr -d \\r >$TESTDIR/baseremoval-config.ldif
195 1.1 lukem cat >$TESTDIR/baseremoval-reference.ldif <<EOF
196 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
197 1.1 lukem objectClass: olcOverlayConfig
198 1.1 lukem objectClass: olcUniqueConfig
199 1.1 lukem olcOverlay: {0}unique
200 1.1 lukem olcUniqueAttribute: employeeNumber
201 1.1 lukem olcUniqueAttribute: displayName
202 1.1 lukem
203 1.1 lukem EOF
204 1.1 lukem diff $TESTDIR/baseremoval-config.ldif $TESTDIR/baseremoval-reference.ldif > /dev/null 2>&1
205 1.1 lukem RC=$?
206 1.1 lukem if test $RC != 0 ; then
207 1.1 lukem echo "Configuration damaged by base removal"
208 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
209 1.1 lukem exit -1
210 1.1 lukem fi
211 1.1 lukem
212 1.1 lukem echo "Adding a non-unique record..."
213 1.1 lukem $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
214 1.1 lukem $TESTOUT 2>&1 << EOTUNIQ2
215 1.1 lukem dn: uid=bill,ou=users,o=unique
216 1.1 lukem objectClass: inetOrgPerson
217 1.1 lukem uid: bill
218 1.1 lukem sn: johnson
219 1.1 lukem cn: bill
220 1.1 lukem businessCategory: rtest
221 1.1 lukem carLicense: ABC123
222 1.1 lukem departmentNumber: 42
223 1.1 lukem displayName: Bill
224 1.1 lukem employeeNumber: 5150
225 1.1 lukem employeeType: contractor
226 1.1 lukem givenName: Bill
227 1.1 lukem EOTUNIQ2
228 1.1 lukem RC=$?
229 1.1.1.3 adam if test $RC != $RCODEconstraint ; then
230 1.1 lukem echo "unique check failed ($RC)!"
231 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
232 1.1 lukem exit -1
233 1.1 lukem fi
234 1.1 lukem
235 1.1 lukem echo Trying a legacy base outside of the backend...
236 1.1 lukem $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
237 1.1 lukem > $TESTOUT 2>&1 <<EOF
238 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
239 1.1 lukem changetype: modify
240 1.1 lukem add: olcUniqueBase
241 1.1 lukem olcUniqueBase: cn=config
242 1.1 lukem EOF
243 1.1 lukem RC=$?
244 1.1 lukem if test $RC != 80 ; then
245 1.1 lukem echo "out of backend scope base allowed"
246 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
247 1.1 lukem exit -1
248 1.1 lukem fi
249 1.1 lukem
250 1.1 lukem echo "Adding and removing attrs..."
251 1.1 lukem $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
252 1.1 lukem > $TESTOUT 2>&1 <<EOF
253 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
254 1.1 lukem changetype: modify
255 1.1 lukem add: olcUniqueAttribute
256 1.1 lukem olcUniqueAttribute: description
257 1.1 lukem olcUniqueAttribute: telephoneNumber
258 1.1 lukem -
259 1.1 lukem delete: olcUniqueAttribute
260 1.1 lukem olcUniqueAttribute: displayName
261 1.1 lukem EOF
262 1.1 lukem RC=$?
263 1.1 lukem if test $RC != 0 ; then
264 1.1 lukem echo "Unable to remove an attribute"
265 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
266 1.1 lukem exit -1
267 1.1 lukem fi
268 1.1 lukem
269 1.1 lukem echo "Verifying we removed the right attr..."
270 1.1 lukem $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
271 1.1 lukem $TESTOUT 2>&1 << EOTUNIQ2
272 1.1 lukem dn: uid=bill,ou=users,o=unique
273 1.1 lukem objectClass: inetOrgPerson
274 1.1 lukem uid: bill
275 1.1 lukem sn: johnson
276 1.1 lukem cn: bill
277 1.1 lukem businessCategory: rtest
278 1.1 lukem carLicense: ABC123
279 1.1 lukem departmentNumber: 42
280 1.1 lukem displayName: Bill
281 1.1 lukem employeeNumber: 5150
282 1.1 lukem employeeType: contractor
283 1.1 lukem givenName: Bill
284 1.1 lukem EOTUNIQ2
285 1.1 lukem RC=$?
286 1.1.1.3 adam if test $RC != $RCODEconstraint ; then
287 1.1 lukem echo "olcUniqueAttribtue single deletion hit the wrong value"
288 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
289 1.1 lukem exit -1
290 1.1 lukem fi
291 1.1 lukem
292 1.1 lukem echo Removing legacy config and adding URIs...
293 1.1 lukem $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
294 1.1 lukem > $TESTOUT 2>&1 <<EOF
295 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
296 1.1 lukem changetype: modify
297 1.1 lukem delete: olcUniqueAttribute
298 1.1 lukem -
299 1.1 lukem add: olcUniqueURI
300 1.1 lukem olcUniqueURI: ldap:///?employeeNumber,displayName?sub
301 1.1 lukem olcUniqueURI: ldap:///?description?one
302 1.1 lukem EOF
303 1.1 lukem RC=$?
304 1.1 lukem if test $RC != 0 ; then
305 1.1 lukem echo "Reconfiguration to URIs failed"
306 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
307 1.1 lukem exit -1
308 1.1 lukem fi
309 1.1 lukem
310 1.1 lukem echo Dynamically retrieving second configuration...
311 1.1 lukem $LDAPSEARCH -S "" -b olcOverlay='{0}'unique,olcDatabase='{1}'$BACKEND,cn=config -D cn=config -y $CONFIGPWF -h $LOCALHOST -p $PORT1 -LLL | tr -d \\r >$TESTDIR/second-config.ldif
312 1.1 lukem cat >$TESTDIR/second-reference.ldif <<EOF
313 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
314 1.1 lukem objectClass: olcOverlayConfig
315 1.1 lukem objectClass: olcUniqueConfig
316 1.1 lukem olcOverlay: {0}unique
317 1.1 lukem olcUniqueURI: ldap:///?employeeNumber,displayName?sub
318 1.1 lukem olcUniqueURI: ldap:///?description?one
319 1.1 lukem
320 1.1 lukem EOF
321 1.1 lukem diff $TESTDIR/second-config.ldif $TESTDIR/second-reference.ldif > /dev/null 2>&1
322 1.1 lukem RC=$?
323 1.1 lukem if test $RC != 0 ; then
324 1.1 lukem echo "Second configuration is not reported correctly."
325 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
326 1.1 lukem exit -1
327 1.1 lukem fi
328 1.1 lukem
329 1.1 lukem echo "Adding a non-unique record..."
330 1.1 lukem $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
331 1.1 lukem $TESTOUT 2>&1 << EOTUNIQ2
332 1.1 lukem dn: uid=bill,ou=users,o=unique
333 1.1 lukem objectClass: inetOrgPerson
334 1.1 lukem uid: bill
335 1.1 lukem sn: johnson
336 1.1 lukem cn: bill
337 1.1 lukem businessCategory: rtest
338 1.1 lukem carLicense: ABC123
339 1.1 lukem departmentNumber: 42
340 1.1 lukem displayName: Bill
341 1.1 lukem employeeNumber: 5150
342 1.1 lukem employeeType: contractor
343 1.1 lukem givenName: Bill
344 1.1 lukem EOTUNIQ2
345 1.1 lukem RC=$?
346 1.1.1.3 adam if test $RC != $RCODEconstraint ; then
347 1.1 lukem echo "unique check failed ($RC)!"
348 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
349 1.1 lukem exit -1
350 1.1 lukem fi
351 1.1 lukem
352 1.1 lukem echo Dynamically trying to add legacy base
353 1.1 lukem $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
354 1.1 lukem > $TESTOUT 2>&1 <<EOF
355 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
356 1.1 lukem changetype: modify
357 1.1 lukem add: olcUniqueBase
358 1.1 lukem olcUniqueBase: o=unique
359 1.1 lukem EOF
360 1.1 lukem RC=$?
361 1.1 lukem if test $RC != 80 ; then
362 1.1 lukem echo "legacy base allowed with URIs"
363 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
364 1.1 lukem exit -1
365 1.1 lukem fi
366 1.1 lukem
367 1.1 lukem echo Dynamically trying to add legacy attrs
368 1.1 lukem $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
369 1.1 lukem > $TESTOUT 2>&1 <<EOF
370 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
371 1.1 lukem changetype: modify
372 1.1 lukem add: olcUniqueAttribute
373 1.1 lukem olcUniqueAttribute: description
374 1.1 lukem EOF
375 1.1 lukem RC=$?
376 1.1 lukem if test $RC != 80 ; then
377 1.1 lukem echo "legacy attributes allowed with URIs"
378 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
379 1.1 lukem exit -1
380 1.1 lukem fi
381 1.1 lukem
382 1.1 lukem echo Dynamically trying to add legacy strictness
383 1.1 lukem $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
384 1.1 lukem > $TESTOUT 2>&1 <<EOF
385 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
386 1.1 lukem changetype: modify
387 1.1 lukem add: olcUniqueStrict
388 1.1 lukem olcUniqueStrict: TRUE
389 1.1 lukem EOF
390 1.1 lukem RC=$?
391 1.1 lukem if test $RC != 80 ; then
392 1.1 lukem echo "legacy strictness allowed with URIs"
393 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
394 1.1 lukem exit -1
395 1.1 lukem fi
396 1.1 lukem
397 1.1 lukem #echo ----------------------
398 1.1 lukem echo Dynamically trying a bad filter...
399 1.1 lukem $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
400 1.1 lukem > $TESTOUT 2>&1 <<EOF
401 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
402 1.1 lukem changetype: modify
403 1.1 lukem replace: olcUniqueURI
404 1.1 lukem olcUniqueURI: ldap:///?sn?sub?((cn=e*))
405 1.1 lukem EOF
406 1.1 lukem RC=$?
407 1.1 lukem if test $RC != 80 ; then
408 1.1 lukem echo "bad filter allowed"
409 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
410 1.1 lukem exit -1
411 1.1 lukem fi
412 1.1 lukem
413 1.1 lukem echo Verifying second configuration intact...
414 1.1 lukem $LDAPSEARCH -S "" -b olcOverlay='{0}'unique,olcDatabase='{1}'$BACKEND,cn=config -D cn=config -y $CONFIGPWF -h $LOCALHOST -p $PORT1 -LLL | tr -d \\r >$TESTDIR/second-config-recheck.ldif
415 1.1 lukem diff $TESTDIR/second-config-recheck.ldif $TESTDIR/second-reference.ldif > /dev/null 2>&1
416 1.1 lukem RC=$?
417 1.1 lukem if test $RC != 0 ; then
418 1.1 lukem echo "Second configuration damaged by rejected modifies."
419 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
420 1.1 lukem exit -1
421 1.1 lukem fi
422 1.1 lukem
423 1.1 lukem #echo ----------------------
424 1.1 lukem echo Dynamically reconfiguring to use different URIs...
425 1.1 lukem $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
426 1.1 lukem > $TESTOUT 2>&1 <<EOF
427 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
428 1.1 lukem changetype: modify
429 1.1 lukem add: olcUniqueURI
430 1.1 lukem olcUniqueURI: ldap:///?sn?sub?(cn=e*)
431 1.1.1.2 lukem olcUniqueURI: ldap:///?uid?sub?(cn=edgar)
432 1.1 lukem -
433 1.1 lukem delete: olcUniqueURI
434 1.1 lukem olcUniqueURI: ldap:///?description?one
435 1.1 lukem EOF
436 1.1 lukem RC=$?
437 1.1 lukem if test $RC != 0 ; then
438 1.1 lukem echo "unable to reconfigure"
439 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
440 1.1 lukem exit -1
441 1.1 lukem fi
442 1.1 lukem
443 1.1 lukem echo Dynamically retrieving third configuration...
444 1.1 lukem $LDAPSEARCH -S "" -b olcOverlay='{0}'unique,olcDatabase='{1}'$BACKEND,cn=config -D cn=config -y $CONFIGPWF -h $LOCALHOST -p $PORT1 -LLL | tr -d \\r >$TESTDIR/third-config.ldif
445 1.1 lukem cat >$TESTDIR/third-reference.ldif <<EOF
446 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
447 1.1 lukem objectClass: olcOverlayConfig
448 1.1 lukem objectClass: olcUniqueConfig
449 1.1 lukem olcOverlay: {0}unique
450 1.1 lukem olcUniqueURI: ldap:///?employeeNumber,displayName?sub
451 1.1 lukem olcUniqueURI: ldap:///?sn?sub?(cn=e*)
452 1.1.1.2 lukem olcUniqueURI: ldap:///?uid?sub?(cn=edgar)
453 1.1 lukem
454 1.1 lukem EOF
455 1.1 lukem diff $TESTDIR/third-config.ldif $TESTDIR/third-reference.ldif > /dev/null 2>&1
456 1.1 lukem RC=$?
457 1.1 lukem if test $RC != 0 ; then
458 1.1 lukem echo "Third configuration is not reported correctly."
459 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
460 1.1 lukem exit -1
461 1.1 lukem fi
462 1.1 lukem
463 1.1 lukem echo "Adding a record unique in both domains if filtered..."
464 1.1 lukem
465 1.1 lukem $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
466 1.1 lukem $TESTOUT 2>&1 << EOF
467 1.1 lukem dn: uid=edgar,ou=users,o=unique
468 1.1 lukem objectClass: inetOrgPerson
469 1.1 lukem uid: edgar
470 1.1 lukem sn: johnson
471 1.1 lukem cn: edgar
472 1.1 lukem EOF
473 1.1 lukem
474 1.1 lukem RC=$?
475 1.1 lukem if test $RC != 0 ; then
476 1.1 lukem echo "unique check failed ($RC)!"
477 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
478 1.1 lukem exit -1
479 1.1 lukem fi
480 1.1 lukem
481 1.1.1.2 lukem echo "Adding a record unique in all domains because of filter conditions "
482 1.1.1.2 lukem $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
483 1.1.1.2 lukem $TESTOUT 2>&1 << EOF
484 1.1.1.2 lukem dn: uid=empty,ou=users,o=unique
485 1.1.1.2 lukem objectClass: inetOrgPerson
486 1.1.1.2 lukem uid: edgar
487 1.1.1.2 lukem cn: empty
488 1.1.1.2 lukem sn: empty
489 1.1.1.2 lukem EOF
490 1.1.1.2 lukem
491 1.1.1.2 lukem RC=$?
492 1.1.1.2 lukem if test $RC != 0 ; then
493 1.1.1.2 lukem echo "spurious unique error ($RC)!"
494 1.1.1.2 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
495 1.1.1.2 lukem exit -1
496 1.1.1.2 lukem fi
497 1.1.1.2 lukem
498 1.1.1.2 lukem
499 1.1 lukem echo "Adding a record unique in one domain, non-unique in the filtered domain..."
500 1.1 lukem
501 1.1 lukem $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
502 1.1 lukem $TESTOUT 2>&1 << EOF
503 1.1 lukem dn: uid=elvis,ou=users,o=unique
504 1.1 lukem objectClass: inetOrgPerson
505 1.1 lukem uid: elvis
506 1.1 lukem sn: johnson
507 1.1 lukem cn: elvis
508 1.1 lukem EOF
509 1.1 lukem
510 1.1 lukem RC=$?
511 1.1.1.3 adam if test $RC != $RCODEconstraint ; then
512 1.1 lukem echo "unique check failed ($RC)!"
513 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
514 1.1 lukem exit -1
515 1.1 lukem fi
516 1.1 lukem
517 1.1 lukem #echo ----------------------
518 1.1 lukem echo Dynamically reconfiguring to use attribute-ignore URIs...
519 1.1 lukem $LDAPMODIFY -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF \
520 1.1 lukem > $TESTOUT 2>&1 <<EOF
521 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
522 1.1 lukem changetype: modify
523 1.1 lukem replace: olcUniqueURI
524 1.1 lukem olcUniqueURI: ignore ldap:///?objectClass,uid,cn,sn?sub
525 1.1 lukem EOF
526 1.1 lukem RC=$?
527 1.1 lukem if test $RC != 0 ; then
528 1.1 lukem echo "unable to reconfigure"
529 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
530 1.1 lukem exit -1
531 1.1 lukem fi
532 1.1 lukem
533 1.1 lukem echo Dynamically retrieving fourth configuration...
534 1.1 lukem $LDAPSEARCH -S "" -b olcOverlay='{0}'unique,olcDatabase='{1}'$BACKEND,cn=config -D cn=config -y $CONFIGPWF -h $LOCALHOST -p $PORT1 -LLL | tr -d \\r >$TESTDIR/fourth-config.ldif
535 1.1 lukem cat >$TESTDIR/fourth-reference.ldif <<EOF
536 1.1 lukem dn: olcOverlay={0}unique,olcDatabase={1}$BACKEND,cn=config
537 1.1 lukem objectClass: olcOverlayConfig
538 1.1 lukem objectClass: olcUniqueConfig
539 1.1 lukem olcOverlay: {0}unique
540 1.1 lukem olcUniqueURI: ignore ldap:///?objectClass,uid,cn,sn?sub
541 1.1 lukem
542 1.1 lukem EOF
543 1.1 lukem diff $TESTDIR/fourth-config.ldif $TESTDIR/fourth-reference.ldif > /dev/null 2>&1
544 1.1 lukem RC=$?
545 1.1 lukem if test $RC != 0 ; then
546 1.1 lukem echo "Fourth configuration is not reported correctly."
547 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
548 1.1 lukem exit -1
549 1.1 lukem fi
550 1.1 lukem
551 1.1 lukem echo "Adding a record unique in the ignore-domain..."
552 1.1 lukem
553 1.1 lukem $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
554 1.1 lukem $TESTOUT 2>&1 << EOF
555 1.1 lukem dn: uid=elvis,ou=users,o=unique
556 1.1 lukem objectClass: inetOrgPerson
557 1.1 lukem uid: elvis
558 1.1 lukem sn: johnson
559 1.1 lukem cn: elvis
560 1.1 lukem description: left the building
561 1.1 lukem EOF
562 1.1 lukem
563 1.1 lukem RC=$?
564 1.1 lukem if test $RC != 0 ; then
565 1.1 lukem echo "unique check failed ($RC)!"
566 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
567 1.1 lukem exit -1
568 1.1 lukem fi
569 1.1 lukem
570 1.1 lukem echo "Adding a record non-unique in the ignore-domain..."
571 1.1 lukem
572 1.1 lukem $LDAPADD -D "$UNIQUEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
573 1.1 lukem $TESTOUT 2>&1 << EOF
574 1.1 lukem dn: uid=harry,ou=users,o=unique
575 1.1 lukem objectClass: inetOrgPerson
576 1.1 lukem uid: harry
577 1.1 lukem sn: johnson
578 1.1 lukem cn: harry
579 1.1 lukem description: left the building
580 1.1 lukem EOF
581 1.1 lukem
582 1.1 lukem RC=$?
583 1.1.1.3 adam if test $RC != $RCODEconstraint ; then
584 1.1 lukem echo "unique check failed ($RC)!"
585 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
586 1.1 lukem exit -1
587 1.1 lukem fi
588 1.1 lukem
589 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
590 1.1 lukem
591 1.1 lukem echo ">>>>> Test succeeded"
592 1.1 lukem
593 1.1 lukem test $KILLSERVERS != no && wait
594 1.1 lukem
595 1.1 lukem exit 0
596