1#! /bin/sh 2# OpenLDAP: pkg/ldap/tests/scripts/test016-subref,v 1.12.2.4 2009/01/22 00:01:19 kurt Exp 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 1998-2009 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 16RCODE=10 17 18echo "running defines.sh" 19. $SRCDIR/scripts/defines.sh 20 21mkdir -p $TESTDIR $DBDIR1 22 23echo "Running slapadd to build slapd database..." 24. $CONFFILTER $BACKEND $MONITORDB < $RCONF > $CONF1 25$SLAPADD -f $CONF1 -l $LDIFREF 26RC=$? 27if test $RC != 0 ; then 28 echo "slapadd failed ($RC)!" 29 exit $RC 30fi 31 32echo "Starting slapd on TCP/IP port $PORT1..." 33$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & 34PID=$! 35if test $WAIT != 0 ; then 36 echo PID $PID 37 read foo 38fi 39KILLPIDS="$PID" 40 41sleep 1 42 43echo "Testing slapd searching..." 44for 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 53done 54 55if test $RC != 0 ; then 56 echo "ldapsearch failed ($RC)!" 57 test $KILLSERVERS != no && kill -HUP $KILLPIDS 58 exit $RC 59fi 60 61cat /dev/null > $SEARCHOUT 62 63echo "Testing ManageDsaIT searching at $REFDN..." 64$LDAPRSEARCH -S "" -MM -b "$REFDN" -h $LOCALHOST -p $PORT1 \ 65 '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1 66RC=$? 67if test $RC != 0 ; then 68 echo "ldapsearch failed ($RC)!" 69 test $KILLSERVERS != no && kill -HUP $KILLPIDS 70 exit $RC 71fi 72 73echo "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 76RC=$? 77if test $RC != 0 ; then 78 echo "ldapsearch failed ($RC)!" 79 test $KILLSERVERS != no && kill -HUP $KILLPIDS 80 exit $RC 81fi 82 83echo "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 86RC=$? 87if test $RC != $RCODE ; then 88 echo "ldapsearch: unexpected result ($RC)! (referral expected)" 89 test $KILLSERVERS != no && kill -HUP $KILLPIDS 90 exit $RC 91fi 92 93XREFDN="$REFDN" 94echo "Testing base searching at $XREFDN..." 95$LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1 96RC=$? 97if test $RC != 0 ; then 98 echo "ldapsearch failed ($RC)!" 99 test $KILLSERVERS != no && kill -HUP $KILLPIDS 100 exit $RC 101fi 102 103echo "Testing one-level searching at $XREFDN..." 104$LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1 105RC=$? 106if test $RC != 0 ; then 107 echo "ldapsearch failed ($RC)!" 108 test $KILLSERVERS != no && kill -HUP $KILLPIDS 109 exit $RC 110fi 111 112echo "Testing subtree searching at $XREFDN..." 113$LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1 114RC=$? 115if test $RC != 0 ; then 116 echo "ldapsearch failed ($RC)!" 117 test $KILLSERVERS != no && kill -HUP $KILLPIDS 118 exit $RC 119fi 120 121XREFDN="o=abc,$REFDN" 122echo "Testing base searching at $XREFDN..." 123$LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1 124RC=$? 125if test $RC != $RCODE ; then 126 echo "ldapsearch: unexpected result ($RC)! (referral expected)" 127 test $KILLSERVERS != no && kill -HUP $KILLPIDS 128 exit $RC 129fi 130 131echo "Testing one-level searching at $XREFDN..." 132$LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1 133RC=$? 134if test $RC != $RCODE ; then 135 echo "ldapsearch: unexpected result ($RC)! (referral expected)" 136 test $KILLSERVERS != no && kill -HUP $KILLPIDS 137 exit $RC 138fi 139 140echo "Testing subtree searching at $XREFDN..." 141$LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1 142RC=$? 143if test $RC != $RCODE ; then 144 echo "ldapsearch: unexpected result ($RC)! (referral expected)" 145 test $KILLSERVERS != no && kill -HUP $KILLPIDS 146 exit $RC 147fi 148 149XREFDN="uid=xxx,o=abc,$REFDN" 150echo "Testing base searching at $XREFDN..." 151$LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1 152RC=$? 153if test $RC != $RCODE ; then 154 echo "ldapsearch: unexpected result ($RC)! (referral expected)" 155 test $KILLSERVERS != no && kill -HUP $KILLPIDS 156 exit $RC 157fi 158 159echo "Testing one-level searching at $XREFDN..." 160$LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1 161RC=$? 162if test $RC != $RCODE ; then 163 echo "ldapsearch: unexpected result ($RC)! (referral expected)" 164 test $KILLSERVERS != no && kill -HUP $KILLPIDS 165 exit $RC 166fi 167 168echo "Testing subtree searching at $XREFDN..." 169$LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1 170RC=$? 171if test $RC != $RCODE ; then 172 echo "ldapsearch: unexpected result ($RC)! (referral expected)" 173 test $KILLSERVERS != no && kill -HUP $KILLPIDS 174 exit $RC 175fi 176 177test $KILLSERVERS != no && kill -HUP $KILLPIDS 178 179LDIF=$SEARCHOUTMASTER 180echo "Filtering ldapsearch results..." 181. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT 182echo "Filtering expected LDIF for comparison..." 183. $LDIFFILTER < $REFERRALOUT > $LDIFFLT 184echo "Comparing filter output..." 185$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 186 187if test $? != 0 ; then 188 echo "Comparison failed" 189 exit 1 190fi 191 192echo ">>>>> Test succeeded" 193 194test $KILLSERVERS != no && wait 195 196exit 0 197