Home | History | Annotate | Line # | Download | only in scripts
      1 #! /bin/sh
      2 ## $OpenLDAP$
      3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
      4 ##
      5 ## Copyright 2016-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 ## ACKNOWLEDGEMENTS:
     17 ## This module was written in 2016 by Ondej Kuznk for Symas Corp.
     18 
     19 echo "running defines.sh"
     20 . $SRCDIR/scripts/defines.sh
     21 
     22 . ${SCRIPTDIR}/common.sh
     23 
     24 echo "Testing searches against regular entries..."
     25 echo "# Testing searches against regular entries..." >> $SEARCHOUT
     26 $LDAPSEARCH -b "$BASEDN" -H $URI1 \
     27 	"(|(name=Elliot)(description=*hiker*))" \
     28 	>> $SEARCHOUT 2>&1
     29 RC=$?
     30 if test $RC != 0 ; then
     31 	echo "ldapsearch failed ($RC)!"
     32 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     33 	exit $RC
     34 fi
     35 
     36 echo "Testing searches listing variants..."
     37 echo >> $SEARCHOUT
     38 echo "# Testing searches listing variants..." >> $SEARCHOUT
     39 $LDAPSEARCH -b "$BASEDN" -s one -H $URI1 \
     40 	>> $SEARCHOUT 2>&1
     41 RC=$?
     42 if test $RC != 0 ; then
     43 	echo "ldapsearch failed ($RC)!"
     44 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     45 	exit $RC
     46 fi
     47 
     48 echo >> $SEARCHOUT
     49 $LDAPSEARCH -b "$BASEDN" -s base -H $URI1 \
     50 	>> $SEARCHOUT 2>&1
     51 RC=$?
     52 if test $RC != 0 ; then
     53 	echo "ldapsearch failed ($RC)!"
     54 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     55 	exit $RC
     56 fi
     57 
     58 echo >> $SEARCHOUT
     59 $LDAPSEARCH -s base -H $URI1 \
     60 	-b "cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN" \
     61 	'(ou=Information Technology Division)' \
     62 	>> $SEARCHOUT 2>&1
     63 RC=$?
     64 if test $RC != 0 ; then
     65 	echo "ldapsearch failed ($RC)!"
     66 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     67 	exit $RC
     68 fi
     69 
     70 echo >> $SEARCHOUT
     71 $LDAPSEARCH -b "cn=ITD Staff,ou=Groups,$BASEDN" -s base -H $URI1 \
     72 	>> $SEARCHOUT 2>&1
     73 RC=$?
     74 if test $RC != 0 ; then
     75 	echo "ldapsearch failed ($RC)!"
     76 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     77 	exit $RC
     78 fi
     79 
     80 echo "Testing searches filtering on variants..."
     81 echo >> $SEARCHOUT
     82 echo "# Testing searches filtering on variants..." >> $SEARCHOUT
     83 $LDAPSEARCH -b "$BASEDN" -H $URI1 \
     84 	"(st=Alumni Association)" st \
     85 	>> $SEARCHOUT 2>&1
     86 RC=$?
     87 if test $RC != 0 ; then
     88 	echo "ldapsearch failed ($RC)!"
     89 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     90 	exit $RC
     91 fi
     92 
     93 test $KILLSERVERS != no && kill -HUP $KILLPIDS
     94 
     95 LDIF=data/test003-out.ldif
     96 
     97 echo "Filtering ldapsearch results..."
     98 $LDIFFILTER -s e < $SEARCHOUT > $SEARCHFLT
     99 echo "Filtering expected entries..."
    100 $LDIFFILTER -s e < $LDIF > $LDIFFLT
    101 echo "Comparing filter output..."
    102 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
    103 
    104 if test $? != 0 ; then
    105 	echo "Comparison failed"
    106 	exit 1
    107 fi
    108 
    109 echo ">>>>> Test succeeded"
    110 
    111 test $KILLSERVERS != no && wait
    112 
    113 exit 0
    114