]> git.sur5r.net Git - openldap/blob - tests/scripts/passwd-search
Sync with HEAD
[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         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 echo "Cleaning up in $DBDIR..."
29
30 rm -f $DBDIR/[!C]*
31
32 echo "Starting slapd on TCP/IP port $PORT..."
33 $SLAPD -f $PASSWDCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
34 PID=$!
35
36 echo "Testing slapd searching..."
37 for i in 0 1 2 3 4 5; do
38         $LDAPSEARCH -L -b "$BASEDN" -h $LOCALHOST -p $PORT \
39                 'objectclass=*' > /dev/null 2>&1
40         RC=$?
41         if test $RC = 1 ; then
42                 echo "Waiting 5 seconds for slapd to start..."
43                 sleep 5
44         fi
45 done
46
47 if test $RC != 0 ; then
48         echo "ldapsearch failed!"
49         kill -HUP $PID
50         exit $RC
51 fi
52
53 cat /dev/null > $TESTOUT
54
55 echo "Testing base suffix searching..."
56 $LDAPSEARCH -L -S "" -b "$BASEDN" -s base -h $LOCALHOST -p $PORT \
57         '(objectclass=*)' >> $TESTOUT 2>&1
58 if test $RC != 0 ; then
59         echo "ldapsearch failed!"
60         kill -HUP $PID
61         exit $RC
62 fi
63
64 echo " ------------ " >> $TESTOUT
65
66 echo "Testing user searching..."
67 $LDAPSEARCH -L -S "" -b "uid=root,$BASEDN" -s base -h $LOCALHOST -p $PORT \
68         '(objectclass=*)' >> $TESTOUT 2>&1
69 if test $RC != 0 ; then
70         echo "ldapsearch failed!"
71         kill -HUP $PID
72         exit $RC
73 fi
74
75 echo " ------------ " >> $TESTOUT
76
77 echo "Testing exact searching..."
78 $LDAPSEARCH -L -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
79         '(uid=root)' >> $TESTOUT 2>&1
80 if test $RC != 0 ; then
81         echo "ldapsearch failed!"
82         kill -HUP $PID
83         exit $RC
84 fi
85
86 echo " ------------ " >> $TESTOUT
87
88 echo "Testing OR searching..."
89 $LDAPSEARCH -L -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
90         '(|(objectclass=person)(cn=root))' >> $TESTOUT 2>&1
91 if test $RC != 0 ; then
92         echo "ldapsearch failed!"
93         kill -HUP $PID
94         exit $RC
95 fi
96
97 echo " ------------ " >> $TESTOUT
98
99 echo "Testing AND searching..."
100 $LDAPSEARCH -L -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
101         '(&(objectclass=person)(cn=root))' >> $TESTOUT 2>&1
102 if test $RC != 0 ; then
103         echo "ldapsearch failed!"
104         kill -HUP $PID
105         exit $RC
106 fi
107
108 kill -HUP $PID
109
110 echo "Assuming everything is fine."
111 #echo "Comparing results"
112 #$CMP $TESTOUT $SEARCHOUTMASTER
113 #if test $? != 0 ; then
114 #       echo "Comparison failed"
115 #       exit 1
116 #fi
117
118 echo ">>>>> Test succeeded"
119
120
121 exit 0