1*e670fd5cSchristos#! /bin/sh 2*e670fd5cSchristos# $OpenLDAP$ 3*e670fd5cSchristos## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4*e670fd5cSchristos## 5*e670fd5cSchristos## Copyright 1998-2021 The OpenLDAP Foundation. 6*e670fd5cSchristos## All rights reserved. 7*e670fd5cSchristos## 8*e670fd5cSchristos## Redistribution and use in source and binary forms, with or without 9*e670fd5cSchristos## modification, are permitted only as authorized by the OpenLDAP 10*e670fd5cSchristos## Public License. 11*e670fd5cSchristos## 12*e670fd5cSchristos## A copy of this license is available in the file LICENSE in the 13*e670fd5cSchristos## top-level directory of the distribution or, alternatively, at 14*e670fd5cSchristos## <http://www.OpenLDAP.org/license.html>. 15*e670fd5cSchristos 16*e670fd5cSchristosecho "running defines.sh" 17*e670fd5cSchristos. $SRCDIR/scripts/defines.sh 18*e670fd5cSchristos 19*e670fd5cSchristosmkdir -p $TESTDIR $DBDIR1 $DBDIR2 20*e670fd5cSchristos 21*e670fd5cSchristos$SLAPPASSWD -g -n >$CONFIGPWF 22*e670fd5cSchristosecho "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf 23*e670fd5cSchristos 24*e670fd5cSchristosecho "Starting an empty slapd on TCP/IP port $PORT2..." 25*e670fd5cSchristos. $CONFFILTER $BACKEND < $SCHEMACONF > $CONF2 26*e670fd5cSchristos$SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 & 27*e670fd5cSchristosPID=$! 28*e670fd5cSchristosif test $WAIT != 0 ; then 29*e670fd5cSchristos echo PID $PID 30*e670fd5cSchristos read foo 31*e670fd5cSchristosfi 32*e670fd5cSchristosPID2="$PID" 33*e670fd5cSchristosKILLPIDS="$PID" 34*e670fd5cSchristos 35*e670fd5cSchristosecho "Testing slapd searching..." 36*e670fd5cSchristosfor i in 0 1 2 3 4 5; do 37*e670fd5cSchristos $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \ 38*e670fd5cSchristos '(objectclass=*)' > /dev/null 2>&1 39*e670fd5cSchristos RC=$? 40*e670fd5cSchristos if test $RC = 0 ; then 41*e670fd5cSchristos break 42*e670fd5cSchristos fi 43*e670fd5cSchristos echo "Waiting $SLEEP1 seconds for slapd to start..." 44*e670fd5cSchristos sleep $SLEEP1 45*e670fd5cSchristosdone 46*e670fd5cSchristosif test $RC != 0 ; then 47*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 48*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 49*e670fd5cSchristos exit $RC 50*e670fd5cSchristosfi 51*e670fd5cSchristos 52*e670fd5cSchristosecho "Running slapadd to build slapd database..." 53*e670fd5cSchristos. $CONFFILTER $BACKEND < $CONFTWO > $CONF3 54*e670fd5cSchristos$SLAPADD -f $CONF3 -l $LDIFORDERED 55*e670fd5cSchristosRC=$? 56*e670fd5cSchristosif test $RC != 0 ; then 57*e670fd5cSchristos echo "slapadd failed ($RC)!" 58*e670fd5cSchristos exit $RC 59*e670fd5cSchristosfi 60*e670fd5cSchristos 61*e670fd5cSchristosecho "Running slapindex to index slapd database..." 62*e670fd5cSchristos$SLAPINDEX -f $CONF3 63*e670fd5cSchristosRC=$? 64*e670fd5cSchristosif test $RC != 0 ; then 65*e670fd5cSchristos echo "warning: slapindex failed ($RC)" 66*e670fd5cSchristos echo " assuming no indexing support" 67*e670fd5cSchristosfi 68*e670fd5cSchristos 69*e670fd5cSchristosecho "Starting second slapd on TCP/IP port $PORT3..." 70*e670fd5cSchristos$SLAPD -f $CONF3 -h $URI3 -d $LVL > $LOG3 2>&1 & 71*e670fd5cSchristosPID=$! 72*e670fd5cSchristosif test $WAIT != 0 ; then 73*e670fd5cSchristos echo PID $PID 74*e670fd5cSchristos read foo 75*e670fd5cSchristosfi 76*e670fd5cSchristosPID3="$PID" 77*e670fd5cSchristosKILLPIDS="$KILLPIDS $PID" 78*e670fd5cSchristos 79*e670fd5cSchristossleep $SLEEP0 80*e670fd5cSchristos 81*e670fd5cSchristosecho "Testing slapd searching..." 82*e670fd5cSchristosfor i in 0 1 2 3 4 5; do 83*e670fd5cSchristos $LDAPSEARCH -s base -b "$MONITOR" -H $URI3 \ 84*e670fd5cSchristos '(objectclass=*)' > /dev/null 2>&1 85*e670fd5cSchristos RC=$? 86*e670fd5cSchristos if test $RC = 0 ; then 87*e670fd5cSchristos break 88*e670fd5cSchristos fi 89*e670fd5cSchristos echo "Waiting $SLEEP1 seconds for slapd to start..." 90*e670fd5cSchristos sleep $SLEEP1 91*e670fd5cSchristosdone 92*e670fd5cSchristosif test $RC != 0 ; then 93*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 94*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 95*e670fd5cSchristos exit $RC 96*e670fd5cSchristosfi 97*e670fd5cSchristos 98*e670fd5cSchristosecho "Starting lloadd on TCP/IP port $PORT1..." 99*e670fd5cSchristos. $CONFFILTER $BACKEND < $LLOADDUNREACHABLECONF > $CONF1.lloadd 100*e670fd5cSchristosif test $AC_lloadd = lloaddyes; then 101*e670fd5cSchristos $LLOADD -f $CONF1.lloadd -h $URI1 -d $LVL > $LOG1 2>&1 & 102*e670fd5cSchristoselse 103*e670fd5cSchristos . $CONFFILTER $BACKEND < $SLAPDLLOADCONF > $CONF1.slapd 104*e670fd5cSchristos $SLAPD -f $CONF1.slapd -h $URI6 -d $LVL > $LOG1 2>&1 & 105*e670fd5cSchristosfi 106*e670fd5cSchristosPID=$! 107*e670fd5cSchristosif test $WAIT != 0 ; then 108*e670fd5cSchristos echo PID $PID 109*e670fd5cSchristos read foo 110*e670fd5cSchristosfi 111*e670fd5cSchristosKILLPIDS="$KILLPIDS $PID" 112*e670fd5cSchristos 113*e670fd5cSchristosecho "Testing slapd searching..." 114*e670fd5cSchristosfor i in 0 1 2 3 4 5; do 115*e670fd5cSchristos $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ 116*e670fd5cSchristos '(objectclass=*)' > /dev/null 2>&1 117*e670fd5cSchristos RC=$? 118*e670fd5cSchristos if test $RC = 0 ; then 119*e670fd5cSchristos break 120*e670fd5cSchristos fi 121*e670fd5cSchristos echo "Waiting $SLEEP1 seconds for lloadd to start..." 122*e670fd5cSchristos sleep $SLEEP1 123*e670fd5cSchristosdone 124*e670fd5cSchristos 125*e670fd5cSchristosif test $RC != 0 ; then 126*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 127*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 128*e670fd5cSchristos exit $RC 129*e670fd5cSchristosfi 130*e670fd5cSchristos 131*e670fd5cSchristosecho "Testing exact searching..." 132*e670fd5cSchristosecho "# Testing exact searching..." > $SEARCHOUT 133*e670fd5cSchristos$LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \ 134*e670fd5cSchristos '(sn=jENSEN)' >> $SEARCHOUT 2>&1 135*e670fd5cSchristosRC=$? 136*e670fd5cSchristosif test $RC != 0 ; then 137*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 138*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 139*e670fd5cSchristos exit $RC 140*e670fd5cSchristosfi 141*e670fd5cSchristos 142*e670fd5cSchristosecho "Testing approximate searching..." 143*e670fd5cSchristosecho "# Testing approximate searching..." >> $SEARCHOUT 144*e670fd5cSchristos$LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \ 145*e670fd5cSchristos '(sn~=jENSEN)' name >> $SEARCHOUT 2>&1 146*e670fd5cSchristosRC=$? 147*e670fd5cSchristosif test $RC != 0 ; then 148*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 149*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 150*e670fd5cSchristos exit $RC 151*e670fd5cSchristosfi 152*e670fd5cSchristos 153*e670fd5cSchristosecho "Testing OR searching..." 154*e670fd5cSchristosecho "# Testing OR searching..." >> $SEARCHOUT 155*e670fd5cSchristos$LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \ 156*e670fd5cSchristos '(|(givenname=Xx*yY*Z)(cn=)(undef=*)(objectclass=groupofnames)(sn=jones)(member=cn=Manager,dc=example,dc=com)(uniqueMember=cn=Manager,dc=example,dc=com))' >> $SEARCHOUT 2>&1 157*e670fd5cSchristosRC=$? 158*e670fd5cSchristosif test $RC != 0 ; then 159*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 160*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 161*e670fd5cSchristos exit $RC 162*e670fd5cSchristosfi 163*e670fd5cSchristos 164*e670fd5cSchristosecho "Testing AND matching and ends-with searching..." 165*e670fd5cSchristosecho "# Testing AND matching and ends-with searching..." >> $SEARCHOUT 166*e670fd5cSchristos$LDAPSEARCH -S "" -b "ou=groups,$BASEDN" -s one -H $URI1 \ 167*e670fd5cSchristos '(&(objectclass=groupofnames)(cn=A*)(member=cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com))' >> $SEARCHOUT 2>&1 168*e670fd5cSchristosRC=$? 169*e670fd5cSchristosif test $RC != 0 ; then 170*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 171*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 172*e670fd5cSchristos exit $RC 173*e670fd5cSchristosfi 174*e670fd5cSchristos 175*e670fd5cSchristosecho "Testing NOT searching..." 176*e670fd5cSchristosecho "# Testing NOT searching..." >> $SEARCHOUT 177*e670fd5cSchristos$LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \ 178*e670fd5cSchristos '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1 179*e670fd5cSchristosRC=$? 180*e670fd5cSchristosif test $RC != 0 ; then 181*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 182*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 183*e670fd5cSchristos exit $RC 184*e670fd5cSchristosfi 185*e670fd5cSchristos 186*e670fd5cSchristosecho "Testing objectClass/attributeType inheritance ..." 187*e670fd5cSchristosecho "# Testing objectClass/attributeType inheritance ..." >> $SEARCHOUT 188*e670fd5cSchristos$LDAPSEARCH -M -a never -S "" -b "$BASEDN" -H $URI1 \ 189*e670fd5cSchristos '(&(objectClass=inetorgperson)(userid=uham))' \ 190*e670fd5cSchristos "2.5.4.0" "userid" >> $SEARCHOUT 2>&1 191*e670fd5cSchristosRC=$? 192*e670fd5cSchristosif test $RC != 0 ; then 193*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 194*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 195*e670fd5cSchristos exit $RC 196*e670fd5cSchristosfi 197*e670fd5cSchristos 198*e670fd5cSchristostest $KILLSERVERS != no && kill -HUP $KILLPIDS 199*e670fd5cSchristos 200*e670fd5cSchristosLDIF=$SEARCHOUTPROVIDER 201*e670fd5cSchristos 202*e670fd5cSchristosecho "Filtering ldapsearch results..." 203*e670fd5cSchristos$LDIFFILTER < $SEARCHOUT > $SEARCHFLT 204*e670fd5cSchristosecho "Filtering original ldif used to create database..." 205*e670fd5cSchristos$LDIFFILTER < $LDIF > $LDIFFLT 206*e670fd5cSchristosecho "Comparing filter output..." 207*e670fd5cSchristos$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 208*e670fd5cSchristos 209*e670fd5cSchristosif test $? != 0 ; then 210*e670fd5cSchristos echo "Comparison failed" 211*e670fd5cSchristos exit 1 212*e670fd5cSchristosfi 213*e670fd5cSchristos 214*e670fd5cSchristosecho ">>>>> Test succeeded" 215*e670fd5cSchristos 216*e670fd5cSchristostest $KILLSERVERS != no && wait 217*e670fd5cSchristos 218*e670fd5cSchristosexit 0 219