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