]> git.sur5r.net Git - openldap/blob - tests/scripts/test009-referral
e9781843a0cf1de1ea3e58150dba76f24aa64391
[openldap] / tests / scripts / test009-referral
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2005 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 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 #
20 # Test default referral
21 #
22
23 mkdir $TESTDIR $DBDIR1 $DBDIR2
24
25 echo "Running slapadd to build slapd database..."
26 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
27 $SLAPADD -f $CONF1 -l $LDIFORDERED
28 RC=$?
29 if test $RC != 0 ; then
30         echo "slapadd failed ($RC)!"
31         exit $RC
32 fi
33
34 echo "Starting master slapd on TCP/IP port $PORT1..."
35 $SLAPD -n master -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
36 PID=$!
37 if test $WAIT != 0 ; then
38     echo PID $PID
39     read foo
40 fi
41
42 echo "Starting slave slapd on TCP/IP port $PORT2..."
43 . $CONFFILTER $BACKEND $MONITORDB < $REFSLAVECONF > $CONF2
44 $SLAPD -n slave -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
45 SLAVEPID=$!
46 if test $WAIT != 0 ; then
47     echo SLAVEPID $SLAVEPID
48     read foo
49 fi
50
51 KILLPIDS="$PID $SLAVEPID"
52
53 echo "Testing for master slapd..."
54 for i in 0 1 2 3 4 5; do
55         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
56                 'objectclass=*' > /dev/null 2>&1
57         RC=$?
58         if test $RC = 0 ; then
59                 break
60         fi
61         echo "Waiting 5 seconds for master slapd to start..."
62         sleep 5
63 done
64
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 for slave slapd..."
72 for i in 0 1 2 3 4 5; do
73         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
74                 'objectclass=*' > /dev/null 2>&1
75         RC=$?
76         if test $RC = 0 ; then
77                 break
78         fi
79         echo "Waiting 5 seconds for slave slapd to start..."
80         sleep 5
81 done
82
83 cat /dev/null > $SEARCHOUT
84
85 echo "Testing exact searching..."
86 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
87         'sn=jensen' >> $SEARCHOUT 2>&1
88 RC=$?
89 if test $RC != 0 ; then
90         echo "ldapsearch failed ($RC)!"
91         test $KILLSERVERS != no && kill -HUP $KILLPIDS
92         exit $RC
93 fi
94
95 echo "Testing approximate searching..."
96 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
97         '(sn=jENSEN)' name >> $SEARCHOUT 2>&1
98 RC=$?
99 if test $RC != 0 ; then
100         echo "ldapsearch failed ($RC)!"
101         test $KILLSERVERS != no && kill -HUP $KILLPIDS
102         exit $RC
103 fi
104
105 echo "Testing OR searching..."
106 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
107         '(|(objectclass=groupofnames)(objectClass=groupofuniquenames)(sn=jones))' >> $SEARCHOUT 2>&1
108 RC=$?
109 if test $RC != 0 ; then
110         echo "ldapsearch failed ($RC)!"
111         test $KILLSERVERS != no && kill -HUP $KILLPIDS
112         exit $RC
113 fi
114
115 echo "Testing AND matching and ends-with searching..."
116 $LDAPSEARCH -C -S "" -b "ou=groups,$BASEDN" -s one -h $LOCALHOST -p $PORT2 \
117         '(&(objectclass=groupofnames)(cn=A*))' >> $SEARCHOUT 2>&1
118 RC=$?
119 if test $RC != 0 ; then
120         echo "ldapsearch failed ($RC)!"
121         test $KILLSERVERS != no && kill -HUP $KILLPIDS
122         exit $RC
123 fi
124
125 echo "Testing NOT searching..."
126 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
127         '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
128 RC=$?
129 if test $RC != 0 ; then
130         echo "ldapsearch failed ($RC)!"
131         test $KILLSERVERS != no && kill -HUP $KILLPIDS
132         exit $RC
133 fi
134
135 echo "Testing objectClass/attributeType inheritance ..."
136 $LDAPSEARCH -M -a never -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
137         '(&(objectClass=inetorgperson)(userid=uham))' \
138         "2.5.4.0" "userid" >> $SEARCHOUT 2>&1
139 RC=$?
140 if test $RC != 0 ; then
141         echo "ldapsearch failed ($RC)!"
142         test $KILLSERVERS != no && kill -HUP $KILLPIDS
143         exit $RC
144 fi
145
146
147 test $KILLSERVERS != no && kill -HUP $KILLPIDS
148
149 LDIF=$SEARCHOUTMASTER
150
151 echo "Filtering ldapsearch results..."
152 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
153 echo "Filtering original ldif used to create database..."
154 . $LDIFFILTER < $LDIF > $LDIFFLT
155 echo "Comparing filter output..."
156 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
157
158 if test $? != 0 ; then
159         echo "Comparison failed"
160         exit 1
161 fi
162
163 echo ">>>>> Test succeeded"
164 exit 0