]> git.sur5r.net Git - openldap/blob - tests/scripts/test016-subref
Happy new year
[openldap] / tests / scripts / test016-subref
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2004 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 RCODE=10
17
18 echo "running defines.sh"
19 . $SRCDIR/scripts/defines.sh
20
21 mkdir $TESTDIR $DBDIR1
22
23 echo "Running slapadd to build slapd database..."
24 . $CONFFILTER $BACKEND $MONITORDB < $RCONF > $CONF1
25 $SLAPADD -f $CONF1 -l $LDIFREF
26 RC=$?
27 if test $RC != 0 ; then
28         echo "slapadd failed ($RC)!"
29         exit $RC
30 fi
31
32 echo "Starting slapd on TCP/IP port $PORT1..."
33 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
34 PID=$!
35 if test $WAIT != 0 ; then
36     echo PID $PID
37     read foo
38 fi
39 KILLPIDS="$PID"
40
41 echo "Testing slapd searching..."
42 for i in 0 1 2 3 4 5; do
43         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
44                 '(objectclass=*)' > /dev/null 2>&1
45         RC=$?
46         if test $RC = 0 ; then
47                 break
48         fi
49         echo "Waiting 5 seconds for slapd to start..."
50         sleep 5
51 done
52
53 if test $RC != 0 ; then
54         echo "ldapsearch failed ($RC)!"
55         test $KILLSERVERS != no && kill -HUP $KILLPIDS
56         exit $RC
57 fi
58
59 cat /dev/null > $SEARCHOUT
60
61 echo "Testing ManageDsaIT searching at $REFDN..."
62 $LDAPRSEARCH -S "" -MM -b "$REFDN" -h $LOCALHOST -p $PORT1 \
63         '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
64 RC=$?
65 if test $RC != 0 ; then
66         echo "ldapsearch failed ($RC)!"
67         test $KILLSERVERS != no && kill -HUP $KILLPIDS
68         exit $RC
69 fi
70
71 echo "Testing ManageDsaIT searching at referral object..."
72 $LDAPRSEARCH -S "" -MM -b "o=abc,$REFDN" -h $LOCALHOST -p $PORT1 \
73         '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
74 RC=$?
75 if test $RC != 0 ; then
76         echo "ldapsearch failed ($RC)!"
77         test $KILLSERVERS != no && kill -HUP $KILLPIDS
78         exit $RC
79 fi
80
81 echo "Testing ManageDsaIT searching below referral object..."
82 $LDAPRSEARCH -S "" -MM -b "uid=xxx,o=abc,$REFDN" -h $LOCALHOST -p $PORT1 \
83         '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
84 RC=$?
85 if test $RC != $RCODE ; then
86         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
87         test $KILLSERVERS != no && kill -HUP $KILLPIDS
88         exit $RC
89 fi
90
91 XREFDN="$REFDN"
92 echo "Testing base searching at $XREFDN..."
93 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
94 RC=$?
95 if test $RC != 0 ; then
96         echo "ldapsearch failed ($RC)!"
97         test $KILLSERVERS != no && kill -HUP $KILLPIDS
98         exit $RC
99 fi
100
101 echo "Testing one-level searching at $XREFDN..."
102 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
103 RC=$?
104 if test $RC != 0 ; then
105         echo "ldapsearch failed ($RC)!"
106         test $KILLSERVERS != no && kill -HUP $KILLPIDS
107         exit $RC
108 fi
109
110 echo "Testing subtree searching at $XREFDN..."
111 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
112 RC=$?
113 if test $RC != 0 ; then
114         echo "ldapsearch failed ($RC)!"
115         test $KILLSERVERS != no && kill -HUP $KILLPIDS
116         exit $RC
117 fi
118
119 XREFDN="o=abc,$REFDN"
120 echo "Testing base searching at $XREFDN..."
121 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
122 RC=$?
123 if test $RC != $RCODE ; then
124         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
125         test $KILLSERVERS != no && kill -HUP $KILLPIDS
126         exit $RC
127 fi
128
129 echo "Testing one-level searching at $XREFDN..."
130 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
131 RC=$?
132 if test $RC != $RCODE ; then
133         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
134         test $KILLSERVERS != no && kill -HUP $KILLPIDS
135         exit $RC
136 fi
137
138 echo "Testing subtree searching at $XREFDN..."
139 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
140 RC=$?
141 if test $RC != $RCODE ; then
142         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
143         test $KILLSERVERS != no && kill -HUP $KILLPIDS
144         exit $RC
145 fi
146
147 XREFDN="uid=xxx,o=abc,$REFDN"
148 echo "Testing base searching at $XREFDN..."
149 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
150 RC=$?
151 if test $RC != $RCODE ; then
152         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
153         test $KILLSERVERS != no && kill -HUP $KILLPIDS
154         exit $RC
155 fi
156
157 echo "Testing one-level searching at $XREFDN..."
158 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
159 RC=$?
160 if test $RC != $RCODE ; then
161         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
162         test $KILLSERVERS != no && kill -HUP $KILLPIDS
163         exit $RC
164 fi
165
166 echo "Testing subtree searching at $XREFDN..."
167 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
168 RC=$?
169 if test $RC != $RCODE ; then
170         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
171         test $KILLSERVERS != no && kill -HUP $KILLPIDS
172         exit $RC
173 fi
174
175 test $KILLSERVERS != no && kill -HUP $KILLPIDS
176
177 LDIF=$SEARCHOUTMASTER
178 echo "Filtering ldapsearch results..."
179 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
180 echo "Filtering expected LDIF for comparison..."
181 . $LDIFFILTER < $REFERRALOUT > $LDIFFLT
182 echo "Comparing filter output..."
183 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
184
185 if test $? != 0 ; then
186         echo "Comparison failed"
187         exit 1
188 fi
189
190 echo ">>>>> Test succeeded"
191 exit 0