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