]> git.sur5r.net Git - openldap/blob - tests/scripts/passwd-search
ITS#4049: oldPassword cannot be ignored, error for now
[openldap] / tests / scripts / passwd-search
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2005 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 if test $# -eq 0 ; then
17         test -z "$SRCDIR" && SRCDIR="."
18 else
19         SRCDIR=$1; shift
20 fi
21 if test $# -eq 1 ; then
22         BACKEND=$1; shift
23 fi
24
25 echo "running defines.sh $SRCDIR $BACKEND"
26 . $SRCDIR/scripts/defines.sh
27
28 if test -d "$TESTDIR"; then
29         echo "Cleaning up in $TESTDIR..."
30         /bin/rm -rf testrun/db.*
31 fi
32 mkdir -p $TESTDIR
33
34 echo "Starting slapd on TCP/IP port $PORT1..."
35 $SLAPD -f $PASSWDCONF -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
36 PID=$!
37 if test ${WAIT-0} != 0 ; then
38     echo PID $PID
39     read foo
40 fi
41 KILLPIDS="$PID"
42
43 echo "Testing slapd searching..."
44 for i in 0 1 2 3 4 5; do
45         $LDAPSEARCH -L -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
46                 'objectclass=*' > /dev/null 2>&1
47         RC=$?
48         if test $RC = 1 ; then
49                 echo "Waiting 5 seconds for slapd to start..."
50                 sleep 5
51         fi
52 done
53
54 if test $RC != 0 ; then
55         echo "ldapsearch failed!"
56         test "$KILLSERVERS" != no && kill -HUP $KILLPIDS
57         exit $RC
58 fi
59
60 cat /dev/null > $TESTOUT
61
62 echo "Testing base suffix searching..."
63 $LDAPSEARCH -L -S "" -b "$BASEDN" -s base -h $LOCALHOST -p $PORT1 \
64         '(objectclass=*)' >> $TESTOUT 2>&1
65 RC=$?
66 if test $RC != 0 ; then
67         echo "ldapsearch failed!"
68         test "$KILLSERVERS" != no && kill -HUP $KILLPIDS
69         exit $RC
70 fi
71
72 echo " ------------ " >> $TESTOUT
73
74 echo "Testing user searching..."
75 $LDAPSEARCH -L -S "" -b "uid=root,$BASEDN" -s base -h $LOCALHOST -p $PORT1 \
76         '(objectclass=*)' >> $TESTOUT 2>&1
77 RC=$?
78 if test $RC != 0 ; then
79         echo "ldapsearch failed!"
80         test "$KILLSERVERS" != no && kill -HUP $KILLPIDS
81         exit $RC
82 fi
83
84 echo " ------------ " >> $TESTOUT
85
86 echo "Testing exact searching..."
87 $LDAPSEARCH -L -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
88         '(uid=root)' >> $TESTOUT 2>&1
89 RC=$?
90 if test $RC != 0 ; then
91         echo "ldapsearch failed!"
92         test "$KILLSERVERS" != no && kill -HUP $KILLPIDS
93         exit $RC
94 fi
95
96 echo " ------------ " >> $TESTOUT
97
98 echo "Testing OR searching..."
99 $LDAPSEARCH -L -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
100         '(|(objectclass=person)(cn=root))' >> $TESTOUT 2>&1
101 RC=$?
102 if test $RC != 0 ; then
103         echo "ldapsearch failed!"
104         test "$KILLSERVERS" != no && kill -HUP $KILLPIDS
105         exit $RC
106 fi
107
108 echo " ------------ " >> $TESTOUT
109
110 echo "Testing AND searching..."
111 $LDAPSEARCH -L -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
112         '(&(objectclass=person)(cn=root))' >> $TESTOUT 2>&1
113 RC=$?
114 if test $RC != 0 ; then
115         echo "ldapsearch failed!"
116         test "$KILLSERVERS" != no && kill -HUP $KILLPIDS
117         exit $RC
118 fi
119
120 test "$KILLSERVERS" != no && kill -HUP $KILLPIDS
121
122 echo "Assuming everything is fine."
123 #echo "Comparing results"
124 #$CMP $TESTOUT $SEARCHOUTMASTER
125 #if test $? != 0 ; then
126 #       echo "Comparison failed"
127 #       exit 1
128 #fi
129
130 echo ">>>>> Test succeeded"
131
132 exit 0