]> git.sur5r.net Git - openldap/blob - tests/scripts/test016-subref
Happy new year! (belated)
[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-2008 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 -p $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 sleep 1
42
43 echo "Testing slapd searching..."
44 for i in 0 1 2 3 4 5; do
45         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
46                 '(objectclass=*)' > /dev/null 2>&1
47         RC=$?
48         if test $RC = 0 ; then
49                 break
50         fi
51         echo "Waiting 5 seconds for slapd to start..."
52         sleep 5
53 done
54
55 if test $RC != 0 ; then
56         echo "ldapsearch failed ($RC)!"
57         test $KILLSERVERS != no && kill -HUP $KILLPIDS
58         exit $RC
59 fi
60
61 cat /dev/null > $SEARCHOUT
62
63 echo "Testing ManageDsaIT searching at $REFDN..."
64 $LDAPRSEARCH -S "" -MM -b "$REFDN" -h $LOCALHOST -p $PORT1 \
65         '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
66 RC=$?
67 if test $RC != 0 ; then
68         echo "ldapsearch failed ($RC)!"
69         test $KILLSERVERS != no && kill -HUP $KILLPIDS
70         exit $RC
71 fi
72
73 echo "Testing ManageDsaIT searching at referral object..."
74 $LDAPRSEARCH -S "" -MM -b "o=abc,$REFDN" -h $LOCALHOST -p $PORT1 \
75         '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
76 RC=$?
77 if test $RC != 0 ; then
78         echo "ldapsearch failed ($RC)!"
79         test $KILLSERVERS != no && kill -HUP $KILLPIDS
80         exit $RC
81 fi
82
83 echo "Testing ManageDsaIT searching below referral object..."
84 $LDAPRSEARCH -S "" -MM -b "uid=xxx,o=abc,$REFDN" -h $LOCALHOST -p $PORT1 \
85         '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
86 RC=$?
87 if test $RC != $RCODE ; then
88         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
89         test $KILLSERVERS != no && kill -HUP $KILLPIDS
90         exit $RC
91 fi
92
93 XREFDN="$REFDN"
94 echo "Testing base searching at $XREFDN..."
95 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
96 RC=$?
97 if test $RC != 0 ; then
98         echo "ldapsearch failed ($RC)!"
99         test $KILLSERVERS != no && kill -HUP $KILLPIDS
100         exit $RC
101 fi
102
103 echo "Testing one-level searching at $XREFDN..."
104 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
105 RC=$?
106 if test $RC != 0 ; then
107         echo "ldapsearch failed ($RC)!"
108         test $KILLSERVERS != no && kill -HUP $KILLPIDS
109         exit $RC
110 fi
111
112 echo "Testing subtree searching at $XREFDN..."
113 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
114 RC=$?
115 if test $RC != 0 ; then
116         echo "ldapsearch failed ($RC)!"
117         test $KILLSERVERS != no && kill -HUP $KILLPIDS
118         exit $RC
119 fi
120
121 XREFDN="o=abc,$REFDN"
122 echo "Testing base searching at $XREFDN..."
123 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
124 RC=$?
125 if test $RC != $RCODE ; then
126         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
127         test $KILLSERVERS != no && kill -HUP $KILLPIDS
128         exit $RC
129 fi
130
131 echo "Testing one-level searching at $XREFDN..."
132 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
133 RC=$?
134 if test $RC != $RCODE ; then
135         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
136         test $KILLSERVERS != no && kill -HUP $KILLPIDS
137         exit $RC
138 fi
139
140 echo "Testing subtree searching at $XREFDN..."
141 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
142 RC=$?
143 if test $RC != $RCODE ; then
144         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
145         test $KILLSERVERS != no && kill -HUP $KILLPIDS
146         exit $RC
147 fi
148
149 XREFDN="uid=xxx,o=abc,$REFDN"
150 echo "Testing base searching at $XREFDN..."
151 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
152 RC=$?
153 if test $RC != $RCODE ; then
154         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
155         test $KILLSERVERS != no && kill -HUP $KILLPIDS
156         exit $RC
157 fi
158
159 echo "Testing one-level searching at $XREFDN..."
160 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
161 RC=$?
162 if test $RC != $RCODE ; then
163         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
164         test $KILLSERVERS != no && kill -HUP $KILLPIDS
165         exit $RC
166 fi
167
168 echo "Testing subtree searching at $XREFDN..."
169 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
170 RC=$?
171 if test $RC != $RCODE ; then
172         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
173         test $KILLSERVERS != no && kill -HUP $KILLPIDS
174         exit $RC
175 fi
176
177 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178
179 LDIF=$SEARCHOUTMASTER
180 echo "Filtering ldapsearch results..."
181 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
182 echo "Filtering expected LDIF for comparison..."
183 . $LDIFFILTER < $REFERRALOUT > $LDIFFLT
184 echo "Comparing filter output..."
185 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
186
187 if test $? != 0 ; then
188         echo "Comparison failed"
189         exit 1
190 fi
191
192 echo ">>>>> Test succeeded"
193 exit 0