]> git.sur5r.net Git - openldap/blob - tests/scripts/test009-referral
Check ldapmodify for success.
[openldap] / tests / scripts / test009-referral
1 #! /bin/sh
2 # $OpenLDAP$
3
4 echo "running defines.sh"
5 . $SRCDIR/scripts/defines.sh
6
7 #
8 # Test default referral
9 #
10
11 mkdir $TESTDIR $DBDIR1 $DBDIR2
12
13 echo "Running slapadd to build slapd database..."
14 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
15 $SLAPADD -f $CONF1 -l $LDIFORDERED
16 RC=$?
17 if test $RC != 0 ; then
18         echo "slapadd failed ($RC)!"
19         exit $RC
20 fi
21
22 echo "Starting master slapd on TCP/IP port $PORT1..."
23 $SLAPD -n master -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
24 PID=$!
25 if test $WAIT != 0 ; then
26     echo PID $PID
27     read foo
28 fi
29
30 echo "Starting slave slapd on TCP/IP port $PORT2..."
31 . $CONFFILTER $BACKEND $MONITORDB < $REFSLAVECONF > $CONF2
32 $SLAPD -n slave -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
33 SLAVEPID=$!
34 if test $WAIT != 0 ; then
35     echo SLAVEPID $SLAVEPID
36     read foo
37 fi
38
39 KILLPIDS="$PID $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 $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 master 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 echo "Testing for slave slapd..."
60 for i in 0 1 2 3 4 5; do
61         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
62                 'objectclass=*' > /dev/null 2>&1
63         RC=$?
64         if test $RC = 0 ; then
65                 break
66         fi
67         echo "Waiting 5 seconds for slave slapd to start..."
68         sleep 5
69 done
70
71 cat /dev/null > $SEARCHOUT
72
73 echo "Testing exact searching..."
74 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
75         'sn=jensen' >> $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 OR searching..."
84 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
85         '(|(objectclass=groupofnames)(objectClass=groupofuniquenames)(sn=jones))' >> $SEARCHOUT 2>&1
86 RC=$?
87 if test $RC != 0 ; then
88         echo "ldapsearch failed ($RC)!"
89         test $KILLSERVERS != no && kill -HUP $KILLPIDS
90         exit $RC
91 fi
92
93 echo "Testing AND matching and ends-with searching..."
94 $LDAPSEARCH -C -S "" -b "ou=groups,$BASEDN" -s one -h $LOCALHOST -p $PORT2 \
95         '(&(objectclass=groupofnames)(cn=A*))' >> $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 NOT searching..."
104 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
105         '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
106 RC=$?
107 if test $RC != 0 ; then
108         echo "ldapsearch failed ($RC)!"
109         test $KILLSERVERS != no && kill -HUP $KILLPIDS
110         exit $RC
111 fi
112
113 echo "Testing objectClass/attributeType inheritance ..."
114 $LDAPSEARCH -M -a never -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
115         '(&(objectClass=inetorgperson)(userid=uham))' \
116         "2.5.4.0" "userid" >> $SEARCHOUT 2>&1
117 RC=$?
118 if test $RC != 0 ; then
119         echo "ldapsearch failed ($RC)!"
120         test $KILLSERVERS != no && kill -HUP $KILLPIDS
121         exit $RC
122 fi
123
124
125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126
127 LDIF=$SEARCHOUTMASTER
128
129 echo "Filtering ldapsearch results..."
130 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
131 echo "Filtering original ldif used to create database..."
132 . $LDIFFILTER < $LDIF > $LDIFFLT
133 echo "Comparing filter output..."
134 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
135
136 if test $? != 0 ; then
137         echo "Comparison failed"
138         exit 1
139 fi
140
141 echo ">>>>> Test succeeded"
142 exit 0