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