3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2009 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 case $BACKEND in bdb | null)
31 # BDB lacks subtree rename, NULL lacks cn=config support
32 echo "Test does not support $BACKEND, test skipped"
36 mkdir -p $TESTDIR $DBDIR1 $TESTDIR/confdir
38 $SLAPPASSWD -g -n >$CONFIGPWF
39 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
41 echo "Starting slapd on TCP/IP port $PORT1..."
42 . $CONFFILTER $BACKEND $MONITORDB < $NAKEDCONF > $CONF1
43 $SLAPD -f $CONF1 -F $TESTDIR/confdir -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
45 if test $WAIT != 0 ; then
52 for i in 0 1 2 3 4 5; do
53 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
54 'objectclass=*' > /dev/null 2>&1
56 if test $RC = 0 ; then
59 echo "Waiting 5 seconds for slapd to start..."
62 if test $RC != 0 ; then
63 echo "ldapsearch failed ($RC)!"
64 test $KILLSERVERS != no && kill -HUP $KILLPIDS
68 cat /dev/null > $TESTOUT
70 if [ "$MEMBEROF" = memberofmod ]; then
71 echo "Inserting memberof overlay on producer..."
72 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
73 dn: cn=module,cn=config
74 objectClass: olcModuleList
76 olcModulePath: ../servers/slapd/overlays
77 olcModuleLoad: memberof.la
78 olcModuleLoad: refint.la
81 if test $RC != 0 ; then
82 echo "ldapadd failed for moduleLoad ($RC)!"
83 test $KILLSERVERS != no && kill -HUP $KILLPIDS
89 case $BACKEND in bdb | hdb)
90 bdb_conf="olcDbCacheSize: 1000
91 olcDbIndex: objectClass eq
92 olcDbIndex: cn pres,eq,sub
93 olcDbIndex: uid pres,eq,sub
94 olcDbIndex: sn pres,eq,sub
98 echo "Running ldapadd to build slapd config database..."
99 $LDAPADD -h $LOCALHOST -p $PORT1 -D 'cn=config' -w `cat $CONFIGPWF` \
100 >> $TESTOUT 2>&1 <<EOF
101 dn: olcDatabase={1}$BACKEND,cn=config
102 objectClass: olcDatabaseConfig
103 objectClass: olc${BACKEND}Config
104 olcDatabase: {1}$BACKEND
106 olcRootDN: cn=Manager,$BASEDN
109 olcDbDirectory: $TESTDIR/db.1.a/
112 # {0}memberof, {1}$BACKEND, config
113 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
114 objectClass: olcOverlayConfig
115 objectClass: olcMemberOf
116 olcOverlay: {0}memberof
117 olcMemberOfRefInt: TRUE
118 olcMemberOfGroupOC: groupOfNames
119 olcMemberOfMemberAD: member
120 olcMemberOfMemberOfAD: memberOf
122 # {1}refint, {1}$BACKEND, config
123 dn: olcOverlay={1}refint,olcDatabase={1}$BACKEND,cn=config
124 objectClass: olcOverlayConfig
125 objectClass: olcRefintConfig
126 olcOverlay: {1}refint
127 olcRefintAttribute: member
128 olcRefintAttribute: memberOf
131 if test $RC != 0 ; then
132 echo "ldapadd failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 echo "Running ldapadd to build slapd database..."
138 $LDAPADD -h $LOCALHOST -p $PORT1 \
139 -D "cn=Manager,$BASEDN" -w secret \
140 >> $TESTOUT 2>&1 << EOF
142 objectClass: organization
143 objectClass: dcObject
147 dn: ou=People,$BASEDN
148 objectClass: organizationalUnit
151 dn: ou=Groups,$BASEDN
152 objectClass: organizationalUnit
155 dn: cn=Roger Rabbit,ou=People,$BASEDN
156 objectClass: inetOrgPerson
160 dn: cn=Baby Herman,ou=People,$BASEDN
161 objectClass: inetOrgPerson
165 dn: cn=Cartoonia,ou=Groups,$BASEDN
166 objectClass: groupOfNames
168 member: cn=Roger Rabbit,ou=People,$BASEDN
169 member: cn=Baby Herman,ou=People,$BASEDN
172 if test $RC != 0 ; then
173 echo "ldapadd failed ($RC)!"
174 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178 echo "Search the entire database..."
179 echo "# Search the entire database..." >> $SEARCHOUT
180 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
181 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
183 if test $RC != 0 ; then
184 echo "ldapsearch failed ($RC)!"
185 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189 echo "Running ldapmodify to rename subtree..."
190 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
191 -D "cn=Manager,$BASEDN" -w secret \
192 >> $TESTOUT 2>&1 << EOF
193 dn: ou=People,$BASEDN
200 # refint runs in a background thread, so it most likely won't complete
201 # before the modify returns. Give it some time to execute.
204 echo "Re-search the entire database..."
205 echo "# Re-search the entire database..." >> $SEARCHOUT
206 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
207 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
209 if test $RC != 0 ; then
210 echo "ldapsearch failed ($RC)!"
211 test $KILLSERVERS != no && kill -HUP $KILLPIDS
215 echo "Running ldapmodify to rename subtree..."
216 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
217 -D "cn=Manager,$BASEDN" -w secret \
218 >> $TESTOUT 2>&1 << EOF
219 dn: ou=Groups,$BASEDN
228 echo "Re-search the entire database..."
229 echo "# Re-search the entire database..." >> $SEARCHOUT
230 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
231 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
233 if test $RC != 0 ; then
234 echo "ldapsearch failed ($RC)!"
235 test $KILLSERVERS != no && kill -HUP $KILLPIDS
239 echo "Running ldapdelete to remove a member..."
240 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
241 -D "cn=Manager,$BASEDN" -w secret \
242 >> $TESTOUT 2>&1 << EOF
243 dn: cn=Baby Herman,ou=Toons,$BASEDN
249 echo "Re-search the entire database..."
250 echo "# Re-search the entire database..." >> $SEARCHOUT
251 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
252 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
254 if test $RC != 0 ; then
255 echo "ldapsearch failed ($RC)!"
256 test $KILLSERVERS != no && kill -HUP $KILLPIDS
260 test $KILLSERVERS != no && kill -HUP $KILLPIDS
262 LDIF=$MEMBEROFREFINTOUT
264 echo "Filtering ldapsearch results..."
265 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
266 echo "Filtering original ldif used to create database..."
267 $LDIFFILTER < $LDIF > $LDIFFLT
268 echo "Comparing filter output..."
269 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
271 if test $? != 0 ; then
272 echo "Comparison failed"
276 echo ">>>>> Test succeeded"
278 test $KILLSERVERS != no && wait