Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / openldap / dist / tests / scripts / test010-passwd
blob36c7a70d4e7eeeca29dfc709b6e5cfe7e424f0ef
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.
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 mkdir -p $TESTDIR $DBDIR1
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
29 KILLPIDS="$PID"
31 sleep 1
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
41 echo "Waiting 5 seconds for slapd to start..."
42 sleep 5
43 done
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
55 echo > $SEARCHOUT
56 echo > $TESTOUT
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
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
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
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
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
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
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
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
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
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
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
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
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
183 test $KILLSERVERS != no && kill -HUP $KILLPIDS
185 echo ">>>>> Test succeeded"
187 test $KILLSERVERS != no && wait
189 exit 0