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