3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2010 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" != "hdb" ; then
31 echo "Test does not support $BACKEND"
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 if [ "$MEMBEROF" = memberofmod ]; then
70 echo "Inserting memberof overlay on producer..."
71 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
72 dn: cn=module,cn=config
73 objectClass: olcModuleList
75 olcModulePath: ../servers/slapd/overlays
76 olcModuleLoad: memberof.la
77 olcModuleLoad: refint.la
80 if test $RC != 0 ; then
81 echo "ldapadd failed for moduleLoad ($RC)!"
82 test $KILLSERVERS != no && kill -HUP $KILLPIDS
87 echo "Running ldapadd to build slapd config database..."
88 $LDAPADD -h $LOCALHOST -p $PORT1 -D 'cn=config' -w `cat $CONFIGPWF` \
89 >> $TESTOUT 2>&1 <<EOF
90 dn: olcDatabase={1}$BACKEND,cn=config
91 objectClass: olcDatabaseConfig
92 objectClass: olc${BACKEND}Config
93 olcDatabase: {1}$BACKEND
95 olcRootDN: cn=Manager,$BASEDN
98 olcDbDirectory: $TESTDIR/db.1.a/
100 olcDbIndex: objectClass eq
101 olcDbIndex: cn pres,eq,sub
102 olcDbIndex: uid pres,eq,sub
103 olcDbIndex: sn pres,eq,sub
106 # {0}memberof, {1}$BACKEND, config
107 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
108 objectClass: olcOverlayConfig
109 objectClass: olcMemberOf
110 olcOverlay: {0}memberof
111 olcMemberOfRefInt: TRUE
112 olcMemberOfGroupOC: groupOfNames
113 olcMemberOfMemberAD: member
114 olcMemberOfMemberOfAD: memberOf
116 # {1}refint, {1}$BACKEND, config
117 dn: olcOverlay={1}refint,olcDatabase={1}$BACKEND,cn=config
118 objectClass: olcOverlayConfig
119 objectClass: olcRefintConfig
120 olcOverlay: {1}refint
121 olcRefintAttribute: member
122 olcRefintAttribute: memberOf
125 if test $RC != 0 ; then
126 echo "ldapadd failed ($RC)!"
127 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 echo "Running ldapadd to build slapd database..."
132 $LDAPADD -h $LOCALHOST -p $PORT1 \
133 -D "cn=Manager,$BASEDN" -w secret \
134 >> $TESTOUT 2>&1 << EOF
136 objectClass: organization
137 objectClass: dcObject
141 dn: ou=People,$BASEDN
142 objectClass: organizationalUnit
145 dn: ou=Groups,$BASEDN
146 objectClass: organizationalUnit
149 dn: cn=Roger Rabbit,ou=People,$BASEDN
150 objectClass: inetOrgPerson
154 dn: cn=Baby Herman,ou=People,$BASEDN
155 objectClass: inetOrgPerson
159 dn: cn=Cartoonia,ou=Groups,$BASEDN
160 objectClass: groupOfNames
162 member: cn=Roger Rabbit,ou=People,$BASEDN
163 member: cn=Baby Herman,ou=People,$BASEDN
166 if test $RC != 0 ; then
167 echo "ldapadd failed ($RC)!"
168 test $KILLSERVERS != no && kill -HUP $KILLPIDS
172 echo "Search the entire database..."
173 echo "# Search the entire database..." >> $SEARCHOUT
174 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
175 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
177 if test $RC != 0 ; then
178 echo "ldapsearch failed ($RC)!"
179 test $KILLSERVERS != no && kill -HUP $KILLPIDS
183 echo "Running ldapmodify to rename subtree..."
184 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
185 -D "cn=Manager,$BASEDN" -w secret \
186 >> $TESTOUT 2>&1 << EOF
187 dn: ou=People,$BASEDN
194 # refint runs in a background thread, so it most likely won't complete
195 # before the modify returns. Give it some time to execute.
198 echo "Re-search the entire database..."
199 echo "# Re-search the entire database..." >> $SEARCHOUT
200 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
201 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
203 if test $RC != 0 ; then
204 echo "ldapsearch failed ($RC)!"
205 test $KILLSERVERS != no && kill -HUP $KILLPIDS
209 echo "Running ldapmodify to rename subtree..."
210 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
211 -D "cn=Manager,$BASEDN" -w secret \
212 >> $TESTOUT 2>&1 << EOF
213 dn: ou=Groups,$BASEDN
222 echo "Re-search the entire database..."
223 echo "# Re-search the entire database..." >> $SEARCHOUT
224 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
225 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
227 if test $RC != 0 ; then
228 echo "ldapsearch failed ($RC)!"
229 test $KILLSERVERS != no && kill -HUP $KILLPIDS
233 echo "Running ldapdelete to remove a member..."
234 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
235 -D "cn=Manager,$BASEDN" -w secret \
236 >> $TESTOUT 2>&1 << EOF
237 dn: cn=Baby Herman,ou=Toons,$BASEDN
243 echo "Re-search the entire database..."
244 echo "# Re-search the entire database..." >> $SEARCHOUT
245 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
246 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
248 if test $RC != 0 ; then
249 echo "ldapsearch failed ($RC)!"
250 test $KILLSERVERS != no && kill -HUP $KILLPIDS
254 test $KILLSERVERS != no && kill -HUP $KILLPIDS
256 LDIF=$MEMBEROFREFINTOUT
258 echo "Filtering ldapsearch results..."
259 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
260 echo "Filtering original ldif used to create database..."
261 . $LDIFFILTER < $LDIF > $LDIFFLT
262 echo "Comparing filter output..."
263 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
265 if test $? != 0 ; then
266 echo "Comparison failed"
270 echo ">>>>> Test succeeded"
272 test $KILLSERVERS != no && wait