2
# $OpenLDAP: pkg/ldap/tests/scripts/test040-subtree-rename,v 1.4.2.3 2008/02/11 23:26:51 kurt Exp $ */
3
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5
## Copyright 1998-2008 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
23
echo "subtree rename not supported by back-$BACKEND"
27
mkdir -p $TESTDIR $DBDIR1
29
echo "Starting slapd on TCP/IP port $PORT1..."
30
. $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
31
$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
33
if test $WAIT != 0 ; then
41
echo "Testing slapd searching..."
42
for i in 0 1 2 3 4 5; do
43
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
44
'(objectclass=*)' > /dev/null 2>&1
46
if test $RC = 0 ; then
49
echo "Waiting 5 seconds for slapd to start..."
53
if test $RC != 0 ; then
54
echo "ldapsearch failed ($RC)!"
55
test $KILLSERVERS != no && kill -HUP $KILLPIDS
59
cat /dev/null > $TESTOUT
60
cat /dev/null > $SEARCHOUT
63
echo "Populating the database..."
64
echo "# Populating the database..." >> $TESTOUT
65
$LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
66
>> $TESTOUT 2>&1 << EOMODS0
68
objectClass: organization
73
dn: ou=Parent,dc=example,dc=com
74
objectClass: organizationalUnit
77
dn: ou=Another parent,dc=example,dc=com
78
objectClass: organizationalUnit
81
dn: ou=Child,ou=Parent,dc=example,dc=com
82
objectClass: organizationalUnit
85
dn: ou=Grandchild,ou=Child,ou=Parent,dc=example,dc=com
86
objectClass: organizationalUnit
90
if test $RC != 0 ; then
91
echo "ldapadd failed ($RC)!"
92
test $KILLSERVERS != no && kill -HUP $KILLPIDS
96
echo "Searching all database..."
97
echo "# Searching all database (after add)..." >> $SEARCHOUT
98
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
99
'(objectClass=*)' >> $SEARCHOUT 2>&1
101
if test $RC != 0 ; then
102
echo "ldapsearch failed ($RC)!"
103
test $KILLSERVERS != no && kill -HUP $KILLPIDS
108
echo "Renaming (PASS1)..."
109
echo "# Renaming (PASS1)..." >> $TESTOUT
110
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
111
>> $TESTOUT 2>&1 << EOMODS1
112
dn: ou=Child,ou=Parent,dc=example,dc=com
114
newrdn: ou=Renamed child
118
if test $RC != 0 ; then
119
echo "ldapadd failed ($RC)!"
120
test $KILLSERVERS != no && kill -HUP $KILLPIDS
124
echo "Searching all database..."
125
echo "# Searching all database (after PASS1)..." >> $SEARCHOUT
126
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
127
'(objectClass=*)' >> $SEARCHOUT 2>&1
129
if test $RC != 0 ; then
130
echo "ldapsearch failed ($RC)!"
131
test $KILLSERVERS != no && kill -HUP $KILLPIDS
136
echo "Renaming (PASS2)..."
137
echo "# Renaming (PASS2)..." >> $TESTOUT
138
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
139
>> $TESTOUT 2>&1 << EOMODS2
140
dn: ou=Parent,dc=example,dc=com
142
newrdn: ou=Renamed parent
146
if test $RC != 0 ; then
147
echo "ldapadd failed ($RC)!"
148
test $KILLSERVERS != no && kill -HUP $KILLPIDS
152
echo "Searching all database..."
153
echo "# Searching all database (after PASS2)..." >> $SEARCHOUT
154
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
155
'(objectClass=*)' >> $SEARCHOUT 2>&1
157
if test $RC != 0 ; then
158
echo "ldapsearch failed ($RC)!"
159
test $KILLSERVERS != no && kill -HUP $KILLPIDS
164
echo "Renaming (PASS3)..."
165
echo "# Renaming (PASS3)..." >> $TESTOUT
166
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
167
>> $TESTOUT 2>&1 << EOMODS3
168
dn: ou=Renamed child,ou=Renamed parent,dc=example,dc=com
170
newrdn: ou=Renamed child
172
newsuperior: ou=Another parent,dc=example,dc=com
175
if test $RC != 0 ; then
176
echo "ldapadd failed ($RC)!"
177
test $KILLSERVERS != no && kill -HUP $KILLPIDS
181
echo "Searching all database..."
182
echo "# Searching all database (after PASS3)..." >> $SEARCHOUT
183
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
184
'(objectClass=*)' >> $SEARCHOUT 2>&1
186
if test $RC != 0 ; then
187
echo "ldapsearch failed ($RC)!"
188
test $KILLSERVERS != no && kill -HUP $KILLPIDS
192
test $KILLSERVERS != no && kill -HUP $KILLPIDS
194
LDIF=$SUBTREERENAMEOUT
196
echo "Filtering ldapsearch results..."
197
. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
198
echo "Filtering original ldif used to create database..."
199
. $LDIFFILTER < $LDIF > $LDIFFLT
200
echo "Comparing filter output..."
201
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
203
if test $? != 0 ; then
204
echo "Comparison failed"
208
echo ">>>>> Test succeeded"
210
test $KILLSERVERS != no && wait