~ttx/openldap/lucid-gssapi-495418

« back to all changes in this revision

Viewing changes to tests/scripts/test040-subtree-rename

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2008-07-10 14:45:49 UTC
  • Revision ID: james.westby@ubuntu.com-20080710144549-wck73med0e72gfyo
Tags: upstream-2.4.10
ImportĀ upstreamĀ versionĀ 2.4.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
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/>.
 
4
##
 
5
## Copyright 1998-2008 The OpenLDAP Foundation.
 
6
## All rights reserved.
 
7
##
 
8
## Redistribution and use in source and binary forms, with or without
 
9
## modification, are permitted only as authorized by the OpenLDAP
 
10
## Public License.
 
11
##
 
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>.
 
15
 
 
16
echo "running defines.sh"
 
17
. $SRCDIR/scripts/defines.sh
 
18
 
 
19
case $BACKEND in
 
20
hdb)
 
21
        ;;
 
22
*)
 
23
        echo "subtree rename not supported by back-$BACKEND"
 
24
        exit 0
 
25
esac
 
26
 
 
27
mkdir -p $TESTDIR $DBDIR1
 
28
 
 
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 &
 
32
PID=$!
 
33
if test $WAIT != 0 ; then
 
34
    echo PID $PID
 
35
    read foo
 
36
fi
 
37
KILLPIDS="$PID"
 
38
 
 
39
sleep 1
 
40
 
 
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
 
45
        RC=$?
 
46
        if test $RC = 0 ; then
 
47
                break
 
48
        fi
 
49
        echo "Waiting 5 seconds for slapd to start..."
 
50
        sleep 5
 
51
done
 
52
 
 
53
if test $RC != 0 ; then
 
54
        echo "ldapsearch failed ($RC)!"
 
55
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
56
        exit $RC
 
57
fi
 
58
 
 
59
cat /dev/null > $TESTOUT
 
60
cat /dev/null > $SEARCHOUT
 
61
 
 
62
# Add
 
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
 
67
dn: dc=example,dc=com
 
68
objectClass: organization
 
69
objectClass: dcObject
 
70
o: Example, Inc.
 
71
dc: example
 
72
 
 
73
dn: ou=Parent,dc=example,dc=com
 
74
objectClass: organizationalUnit
 
75
ou: Parent
 
76
 
 
77
dn: ou=Another parent,dc=example,dc=com
 
78
objectClass: organizationalUnit
 
79
ou: Another parent
 
80
 
 
81
dn: ou=Child,ou=Parent,dc=example,dc=com
 
82
objectClass: organizationalUnit
 
83
ou: Child
 
84
 
 
85
dn: ou=Grandchild,ou=Child,ou=Parent,dc=example,dc=com
 
86
objectClass: organizationalUnit
 
87
ou: Grandchild
 
88
EOMODS0
 
89
RC=$?
 
90
if test $RC != 0 ; then
 
91
        echo "ldapadd failed ($RC)!"
 
92
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
93
        exit $RC
 
94
fi
 
95
 
 
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
 
100
RC=$?
 
101
if test $RC != 0 ; then
 
102
        echo "ldapsearch failed ($RC)!"
 
103
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
104
        exit $RC
 
105
fi
 
106
 
 
107
# Rename (PASS1)
 
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
 
113
changetype: modrdn
 
114
newrdn: ou=Renamed child
 
115
deleteoldrdn: 0
 
116
EOMODS1
 
117
RC=$?
 
118
if test $RC != 0 ; then
 
119
        echo "ldapadd failed ($RC)!"
 
120
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
121
        exit $RC
 
122
fi
 
123
 
 
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
 
128
RC=$?
 
129
if test $RC != 0 ; then
 
130
        echo "ldapsearch failed ($RC)!"
 
131
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
132
        exit $RC
 
133
fi
 
134
 
 
135
# Rename (PASS2)
 
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
 
141
changetype: modrdn
 
142
newrdn: ou=Renamed parent
 
143
deleteoldrdn: 0
 
144
EOMODS2
 
145
RC=$?
 
146
if test $RC != 0 ; then
 
147
        echo "ldapadd failed ($RC)!"
 
148
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
149
        exit $RC
 
150
fi
 
151
 
 
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
 
156
RC=$?
 
157
if test $RC != 0 ; then
 
158
        echo "ldapsearch failed ($RC)!"
 
159
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
160
        exit $RC
 
161
fi
 
162
 
 
163
# Rename (PASS3)
 
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
 
169
changetype: modrdn
 
170
newrdn: ou=Renamed child
 
171
deleteoldrdn: 0
 
172
newsuperior: ou=Another parent,dc=example,dc=com
 
173
EOMODS3
 
174
RC=$?
 
175
if test $RC != 0 ; then
 
176
        echo "ldapadd failed ($RC)!"
 
177
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
178
        exit $RC
 
179
fi
 
180
 
 
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
 
185
RC=$?
 
186
if test $RC != 0 ; then
 
187
        echo "ldapsearch failed ($RC)!"
 
188
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
189
        exit $RC
 
190
fi
 
191
 
 
192
test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
193
 
 
194
LDIF=$SUBTREERENAMEOUT
 
195
 
 
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
 
202
 
 
203
if test $? != 0 ; then
 
204
        echo "Comparison failed"
 
205
        exit 1
 
206
fi
 
207
 
 
208
echo ">>>>> Test succeeded"
 
209
 
 
210
test $KILLSERVERS != no && wait
 
211
 
 
212
exit 0