]> git.sur5r.net Git - openldap/blob - tests/scripts/test010-passwd
Add password check and generation check.
[openldap] / tests / scripts / test010-passwd
1 #! /bin/sh
2 # $OpenLDAP$
3
4 if test $# -eq 0 ; then
5         SRCDIR="."
6 else
7         SRCDIR=$1; shift
8 fi
9 if test $# -eq 1 ; then
10         BACKEND=$1; shift
11 fi
12
13 echo "running defines.sh $SRCDIR $BACKEND"
14 . $SRCDIR/scripts/defines.sh
15
16 echo "Cleaning up in $DBDIR..."
17
18 rm -f $DBDIR/[!C]*
19
20 echo "Starting slapd on TCP/IP port $PORT..."
21 $SLAPD -f $PWCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
22 PID=$!
23
24 echo "Using ldapsearch to check that slapd is running..."
25 for i in 0 1 2 3 4 5; do
26         $LDAPSEARCH -s base -b "$MONITOR" -h localhost -p $PORT \
27                 'objectclass=*' > /dev/null 2>&1
28         RC=$?
29         if test $RC = 1 ; then
30                 echo "Waiting 5 seconds for slapd to start..."
31                 sleep 5
32         fi
33 done
34
35 echo "Using ldapadd to populate the database..."
36 $LDAPADD -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD < \
37         $LDIFPASSWD > $TESTOUT 2>&1
38 RC=$?
39 if test $RC != 0 ; then
40         echo "ldapadd failed!"
41         kill -HUP $PID
42         exit $RC
43 fi
44
45 echo > $SEARCHOUT
46 echo > $TESTOUT
47
48 echo "Using ldapsearch to verify population ..."
49 echo "++ Initial search" >> $SEARCHOUT
50 $LDAPSEARCH -h localhost -p $PORT \
51         -D "$MANAGERDN" -w $PASSWD \
52         -b "$BASEDN" \
53         'objectclass=*' >> $SEARCHOUT 2>&1
54
55 echo "Using ldappasswd (PASS 1)  ..."
56 echo "Pass 1" >> $TESTOUT
57 $LDAPPASSWD -h localhost -p $PORT \
58         -w secret -s newsecret \
59         "cn=md5, $BASEDN" >> $TESTOUT 2>&1
60 RC=$?
61 if test $RC != 0 ; then
62         echo "ldappasswd failed!"
63         kill -HUP $PID
64         exit $RC
65 fi
66 $LDAPPASSWD -h localhost -p $PORT \
67         -w secret -s newsecret \
68         "cn=smd5, $BASEDN" >> $TESTOUT 2>&1
69 if test $RC != 0 ; then
70         echo "ldappasswd failed!"
71         kill -HUP $PID
72         exit $RC
73 fi
74 $LDAPPASSWD -h localhost -p $PORT \
75         -w secret -s newsecret \
76         "cn=sha, $BASEDN" >> $TESTOUT 2>&1
77 if test $RC != 0 ; then
78         echo "ldappasswd failed!"
79         kill -HUP $PID
80         exit $RC
81 fi
82 $LDAPPASSWD -h localhost -p $PORT \
83         -w secret -s newsecret \
84         "cn=ssha, $BASEDN" >> $TESTOUT 2>&1
85 if test $RC != 0 ; then
86         echo "ldappasswd failed!"
87         kill -HUP $PID
88         exit $RC
89 fi
90
91 echo "" >> $TESTOUT
92 echo "Pass 2" >> $TESTOUT
93 echo "Using ldappasswd (PASS 2)  ..."
94 $LDAPPASSWD -h localhost -p $PORT \
95         -w newsecret \
96         "cn=md5, $BASEDN" >> $TESTOUT 2>&1
97 if test $RC != 0 ; then
98         echo "ldappasswd failed!"
99         kill -HUP $PID
100         exit $RC
101 fi
102 $LDAPPASSWD -h localhost -p $PORT \
103         -w newsecret \
104         "cn=smd5, $BASEDN" >> $TESTOUT 2>&1
105 if test $RC != 0 ; then
106         echo "ldappasswd failed!"
107         kill -HUP $PID
108         exit $RC
109 fi
110 $LDAPPASSWD -h localhost -p $PORT \
111         -w newsecret \
112         "cn=sha, $BASEDN" >> $TESTOUT 2>&1
113 if test $RC != 0 ; then
114         echo "ldappasswd failed!"
115         kill -HUP $PID
116         exit $RC
117 fi
118 $LDAPPASSWD -h localhost -p $PORT \
119         -w newsecret \
120         "cn=ssha, $BASEDN" >> $TESTOUT 2>&1
121 if test $RC != 0 ; then
122         echo "ldappasswd failed!"
123         kill -HUP $PID
124         exit $RC
125 fi
126
127 kill -HUP $PID
128
129 echo ">>>>> Test succeeded"
130
131 exit 0