~ttx/openldap/lucid-gssapi-495418

« back to all changes in this revision

Viewing changes to tests/scripts/test010-passwd

  • 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/test010-passwd,v 1.26.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
mkdir -p $TESTDIR $DBDIR1
 
20
 
 
21
echo "Starting slapd on TCP/IP port $PORT1..."
 
22
. $CONFFILTER $BACKEND $MONITORDB < $PWCONF > $CONF1
 
23
$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
 
24
PID=$!
 
25
if test $WAIT != 0 ; then
 
26
    echo PID $PID
 
27
    read foo
 
28
fi
 
29
KILLPIDS="$PID"
 
30
 
 
31
sleep 1
 
32
 
 
33
echo "Using ldapsearch to check that slapd is running..."
 
34
for i in 0 1 2 3 4 5; do
 
35
        $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
 
36
                'objectclass=*' > /dev/null 2>&1
 
37
        RC=$?
 
38
        if test $RC = 0 ; then
 
39
                break
 
40
        fi
 
41
        echo "Waiting 5 seconds for slapd to start..."
 
42
        sleep 5
 
43
done
 
44
 
 
45
echo "Using ldapadd to populate the database..."
 
46
$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
 
47
        $LDIFPASSWD > $TESTOUT 2>&1
 
48
RC=$?
 
49
if test $RC != 0 ; then
 
50
        echo "ldapadd failed ($RC)!"
 
51
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
52
        exit $RC
 
53
fi
 
54
 
 
55
echo > $SEARCHOUT
 
56
echo > $TESTOUT
 
57
 
 
58
echo "Using ldapsearch to verify population ..."
 
59
echo "++ Initial search" >> $SEARCHOUT
 
60
$LDAPSEARCH -h $LOCALHOST -p $PORT1 \
 
61
        -D "$MANAGERDN" -w $PASSWD \
 
62
        -b "$BASEDN" \
 
63
        'objectclass=*' >> $SEARCHOUT 2>&1
 
64
 
 
65
echo "Using ldappasswd to test a few error conditions ..."
 
66
echo "Pass 0" >> $TESTOUT
 
67
$LDAPPASSWD -h $LOCALHOST -p $PORT1 \
 
68
        -w secret -a "" -s newsecret \
 
69
        -D "cn=md5, $BASEDN" >> $TESTOUT 2>&1
 
70
RC=$?
 
71
if test $RC = 0 ; then
 
72
        echo "ldappasswd unexpectantly passed ($RC)! old empty"
 
73
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
74
        exit 1
 
75
fi
 
76
$LDAPPASSWD -h $LOCALHOST -p $PORT1 \
 
77
        -w secret -a oldsecret -s "" \
 
78
        -D "cn=md5, $BASEDN" >> $TESTOUT 2>&1
 
79
RC=$?
 
80
if test $RC = 0 ; then
 
81
        echo "ldappasswd unexpectantly passed ($RC)! new empty"
 
82
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
83
        exit 1
 
84
fi
 
85
$LDAPPASSWD -h $LOCALHOST -p $PORT1 \
 
86
        -w secret -a oldsecret -s newsecret \
 
87
        -D "cn=md5, $BASEDN" >> $TESTOUT 2>&1
 
88
RC=$?
 
89
if test $RC = 0 ; then
 
90
        echo "ldappasswd unexpectantly passed ($RC)! wrong old"
 
91
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
92
        exit 1
 
93
fi
 
94
 
 
95
echo "Using ldappasswd (PASS 1)  ..."
 
96
echo "Pass 1" >> $TESTOUT
 
97
$LDAPPASSWD -h $LOCALHOST -p $PORT1 \
 
98
        -w secret -s newsecret \
 
99
        -D "cn=md5, $BASEDN" >> $TESTOUT 2>&1
 
100
RC=$?
 
101
if test $RC != 0 ; then
 
102
        echo "ldappasswd failed ($RC)!"
 
103
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
104
        exit $RC
 
105
fi
 
106
$LDAPPASSWD -h $LOCALHOST -p $PORT1 \
 
107
        -w $PASSWD -s newsecret \
 
108
        -D "$MANAGERDN" "cn=smd5, $BASEDN" >> $TESTOUT 2>&1
 
109
RC=$?
 
110
if test $RC != 0 ; then
 
111
        echo "ldappasswd failed ($RC)!"
 
112
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
113
        exit $RC
 
114
fi
 
115
$LDAPPASSWD -h $LOCALHOST -p $PORT1 \
 
116
        -w secret -s newsecret \
 
117
        -D "cn=sha, $BASEDN" >> $TESTOUT 2>&1
 
118
RC=$?
 
119
if test $RC != 0 ; then
 
120
        echo "ldappasswd failed ($RC)!"
 
121
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
122
        exit $RC
 
123
fi
 
124
$LDAPPASSWD -h $LOCALHOST -p $PORT1 \
 
125
        -w secret -s newsecret \
 
126
        -D "cn=ssha, $BASEDN" >> $TESTOUT 2>&1
 
127
RC=$?
 
128
if test $RC != 0 ; then
 
129
        echo "ldappasswd failed ($RC)!"
 
130
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
131
        exit $RC
 
132
fi
 
133
 
 
134
echo "" >> $TESTOUT
 
135
echo "Pass 2" >> $TESTOUT
 
136
echo "Using ldappasswd (PASS 2)  ..."
 
137
$LDAPPASSWD -h $LOCALHOST -p $PORT1 \
 
138
        -w newsecret \
 
139
        -D "cn=md5, $BASEDN" >> $TESTOUT 2>&1
 
140
RC=$?
 
141
if test $RC != 0 ; then
 
142
        echo "ldappasswd failed ($RC)!"
 
143
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
144
        exit $RC
 
145
fi
 
146
$LDAPPASSWD -h $LOCALHOST -p $PORT1 \
 
147
        -w newsecret \
 
148
        -D "cn=smd5, $BASEDN" >> $TESTOUT 2>&1
 
149
RC=$?
 
150
if test $RC != 0 ; then
 
151
        echo "ldappasswd failed ($RC)!"
 
152
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
153
        exit $RC
 
154
fi
 
155
$LDAPPASSWD -h $LOCALHOST -p $PORT1 \
 
156
        -w newsecret \
 
157
        -D "cn=sha, $BASEDN" >> $TESTOUT 2>&1
 
158
RC=$?
 
159
if test $RC != 0 ; then
 
160
        echo "ldappasswd failed ($RC)!"
 
161
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
162
        exit $RC
 
163
fi
 
164
$LDAPPASSWD -h $LOCALHOST -p $PORT1 \
 
165
        -w newsecret \
 
166
        -D "cn=ssha, $BASEDN" >> $TESTOUT 2>&1
 
167
RC=$?
 
168
if test $RC != 0 ; then
 
169
        echo "ldappasswd failed ($RC)!"
 
170
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
171
        exit $RC
 
172
fi
 
173
 
 
174
echo "Logging end state with ldapsearch..."
 
175
echo "" >> $TESTOUT
 
176
echo "++ End search" >> $TESTOUT
 
177
$LDAPSEARCH -h $LOCALHOST -p $PORT1 \
 
178
        -D "$MANAGERDN" -w $PASSWD \
 
179
        -b "$BASEDN" \
 
180
        'objectclass=*' >> $TESTOUT 2>&1
 
181
 
 
182
 
 
183
test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
184
 
 
185
echo ">>>>> Test succeeded"
 
186
 
 
187
test $KILLSERVERS != no && wait
 
188
 
 
189
exit 0