3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2017 The OpenLDAP Foundation.
6 ## Portions Copyright 2008 Red Hat, Inc.
7 ## All rights reserved.
9 ## Redistribution and use in source and binary forms, with or without
10 ## modification, are permitted only as authorized by the OpenLDAP
13 ## A copy of this license is available in the file LICENSE in the
14 ## top-level directory of the distribution or, alternatively, at
15 ## <http://www.OpenLDAP.org/license.html>.
17 echo "running defines.sh"
18 . $SRCDIR/scripts/defines.sh
20 if test $MEMBEROF = memberofno; then
21 echo "Memberof overlay not available, test skipped"
25 if test $REFINT = refintno; then
26 echo "Referential Integrity overlay not available, test skipped"
30 if test $BACKEND = bdb; then
31 echo "$BACKEND backend does not support subtree rename, test skipped"
35 mkdir -p $TESTDIR $DBDIR1 $TESTDIR/confdir
37 $SLAPPASSWD -g -n >$CONFIGPWF
38 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
40 echo "Starting slapd on TCP/IP port $PORT1..."
41 . $CONFFILTER $BACKEND $MONITORDB < $NAKEDCONF > $CONF1
42 $SLAPD -f $CONF1 -F $TESTDIR/confdir -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
44 if test $WAIT != 0 ; then
51 for i in 0 1 2 3 4 5; do
52 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
53 'objectclass=*' > /dev/null 2>&1
55 if test $RC = 0 ; then
58 echo "Waiting 5 seconds for slapd to start..."
61 if test $RC != 0 ; then
62 echo "ldapsearch failed ($RC)!"
63 test $KILLSERVERS != no && kill -HUP $KILLPIDS
67 cat /dev/null > $TESTOUT
69 indexInclude="" mainInclude="" bdbInclude="# " nullExclude=""
70 test $INDEXDB = indexdb || indexInclude="# "
71 test $MAINDB = maindb || mainInclude="# "
73 bdb | hdb) bdbInclude="" ;;
74 null) nullExclude="# " ;;
77 if [ "$MEMBEROF" = memberofmod ]; then
78 echo "Inserting memberof overlay on provider..."
79 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
80 dn: cn=module,cn=config
81 objectClass: olcModuleList
83 olcModulePath: ../servers/slapd/overlays
84 olcModuleLoad: memberof.la
85 olcModuleLoad: refint.la
88 if test $RC != 0 ; then
89 echo "ldapadd failed for moduleLoad ($RC)!"
90 test $KILLSERVERS != no && kill -HUP $KILLPIDS
95 echo "Running ldapadd to build slapd config database..."
96 $LDAPADD -h $LOCALHOST -p $PORT1 -D 'cn=config' -w `cat $CONFIGPWF` \
97 >> $TESTOUT 2>&1 <<EOF
98 dn: olcDatabase={1}$BACKEND,cn=config
99 objectClass: olcDatabaseConfig
100 ${nullExclude}objectClass: olc${BACKEND}Config
101 olcDatabase: {1}$BACKEND
103 olcRootDN: cn=Manager,$BASEDN
106 ${nullExclude}olcDbDirectory: $TESTDIR/db.1.a/
107 ${bdbInclude}olcDbCacheSize: 1000
108 ${indexInclude}olcDbIndex: objectClass eq
109 ${indexInclude}olcDbIndex: cn pres,eq,sub
110 ${indexInclude}olcDbIndex: uid pres,eq,sub
111 ${indexInclude}olcDbIndex: sn pres,eq,sub
112 ${mainInclude}olcDbMode: 384
114 # {0}memberof, {1}$BACKEND, config
115 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
116 objectClass: olcOverlayConfig
117 objectClass: olcMemberOf
118 olcOverlay: {0}memberof
119 olcMemberOfRefInt: TRUE
120 olcMemberOfGroupOC: groupOfNames
121 olcMemberOfMemberAD: member
122 olcMemberOfMemberOfAD: memberOf
124 # {1}refint, {1}$BACKEND, config
125 dn: olcOverlay={1}refint,olcDatabase={1}$BACKEND,cn=config
126 objectClass: olcOverlayConfig
127 objectClass: olcRefintConfig
128 olcOverlay: {1}refint
129 olcRefintAttribute: member
130 olcRefintAttribute: memberOf
133 if test $RC != 0 ; then
134 echo "ldapadd failed ($RC)!"
135 test $KILLSERVERS != no && kill -HUP $KILLPIDS
139 echo "Running ldapadd to build slapd database..."
140 $LDAPADD -h $LOCALHOST -p $PORT1 \
141 -D "cn=Manager,$BASEDN" -w secret \
142 >> $TESTOUT 2>&1 << EOF
144 objectClass: organization
145 objectClass: dcObject
149 dn: ou=People,$BASEDN
150 objectClass: organizationalUnit
153 dn: ou=Groups,$BASEDN
154 objectClass: organizationalUnit
157 dn: cn=Roger Rabbit,ou=People,$BASEDN
158 objectClass: inetOrgPerson
162 dn: cn=Baby Herman,ou=People,$BASEDN
163 objectClass: inetOrgPerson
167 dn: cn=Cartoonia,ou=Groups,$BASEDN
168 objectClass: groupOfNames
170 member: cn=Roger Rabbit,ou=People,$BASEDN
171 member: cn=Baby Herman,ou=People,$BASEDN
174 if test $RC != 0 ; then
175 echo "ldapadd failed ($RC)!"
176 test $KILLSERVERS != no && kill -HUP $KILLPIDS
180 echo "Search the entire database..."
181 echo "# Search the entire database..." >> $SEARCHOUT
182 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
183 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
185 if test $RC != 0 ; then
186 echo "ldapsearch failed ($RC)!"
187 test $KILLSERVERS != no && kill -HUP $KILLPIDS
191 echo "Running ldapmodify to rename subtree..."
192 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
193 -D "cn=Manager,$BASEDN" -w secret \
194 >> $TESTOUT 2>&1 << EOF
195 dn: ou=People,$BASEDN
202 # refint runs in a background thread, so it most likely won't complete
203 # before the modify returns. Give it some time to execute.
206 echo "Re-search the entire database..."
207 echo "# Re-search the entire database..." >> $SEARCHOUT
208 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
209 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
211 if test $RC != 0 ; then
212 echo "ldapsearch failed ($RC)!"
213 test $KILLSERVERS != no && kill -HUP $KILLPIDS
217 echo "Running ldapmodify to rename subtree..."
218 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
219 -D "cn=Manager,$BASEDN" -w secret \
220 >> $TESTOUT 2>&1 << EOF
221 dn: ou=Groups,$BASEDN
230 echo "Re-search the entire database..."
231 echo "# Re-search the entire database..." >> $SEARCHOUT
232 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
233 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
235 if test $RC != 0 ; then
236 echo "ldapsearch failed ($RC)!"
237 test $KILLSERVERS != no && kill -HUP $KILLPIDS
241 echo "Running ldapdelete to remove a member..."
242 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
243 -D "cn=Manager,$BASEDN" -w secret \
244 >> $TESTOUT 2>&1 << EOF
245 dn: cn=Baby Herman,ou=Toons,$BASEDN
251 echo "Re-search the entire database..."
252 echo "# Re-search the entire database..." >> $SEARCHOUT
253 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
254 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
256 if test $RC != 0 ; then
257 echo "ldapsearch failed ($RC)!"
258 test $KILLSERVERS != no && kill -HUP $KILLPIDS
262 test $KILLSERVERS != no && kill -HUP $KILLPIDS
264 LDIF=$MEMBEROFREFINTOUT
266 echo "Filtering ldapsearch results..."
267 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
268 echo "Filtering original ldif used to create database..."
269 $LDIFFILTER < $LDIF > $LDIFFLT
270 echo "Comparing filter output..."
271 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
273 if test $? != 0 ; then
274 echo "Comparison failed"
278 echo ">>>>> Test succeeded"
280 test $KILLSERVERS != no && wait