]> git.sur5r.net Git - openldap/blob - tests/scripts/passwd-search
Use -h URL, not -p port
[openldap] / tests / scripts / passwd-search
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 $PASSWDCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
22 PID=$!
23
24 echo "Testing slapd searching..."
25 for i in 0 1 2 3 4 5; do
26         $LDAPSEARCH -L -b "$BASEDN" -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 if test $RC != 0 ; then
36         echo "ldapsearch failed!"
37         kill -HUP $PID
38         exit $RC
39 fi
40
41 cat /dev/null > $TESTOUT
42
43 echo "Testing base suffix searching..."
44 $LDAPSEARCH -L -S "" -b "$BASEDN" -s base -h localhost -p $PORT \
45         '(objectclass=*)' >> $TESTOUT 2>&1
46 if test $RC != 0 ; then
47         echo "ldapsearch failed!"
48         kill -HUP $PID
49         exit $RC
50 fi
51
52 echo " ------------ " >> $TESTOUT
53
54 echo "Testing user searching..."
55 $LDAPSEARCH -L -S "" -b "uid=root,$BASEDN" -s base -h localhost -p $PORT \
56         '(objectclass=*)' >> $TESTOUT 2>&1
57 if test $RC != 0 ; then
58         echo "ldapsearch failed!"
59         kill -HUP $PID
60         exit $RC
61 fi
62
63 echo " ------------ " >> $TESTOUT
64
65 echo "Testing exact searching..."
66 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
67         '(uid=root)' >> $TESTOUT 2>&1
68 if test $RC != 0 ; then
69         echo "ldapsearch failed!"
70         kill -HUP $PID
71         exit $RC
72 fi
73
74 echo " ------------ " >> $TESTOUT
75
76 echo "Testing OR searching..."
77 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
78         '(|(objectclass=person)(cn=root))' >> $TESTOUT 2>&1
79 if test $RC != 0 ; then
80         echo "ldapsearch failed!"
81         kill -HUP $PID
82         exit $RC
83 fi
84
85 echo " ------------ " >> $TESTOUT
86
87 echo "Testing AND searching..."
88 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
89         '(&(objectclass=person)(cn=root))' >> $TESTOUT 2>&1
90 if test $RC != 0 ; then
91         echo "ldapsearch failed!"
92         kill -HUP $PID
93         exit $RC
94 fi
95
96 kill -HUP $PID
97
98 echo "Assuming everything is fine."
99 #echo "Comparing results"
100 #$CMP $TESTOUT $SEARCHOUTMASTER
101 #if test $? != 0 ; then
102 #       echo "Comparison failed"
103 #       exit 1
104 #fi
105
106 echo ">>>>> Test succeeded"
107
108
109 exit 0