Home | History | Annotate | Line # | Download | only in scripts
      1       1.1     lukem #! /bin/sh
      2   1.1.1.4      tron # $OpenLDAP$
      3       1.1     lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
      4       1.1     lukem ##
      5  1.1.1.10  christos ## Copyright 1998-2024 The OpenLDAP Foundation.
      6       1.1     lukem ## All rights reserved.
      7       1.1     lukem ##
      8       1.1     lukem ## Redistribution and use in source and binary forms, with or without
      9       1.1     lukem ## modification, are permitted only as authorized by the OpenLDAP
     10       1.1     lukem ## Public License.
     11       1.1     lukem ##
     12       1.1     lukem ## A copy of this license is available in the file LICENSE in the
     13       1.1     lukem ## top-level directory of the distribution or, alternatively, at
     14       1.1     lukem ## <http://www.OpenLDAP.org/license.html>.
     15       1.1     lukem 
     16       1.1     lukem echo "running defines.sh"
     17       1.1     lukem . $SRCDIR/scripts/defines.sh
     18       1.1     lukem 
     19       1.1     lukem #
     20       1.1     lukem # Test default referral
     21       1.1     lukem #
     22       1.1     lukem 
     23       1.1     lukem mkdir -p $TESTDIR $DBDIR1 $DBDIR2
     24       1.1     lukem 
     25       1.1     lukem echo "Running slapadd to build slapd database..."
     26   1.1.1.9  christos . $CONFFILTER $BACKEND < $CONF > $CONF1
     27       1.1     lukem $SLAPADD -f $CONF1 -l $LDIFORDERED
     28       1.1     lukem RC=$?
     29       1.1     lukem if test $RC != 0 ; then
     30       1.1     lukem 	echo "slapadd failed ($RC)!"
     31       1.1     lukem 	exit $RC
     32       1.1     lukem fi
     33       1.1     lukem 
     34   1.1.1.9  christos echo "Starting provider slapd on TCP/IP port $PORT1..."
     35   1.1.1.9  christos $SLAPD -n provider -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
     36       1.1     lukem PID=$!
     37       1.1     lukem if test $WAIT != 0 ; then
     38       1.1     lukem     echo PID $PID
     39       1.1     lukem     read foo
     40       1.1     lukem fi
     41       1.1     lukem 
     42   1.1.1.9  christos echo "Starting consumer slapd on TCP/IP port $PORT2..."
     43   1.1.1.9  christos . $CONFFILTER $BACKEND < $REFCONSUMERCONF > $CONF2
     44   1.1.1.9  christos $SLAPD -n consumer -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
     45   1.1.1.9  christos CONSUMERPID=$!
     46       1.1     lukem if test $WAIT != 0 ; then
     47   1.1.1.9  christos     echo CONSUMERPID $CONSUMERPID
     48       1.1     lukem     read foo
     49       1.1     lukem fi
     50       1.1     lukem 
     51   1.1.1.9  christos KILLPIDS="$PID $CONSUMERPID"
     52       1.1     lukem 
     53       1.1     lukem sleep 1
     54       1.1     lukem 
     55   1.1.1.9  christos echo "Testing for provider slapd..."
     56       1.1     lukem for i in 0 1 2 3 4 5; do
     57   1.1.1.9  christos 	$LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
     58       1.1     lukem 		'objectclass=*' > /dev/null 2>&1
     59       1.1     lukem 	RC=$?
     60       1.1     lukem 	if test $RC = 0 ; then
     61       1.1     lukem 		break
     62       1.1     lukem 	fi
     63   1.1.1.9  christos 	echo "Waiting 5 seconds for provider slapd to start..."
     64       1.1     lukem 	sleep 5
     65       1.1     lukem done
     66       1.1     lukem 
     67       1.1     lukem if test $RC != 0 ; then
     68       1.1     lukem 	echo "ldapsearch failed ($RC)!"
     69       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     70       1.1     lukem 	exit $RC
     71       1.1     lukem fi
     72       1.1     lukem 
     73   1.1.1.9  christos echo "Testing for consumer slapd..."
     74       1.1     lukem for i in 0 1 2 3 4 5; do
     75   1.1.1.9  christos 	$LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
     76       1.1     lukem 		'objectclass=*' > /dev/null 2>&1
     77       1.1     lukem 	RC=$?
     78       1.1     lukem 	if test $RC = 0 ; then
     79       1.1     lukem 		break
     80       1.1     lukem 	fi
     81   1.1.1.9  christos 	echo "Waiting 5 seconds for consumer slapd to start..."
     82       1.1     lukem 	sleep 5
     83       1.1     lukem done
     84       1.1     lukem 
     85       1.1     lukem cat /dev/null > $SEARCHOUT
     86       1.1     lukem 
     87       1.1     lukem echo "Testing exact searching..."
     88   1.1.1.9  christos $LDAPSEARCH -C -S "" -b "$BASEDN" -H $URI2 \
     89       1.1     lukem 	'sn=jensen' >> $SEARCHOUT 2>&1
     90       1.1     lukem RC=$?
     91       1.1     lukem if test $RC != 0 ; then
     92       1.1     lukem 	echo "ldapsearch failed ($RC)!"
     93       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     94       1.1     lukem 	exit $RC
     95       1.1     lukem fi
     96       1.1     lukem 
     97       1.1     lukem echo "Testing approximate searching..."
     98   1.1.1.9  christos $LDAPSEARCH -C -S "" -b "$BASEDN" -H $URI2 \
     99       1.1     lukem 	'(sn=jENSEN)' name >> $SEARCHOUT 2>&1
    100       1.1     lukem RC=$?
    101       1.1     lukem if test $RC != 0 ; then
    102       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    103       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    104       1.1     lukem 	exit $RC
    105       1.1     lukem fi
    106       1.1     lukem 
    107       1.1     lukem echo "Testing OR searching..."
    108   1.1.1.9  christos $LDAPSEARCH -C -S "" -b "$BASEDN" -H $URI2 \
    109       1.1     lukem 	'(|(objectclass=groupofnames)(objectClass=groupofuniquenames)(sn=jones))' >> $SEARCHOUT 2>&1
    110       1.1     lukem RC=$?
    111       1.1     lukem if test $RC != 0 ; then
    112       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    113       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    114       1.1     lukem 	exit $RC
    115       1.1     lukem fi
    116       1.1     lukem 
    117       1.1     lukem echo "Testing AND matching and ends-with searching..."
    118   1.1.1.9  christos $LDAPSEARCH -C -S "" -b "ou=groups,$BASEDN" -s one -H $URI2 \
    119       1.1     lukem 	'(&(objectclass=groupofnames)(cn=A*))' >> $SEARCHOUT 2>&1
    120       1.1     lukem RC=$?
    121       1.1     lukem if test $RC != 0 ; then
    122       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    123       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    124       1.1     lukem 	exit $RC
    125       1.1     lukem fi
    126       1.1     lukem 
    127       1.1     lukem echo "Testing NOT searching..."
    128   1.1.1.9  christos $LDAPSEARCH -C -S "" -b "$BASEDN" -H $URI2 \
    129       1.1     lukem 	'(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
    130       1.1     lukem RC=$?
    131       1.1     lukem if test $RC != 0 ; then
    132       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    133       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    134       1.1     lukem 	exit $RC
    135       1.1     lukem fi
    136       1.1     lukem 
    137       1.1     lukem echo "Testing objectClass/attributeType inheritance ..."
    138   1.1.1.9  christos $LDAPSEARCH -M -a never -S "" -b "$BASEDN" -H $URI1 \
    139       1.1     lukem 	'(&(objectClass=inetorgperson)(userid=uham))' \
    140       1.1     lukem 	"2.5.4.0" "userid" >> $SEARCHOUT 2>&1
    141       1.1     lukem RC=$?
    142       1.1     lukem if test $RC != 0 ; then
    143       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    144       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    145       1.1     lukem 	exit $RC
    146       1.1     lukem fi
    147       1.1     lukem 
    148       1.1     lukem echo "Testing dontUseCopy control..."
    149   1.1.1.9  christos $LDAPSEARCH -C -S "" -b "$BASEDN" -H $URI2 \
    150       1.1     lukem 	-E \!dontUseCopy \
    151       1.1     lukem 	'sn=jensen' >> $SEARCHOUT
    152       1.1     lukem RC=$?
    153       1.1     lukem if test $RC = 10 ; then
    154       1.1     lukem 	echo "ldapsearch failed as expected ($RC)"
    155       1.1     lukem else
    156       1.1     lukem 	echo "ldapsearch did not error as expected ($RC)!"
    157       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    158       1.1     lukem 	exit $RC
    159       1.1     lukem fi
    160       1.1     lukem 
    161       1.1     lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
    162       1.1     lukem 
    163   1.1.1.9  christos LDIF=$SEARCHOUTPROVIDER
    164       1.1     lukem 
    165       1.1     lukem echo "Filtering ldapsearch results..."
    166   1.1.1.3      adam $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
    167       1.1     lukem echo "Filtering original ldif used to create database..."
    168   1.1.1.3      adam $LDIFFILTER < $LDIF > $LDIFFLT
    169       1.1     lukem echo "Comparing filter output..."
    170       1.1     lukem $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
    171       1.1     lukem 
    172       1.1     lukem if test $? != 0 ; then
    173       1.1     lukem 	echo "Comparison failed"
    174       1.1     lukem 	exit 1
    175       1.1     lukem fi
    176       1.1     lukem 
    177       1.1     lukem echo ">>>>> Test succeeded"
    178       1.1     lukem 
    179       1.1     lukem test $KILLSERVERS != no && wait
    180       1.1     lukem 
    181       1.1     lukem exit 0
    182