3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2004 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
20 # Test default referral
23 mkdir $TESTDIR $DBDIR1 $DBDIR2
25 echo "Running slapadd to build slapd database..."
26 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
27 $SLAPADD -f $CONF1 -l $LDIFORDERED
29 if test $RC != 0 ; then
30 echo "slapadd failed ($RC)!"
34 echo "Starting master slapd on TCP/IP port $PORT1..."
35 $SLAPD -n master -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
37 if test $WAIT != 0 ; then
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 &
46 if test $WAIT != 0 ; then
47 echo SLAVEPID $SLAVEPID
51 KILLPIDS="$PID $SLAVEPID"
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
58 if test $RC = 0 ; then
61 echo "Waiting 5 seconds for master slapd to start..."
65 if test $RC != 0 ; then
66 echo "ldapsearch failed ($RC)!"
67 test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
76 if test $RC = 0 ; then
79 echo "Waiting 5 seconds for slave slapd to start..."
83 cat /dev/null > $SEARCHOUT
85 echo "Testing exact searching..."
86 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
87 'sn=jensen' >> $SEARCHOUT 2>&1
89 if test $RC != 0 ; then
90 echo "ldapsearch failed ($RC)!"
91 test $KILLSERVERS != no && kill -HUP $KILLPIDS
95 echo "Testing approximate searching..."
96 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
97 '(sn=jENSEN)' name >> $SEARCHOUT 2>&1
99 if test $RC != 0 ; then
100 echo "ldapsearch failed ($RC)!"
101 test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
109 if test $RC != 0 ; then
110 echo "ldapsearch failed ($RC)!"
111 test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
119 if test $RC != 0 ; then
120 echo "ldapsearch failed ($RC)!"
121 test $KILLSERVERS != no && kill -HUP $KILLPIDS
125 echo "Testing NOT searching..."
126 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
127 '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
129 if test $RC != 0 ; then
130 echo "ldapsearch failed ($RC)!"
131 test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
140 if test $RC != 0 ; then
141 echo "ldapsearch failed ($RC)!"
142 test $KILLSERVERS != no && kill -HUP $KILLPIDS
147 test $KILLSERVERS != no && kill -HUP $KILLPIDS
149 LDIF=$SEARCHOUTMASTER
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
158 if test $? != 0 ; then
159 echo "Comparison failed"
163 echo ">>>>> Test succeeded"