]> git.sur5r.net Git - openldap/blob - tests/scripts/test015-xsearch
84f17970c17aae958e70f374341a4b1e53f6641c
[openldap] / tests / scripts / test015-xsearch
1 #! /bin/sh
2 # $OpenLDAP$
3
4 echo "running defines.sh"
5 . $SRCDIR/scripts/defines.sh
6
7 mkdir $DBDIR
8
9 echo "Running slapadd to build slapd database..."
10 . $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF
11 $SLAPADD -f $ADDCONF -l $LDIFORDERED
12 RC=$?
13 if test $RC != 0 ; then
14         echo "slapadd failed ($RC)!"
15         exit $RC
16 fi
17
18 echo "Running slapindex to index slapd database..."
19 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $DBCONF
20 $SLAPINDEX -f $DBCONF
21 RC=$?
22 if test $RC != 0 ; then
23         echo "warning: slapindex failed ($RC)"
24         echo "  assuming no indexing support"
25 fi
26
27 echo "Starting slapd on TCP/IP port $PORT..."
28 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
29 PID=$!
30 if test $WAIT != 0 ; then
31     echo PID $PID
32     read foo
33 fi
34
35 echo "Testing slapd searching..."
36 for i in 0 1 2 3 4 5; do
37         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
38                 'objectclass=*' > /dev/null 2>&1
39         RC=$?
40         if test $RC = 0 ; then
41                 break
42         fi
43         echo "Waiting 5 seconds for slapd to start..."
44         sleep 5
45 done
46
47 if test $RC != 0 ; then
48         echo "ldapsearch failed ($RC)!"
49         kill -HUP $PID
50         exit $RC
51 fi
52
53 cat /dev/null > $SEARCHOUT
54
55 echo "Testing exact searching..."
56 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
57         '(sn:=jensen)' >> $SEARCHOUT 2>&1
58 RC=$?
59 if test $RC != 0 ; then
60         echo "ldapsearch failed ($RC)!"
61         kill -HUP $PID
62         exit $RC
63 fi
64
65 echo "Testing OR searching..."
66 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
67         '(|(givenName=XX*YY*Z)(cn=)(undef=*)(objectclass=groupofnames)(objectclass=groupofuniquenames)(sn:caseExactMatch:=Jones))' >> $SEARCHOUT 2>&1
68 RC=$?
69 if test $RC != 0 ; then
70         echo "ldapsearch failed ($RC)!"
71         kill -HUP $PID
72         exit $RC
73 fi
74
75 echo "Testing AND matching and ends-with searching..."
76 $LDAPSEARCH -S "" -b "ou=groups,$BASEDN" -s one -h $LOCALHOST -p $PORT \
77         '(&(|(objectclass=groupofnames)(objectclass=groupofuniquenames))(cn=A*))' >> $SEARCHOUT 2>&1
78 RC=$?
79 if test $RC != 0 ; then
80         echo "ldapsearch failed ($RC)!"
81         kill -HUP $PID
82         exit $RC
83 fi
84
85 echo "Testing NOT searching..."
86 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
87         '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
88 RC=$?
89 if test $RC != 0 ; then
90         echo "ldapsearch failed ($RC)!"
91         kill -HUP $PID
92         exit $RC
93 fi
94
95 echo "Testing objectClass/attributeType inheritance ..."
96 $LDAPSEARCH -M -a never -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
97         '(&(objectClass=inetorgperson)(userid=uham))' \
98         "2.5.4.0" "userid" >> $SEARCHOUT 2>&1
99 RC=$?
100 if test $RC != 0 ; then
101         echo "ldapsearch failed ($RC)!"
102         kill -HUP $PID
103         exit $RC
104 fi
105
106 echo "Testing extended RFC2254 searching..."
107 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
108         '(:dn:caseExactMatch:=University of Michigan)' >> $SEARCHOUT 2>&1
109
110 RC=$?
111 if test $RC != 0 ; then
112         echo "ldapsearch failed ($RC)!"
113         kill -HUP $PID
114         exit $RC
115 fi
116
117 echo "Testing values return filter searching..."
118 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
119         -E '!mv=(o=University of Michigan)' \
120         '(o=University of Michigan)' >> $SEARCHOUT 2>&1
121 RC=$?
122 if test $RC != 0 ; then
123         echo "ldapsearch failed ($RC)!"
124         kill -HUP $PID
125         exit $RC
126 fi
127
128
129 kill -HUP $PID
130
131 LDIF=$SEARCHOUTMASTER
132 LDIF2=$SEARCHOUTX
133
134 echo "Filtering ldapsearch results..."
135 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
136 echo "Filtering original ldif used to create database..."
137 . $LDIFFILTER < $LDIF > $LDIFFLT
138 . $LDIFFILTER < $LDIF2 >> $LDIFFLT
139 echo "Comparing filter output..."
140 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
141
142 if test $? != 0 ; then
143         echo "Comparison failed"
144         exit 1
145 fi
146
147 echo ">>>>> Test succeeded"
148 exit 0