]> git.sur5r.net Git - openldap/blob - tests/scripts/test009-referral
Add OpenLDAP RCS id
[openldap] / tests / scripts / test009-referral
1 #! /bin/sh
2 # $OpenLDAP$
3
4 #
5 # Test default referral
6 #
7
8 if test $# -eq 0 ; then
9         SRCDIR="."
10 else
11         SRCDIR=$1; shift
12 fi
13 if test $# -eq 1 ; then
14         BACKEND=$1; shift
15 fi
16
17 echo "running defines.sh $SRCDIR $BACKEND"
18 . $SRCDIR/scripts/defines.sh
19
20 echo "Cleaning up in $DBDIR and $REPLDIR ..."
21
22 rm -f $DBDIR/[!C]*
23 rm -f $REPLDIR/[!C]*
24
25 echo "Running slapadd to build slapd database..."
26 $LDIF2LDBM -f $CONF -l $LDIF
27 RC=$?
28 if test $RC != 0 ; then
29         echo "slapadd failed!"
30         exit $RC
31 fi
32
33 echo "Starting master slapd on TCP/IP port $PORT..."
34 $SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
35 PID=$!
36
37 echo "Starting slave slapd on TCP/IP port $SLAVEPORT..."
38 $SLAPD -f $REFSLAVECONF -p $SLAVEPORT -d $LVL $TIMING > $SLAVELOG 2>&1 &
39 SLAVEPID=$!
40
41 echo "Testing for master slapd..."
42 for i in 0 1 2 3 4 5; do
43         $LDAPSEARCH -s base -b "$MONITOR" -h localhost -p $PORT \
44                 'objectclass=*' > /dev/null 2>&1
45         RC=$?
46         if test $RC = 1 ; then
47                 echo "Waiting 5 seconds for slapd to start..."
48                 sleep 5
49         fi
50 done
51
52 if test $RC != 0 ; then
53         echo "ldapsearch failed!"
54         kill -HUP $PID
55         exit $RC
56 fi
57
58 echo "Testing for slave slapd..."
59 for i in 0 1 2 3 4 5; do
60         $LDAPSEARCH -s base -b "$MONITOR" -h localhost -p $SLAVEPORT \
61                 'objectclass=*' > /dev/null 2>&1
62         RC=$?
63         if test $RC = 1 ; then
64                 echo "Waiting 5 seconds for slapd to start..."
65                 sleep 5
66         fi
67 done
68
69 cat /dev/null > $SEARCHOUT
70
71 echo "Testing exact searching..."
72 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $SLAVEPORT \
73         'sn=jensen' >> $SEARCHOUT 2>&1
74 if test $RC != 0 ; then
75         echo "ldapsearch failed!"
76         kill -HUP $PID $SLAVEPID
77         exit $RC
78 fi
79
80 echo "Testing OR searching..."
81 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $SLAVEPORT \
82         '(|(objectclass=rfc822mailgroup)(sn=jones))' >> $SEARCHOUT 2>&1
83 if test $RC != 0 ; then
84         echo "ldapsearch failed!"
85         kill -HUP $PID $SLAVEPID
86         exit $RC
87 fi
88
89 echo "Testing AND matching and ends-with searching..."
90 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $SLAVEPORT \
91         '(&(objectclass=rfc822mailgroup)(cn=A*))' >> $SEARCHOUT 2>&1
92 if test $RC != 0 ; then
93         echo "ldapsearch failed!"
94         kill -HUP $PID $SLAVEPID
95         exit $RC
96 fi
97
98 echo "Testing NOT searching..."
99 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $SLAVEPORT \
100         '(!(objectclass=person))' >> $SEARCHOUT 2>&1
101 if test $RC != 0 ; then
102         echo "ldapsearch failed!"
103         kill -HUP $PID $SLAVEPID
104         exit $RC
105 fi
106
107 kill -HUP $PID $SLAVEPID
108
109 LDIF=$SEARCHOUTMASTER
110
111 echo "Filtering ldapsearch results..."
112 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
113 echo "Filtering original ldif used to create database..."
114 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
115 echo "Comparing filter output..."
116 cmp $SEARCHFLT $LDIFFLT
117
118 if test $? != 0 ; then
119         echo "Comparison failed"
120         exit 1
121 fi
122
123 echo ">>>>> Test succeeded"
124
125
126 exit 0