3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2005 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $BACKLDAP = "ldapno" ; then
20 echo "LDAP backend not available, test skipped"
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
26 echo "Running slapadd to build slapd database..."
27 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF1 > $ADDCONF
28 . $CONFFILTER < $LDIFCHAIN1 > $SEARCHOUT
29 $SLAPADD -f $ADDCONF -l $SEARCHOUT
31 if test $RC != 0 ; then
32 echo "slapadd 1 failed ($RC)!"
36 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF2 > $ADDCONF
37 . $CONFFILTER < $LDIFCHAIN2 > $SEARCHOUT
38 $SLAPADD -f $ADDCONF -l $SEARCHOUT
40 if test $RC != 0 ; then
41 echo "slapadd 2 failed ($RC)!"
45 echo "Starting first slapd on TCP/IP port $PORT1..."
46 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF1 > $CONF1
47 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
49 if test $WAIT != 0 ; then
54 echo "Starting second slapd on TCP/IP port $PORT2..."
55 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF2 > $CONF2
56 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
58 if test $WAIT != 0 ; then
63 KILLPIDS="$PID1 $PID2"
65 echo "Using ldapsearch to check that first slapd is running..."
66 for i in 0 1 2 3 4 5; do
67 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
68 'objectclass=*' > /dev/null 2>&1
70 if test $RC = 0 ; then
73 echo "Waiting 5 seconds for slapd to start..."
77 echo "Using ldapsearch to check that second slapd is running..."
78 for i in 0 1 2 3 4 5; do
79 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
80 'objectclass=*' > /dev/null 2>&1
82 if test $RC = 0 ; then
85 echo "Waiting 5 seconds for slapd to start..."
89 for P in $PORT1 $PORT2 ; do
90 echo "Testing ldapsearch as anonymous for \"$BASEDN\" on port $P..."
91 $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASEDN" -S "" \
95 if test $RC != 0 ; then
96 echo "ldapsearch failed ($RC)!"
97 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101 echo "Filtering ldapsearch results..."
102 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
103 echo "Filtering original ldif used to create database..."
104 . $LDIFFILTER < $CHAINOUT > $LDIFFLT
105 echo "Comparing filter output..."
106 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
108 if test $? != 0 ; then
109 echo "comparison failed - chained search didn't succeed"
110 test $KILLSERVERS != no && kill -HUP $KILLPIDS
116 # Testing writes to first server
118 echo "Writing to first server with scope on second server..."
119 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
120 $TESTOUT 2>&1 << EOMODS
121 dn: cn=New Group,ou=Groups,dc=example,dc=com
123 objectClass: groupOfNames
127 dn: cn=New Group,ou=Groups,dc=example,dc=com
130 description: testing chain overlay writes...
133 member: cn=New Group,ou=Groups,dc=example,dc=com
134 member: cn=Manager,dc=example,dc=com
137 owner: cn=Manager,dc=example,dc=com
140 dn: cn=New Group,ou=Groups,dc=example,dc=com
142 newrdn: cn=Renamed Group
145 dn: cn=All Staff,ou=Groups,dc=example,dc=com
150 if test $RC != 0 ; then
151 echo "ldapmodify failed ($RC)!"
152 test $KILLSERVERS != no && kill -HUP $KILLPIDS
157 # Testing writes to second server
159 echo "Writing to second server with scope on first server..."
160 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
161 $TESTOUT 2>&1 << EOMODS
162 dn: cn=New User,ou=People,dc=example,dc=com
167 seeAlso: cn=New Group,ou=Groups,dc=example,dc=com
169 dn: cn=New User,ou=People,dc=example,dc=com
172 description: testing chain overlay writes...
175 seeAlso: cn=Renamed Group,ou=Groups,dc=example,dc=com
178 dn: cn=New User,ou=People,dc=example,dc=com
180 newrdn: cn=Renamed User
183 dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
188 if test $RC != 0 ; then
189 echo "ldapmodify failed ($RC)!"
190 test $KILLSERVERS != no && kill -HUP $KILLPIDS
194 for P in $PORT1 $PORT2 ; do
195 echo "Testing ldapsearch as anonymous for \"$BASEDN\" on port $P..."
196 $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASEDN" -S "" \
200 if test $RC != 0 ; then
201 echo "ldapsearch failed ($RC)!"
202 test $KILLSERVERS != no && kill -HUP $KILLPIDS
206 echo "Filtering ldapsearch results..."
207 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
208 echo "Filtering original ldif used to create database..."
209 . $LDIFFILTER < $CHAINMODOUT > $LDIFFLT
210 echo "Comparing filter output..."
211 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
213 if test $? != 0 ; then
214 echo "comparison failed - chained search didn't succeed"
215 test $KILLSERVERS != no && kill -HUP $KILLPIDS
221 echo "Using ldappasswd on second server with scope on first server..."
222 $LDAPPASSWD -h $LOCALHOST -p $PORT2 \
223 -w secret -s $NEWPW \
224 -D "$MANAGERDN" "$BJORNSDN" >> $TESTOUT 2>&1
226 if test $RC != 0 ; then
227 echo "ldappasswd failed ($RC)!"
228 test $KILLSERVERS != no && kill -HUP $KILLPIDS
232 echo "Binding with newly changed password on first server..."
233 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
234 -D "$BJORNSDN" -w $NEWPW
236 if test $RC != 0 ; then
237 echo "ldapwhoami failed ($RC)!"
238 test $KILLSERVERS != no && kill -HUP $KILLPIDS
242 test $KILLSERVERS != no && kill -HUP $KILLPIDS
244 echo ">>>>> Test succeeded"