3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2011 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 $BACKEND = bdb ; then
20 echo "subtree rename not supported by back-$BACKEND"
24 mkdir -p $TESTDIR $DBDIR1
26 echo "Starting slapd on TCP/IP port $PORT1..."
27 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
28 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
30 if test $WAIT != 0 ; then
38 echo "Testing slapd searching..."
39 for i in 0 1 2 3 4 5; do
40 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
41 '(objectclass=*)' > /dev/null 2>&1
43 if test $RC = 0 ; then
46 echo "Waiting 5 seconds for slapd to start..."
50 if test $RC != 0 ; then
51 echo "ldapsearch failed ($RC)!"
52 test $KILLSERVERS != no && kill -HUP $KILLPIDS
56 cat /dev/null > $TESTOUT
57 cat /dev/null > $SEARCHOUT
60 echo "Populating the database..."
61 echo "# Populating the database..." >> $TESTOUT
62 $LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
63 >> $TESTOUT 2>&1 << EOMODS0
65 objectClass: organization
70 dn: ou=Parent,dc=example,dc=com
71 objectClass: organizationalUnit
74 dn: ou=Another parent,dc=example,dc=com
75 objectClass: organizationalUnit
78 dn: ou=Child,ou=Parent,dc=example,dc=com
79 objectClass: organizationalUnit
82 dn: ou=Grandchild,ou=Child,ou=Parent,dc=example,dc=com
83 objectClass: organizationalUnit
87 if test $RC != 0 ; then
88 echo "ldapadd failed ($RC)!"
89 test $KILLSERVERS != no && kill -HUP $KILLPIDS
93 echo "Searching all database..."
94 echo "# Searching all database (after add)..." >> $SEARCHOUT
95 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
96 '(objectClass=*)' >> $SEARCHOUT 2>&1
98 if test $RC != 0 ; then
99 echo "ldapsearch failed ($RC)!"
100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
105 echo "Renaming (PASS1)..."
106 echo "# Renaming (PASS1)..." >> $TESTOUT
107 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
108 >> $TESTOUT 2>&1 << EOMODS1
109 dn: ou=Child,ou=Parent,dc=example,dc=com
111 newrdn: ou=Renamed child
115 if test $RC != 0 ; then
116 echo "ldapadd failed ($RC)!"
117 test $KILLSERVERS != no && kill -HUP $KILLPIDS
121 echo "Searching all database..."
122 echo "# Searching all database (after PASS1)..." >> $SEARCHOUT
123 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
124 '(objectClass=*)' >> $SEARCHOUT 2>&1
126 if test $RC != 0 ; then
127 echo "ldapsearch failed ($RC)!"
128 test $KILLSERVERS != no && kill -HUP $KILLPIDS
133 echo "Renaming (PASS2)..."
134 echo "# Renaming (PASS2)..." >> $TESTOUT
135 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
136 >> $TESTOUT 2>&1 << EOMODS2
137 dn: ou=Parent,dc=example,dc=com
139 newrdn: ou=Renamed parent
143 if test $RC != 0 ; then
144 echo "ldapadd failed ($RC)!"
145 test $KILLSERVERS != no && kill -HUP $KILLPIDS
149 echo "Searching all database..."
150 echo "# Searching all database (after PASS2)..." >> $SEARCHOUT
151 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
152 '(objectClass=*)' >> $SEARCHOUT 2>&1
154 if test $RC != 0 ; then
155 echo "ldapsearch failed ($RC)!"
156 test $KILLSERVERS != no && kill -HUP $KILLPIDS
161 echo "Renaming (PASS3)..."
162 echo "# Renaming (PASS3)..." >> $TESTOUT
163 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
164 >> $TESTOUT 2>&1 << EOMODS3
165 dn: ou=Renamed child,ou=Renamed parent,dc=example,dc=com
167 newrdn: ou=Renamed child
169 newsuperior: ou=Another parent,dc=example,dc=com
172 if test $RC != 0 ; then
173 echo "ldapadd failed ($RC)!"
174 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178 echo "Searching all database..."
179 echo "# Searching all database (after PASS3)..." >> $SEARCHOUT
180 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
181 '(objectClass=*)' >> $SEARCHOUT 2>&1
183 if test $RC != 0 ; then
184 echo "ldapsearch failed ($RC)!"
185 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189 test $KILLSERVERS != no && kill -HUP $KILLPIDS
191 LDIF=$SUBTREERENAMEOUT
193 echo "Filtering ldapsearch results..."
194 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
195 echo "Filtering original ldif used to create database..."
196 $LDIFFILTER < $LDIF > $LDIFFLT
197 echo "Comparing filter output..."
198 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
200 if test $? != 0 ; then
201 echo "Comparison failed"
205 echo ">>>>> Test succeeded"
207 test $KILLSERVERS != no && wait