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