~ttx/openldap/lucid-gssapi-495418

« back to all changes in this revision

Viewing changes to tests/scripts/test037-manage

  • 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/test037-manage,v 1.12.2.5 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
if test $BACKEND = "ldif" ; then 
 
20
        echo "LDIF backend does not support manageDIT control, test skipped"
 
21
        exit 0
 
22
fi 
 
23
 
 
24
mkdir -p $TESTDIR $DBDIR1
 
25
 
 
26
echo "Running slapadd to build slapd database..."
 
27
. $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
 
28
$SLAPADD -f $CONF1 -l $LDIFORDERED
 
29
RC=$?
 
30
if test $RC != 0 ; then
 
31
        echo "slapadd failed ($RC)!"
 
32
        exit $RC
 
33
fi
 
34
 
 
35
echo "Starting slapd on TCP/IP port $PORT1..."
 
36
$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
 
37
PID=$!
 
38
if test $WAIT != 0 ; then
 
39
    echo PID $PID
 
40
    read foo
 
41
fi
 
42
KILLPIDS="$PID"
 
43
 
 
44
sleep 1
 
45
 
 
46
echo "Testing slapd Manage operations..."
 
47
for i in 0 1 2 3 4 5; do
 
48
        $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
 
49
                'objectclass=*' > /dev/null 2>&1
 
50
        RC=$?
 
51
        if test $RC = 0 ; then
 
52
                break
 
53
        fi
 
54
        echo "Waiting 5 seconds for slapd to start..."
 
55
        sleep 5
 
56
done
 
57
 
 
58
if test $RC != 0 ; then
 
59
        echo "ldapsearch failed ($RC)!"
 
60
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
61
        exit $RC
 
62
fi
 
63
 
 
64
echo "Testing modify, add, and delete..."
 
65
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
 
66
        -e \!relax > \
 
67
        $TESTOUT 2>&1 << EOMODS
 
68
version: 1
 
69
#
 
70
# Working Tests
 
71
#
 
72
 
 
73
#
 
74
# ObjectClass tests
 
75
#
 
76
 
 
77
dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
 
78
 dc=com
 
79
# add obsolete auxiliary objectclass
 
80
changetype: modify
 
81
add: objectClass
 
82
objectClass: obsoletePerson
 
83
 
 
84
dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
 
85
 dc=com
 
86
# add obsolete attribute
 
87
changetype: modify
 
88
add: testObsolete
 
89
testObsolete: TRUE
 
90
 
 
91
#
 
92
# create/modify timestamp test
 
93
#
 
94
 
 
95
dn: ou=Groups,dc=example,dc=com
 
96
# change creatorsName
 
97
changetype: modify
 
98
replace: creatorsName
 
99
creatorsName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
 
100
 
 
101
dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
 
102
# change modifiersName
 
103
changetype: modify
 
104
replace: modifiersName
 
105
modifiersName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
 
106
 
 
107
dn: dc=example,dc=com
 
108
# change timestamps
 
109
changetype: modify
 
110
replace: modifyTimestamp
 
111
modifyTimestamp: 19700101000000Z
 
112
-
 
113
replace: createTimestamp
 
114
createTimestamp: 19700101000000Z
 
115
-
 
116
 
 
117
dn: cn=All Staff,ou=Groups,dc=example,dc=com
 
118
# change entryUUID
 
119
changetype: modify
 
120
replace: entryUUID
 
121
entryUUID: badbadba-dbad-1029-92f7-badbadbadbad
 
122
 
 
123
dn: cn=All Staff,dc=example,dc=com
 
124
changetype: add
 
125
objectClass: groupOfNames
 
126
cn: All Staff
 
127
member:
 
128
creatorsName: cn=Someone
 
129
createTimestamp: 19700101000000Z
 
130
modifiersName: cn=Someone Else
 
131
modifyTimestamp: 19700101000000Z
 
132
entryUUID: badbadef-dbad-1029-92f7-badbadbadbad
 
133
EOMODS
 
134
 
 
135
RC=$?
 
136
if test $RC != 0 ; then
 
137
        echo "ldapmodify failed ($RC)!"
 
138
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
139
        exit $RC
 
140
fi
 
141
 
 
142
echo "Testing modify, add, and delete..."
 
143
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
 
144
        -e \!relax > \
 
145
        $TESTOUT 2>&1 << EOMODS
 
146
version: 1
 
147
#
 
148
# Non-working tests
 
149
#
 
150
 
 
151
dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
 
152
 dc=com
 
153
# update structural object class of entry via objectClass replace
 
154
changetype: modify
 
155
replace: objectClass
 
156
objectClass: obsoletePerson
 
157
-
 
158
replace: structuralObjectClass
 
159
structuralObjectClass: testPerson
 
160
 
 
161
dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
 
162
# update structural object class of entry via objectClass add
 
163
changetype: modify
 
164
add: objectClass
 
165
objectClass: testPerson
 
166
-
 
167
replace: structuralObjectClass
 
168
structuralObjectClass: testPerson
 
169
 
 
170
dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
 
171
# update structural object class of entry via objectClass delete/add
 
172
changetype: modify
 
173
delete: objectClass
 
174
objectClass: OpenLDAPperson
 
175
-
 
176
add: objectClass
 
177
objectClass: testPerson
 
178
-
 
179
delete: structuralObjectClass
 
180
-
 
181
add: structuralObjectClass
 
182
structuralObjectClass: testPerson
 
183
EOMODS
 
184
 
 
185
RC=$?
 
186
if test $RC != 0 ; then
 
187
        echo "ldapmodify failed ($RC)!  IGNORED"
 
188
#       test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
189
#       exit $RC
 
190
fi
 
191
 
 
192
echo "Using ldapsearch to retrieve all the entries..."
 
193
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
 
194
    'objectClass=*' '*' creatorsName modifiersName > $SEARCHOUT 2>&1
 
195
RC=$?
 
196
if test $RC != 0 ; then
 
197
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
198
        echo "ldapsearch failed ($RC)!"
 
199
        exit $RC
 
200
fi
 
201
 
 
202
$LDAPSEARCH -S "" -b "$BASEDN" -s base -h $LOCALHOST -p $PORT1 \
 
203
    'objectClass=*' '*' creatorsName createTimestamp \
 
204
    modifiersName modifyTimestamp >> $SEARCHOUT 2>&1
 
205
RC=$?
 
206
if test $RC != 0 ; then
 
207
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
208
        echo "ldapsearch failed ($RC)!"
 
209
        exit $RC
 
210
fi
 
211
 
 
212
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
 
213
    '(cn=All Staff)' '*' entryUUID >> $SEARCHOUT 2>&1
 
214
RC=$?
 
215
test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
216
if test $RC != 0 ; then
 
217
        echo "ldapsearch failed ($RC)!"
 
218
        exit $RC
 
219
fi
 
220
 
 
221
LDIF=$MANAGEOUT
 
222
 
 
223
echo "Filtering ldapsearch results..."
 
224
. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
 
225
echo "Filtering original ldif used to create database..."
 
226
. $LDIFFILTER < $LDIF > $LDIFFLT
 
227
echo "Comparing filter output..."
 
228
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
 
229
 
 
230
if test $? != 0 ; then
 
231
        echo "comparison failed - manage operations did not complete correctly"
 
232
        exit 1
 
233
fi
 
234
 
 
235
echo ">>>>> Test succeeded"
 
236
 
 
237
test $KILLSERVERS != no && wait
 
238
 
 
239
exit 0