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 echo "running defines.sh" 17 . $SRCDIR/scripts/defines.sh 18 19 mkdir -p $TESTDIR $DBDIR1 20 21 echo "Running slapadd to build slapd database..." 22 . $CONFFILTER $BACKEND < $CONF > $CONF1 23 $SLAPADD -f $CONF1 -l $LDIFORDERED 24 RC=$? 25 if test $RC != 0 ; then 26 echo "slapadd failed ($RC)!" 27 exit $RC 28 fi 29 30 echo "Starting slapd on TCP/IP port $PORT1..." 31 $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 & 32 PID=$! 33 if test $WAIT != 0 ; then 34 echo PID $PID 35 read foo 36 fi 37 KILLPIDS="$PID" 38 39 sleep 1 40 41 echo "Testing slapd modify operations..." 42 for i in 0 1 2 3 4 5; do 43 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ 44 'objectclass=*' > /dev/null 2>&1 45 RC=$? 46 if test $RC = 0 ; then 47 break 48 fi 49 echo "Waiting 5 seconds for slapd to start..." 50 sleep 5 51 done 52 53 if test $RC != 0 ; then 54 echo "ldapsearch failed ($RC)!" 55 test $KILLSERVERS != no && kill -HUP $KILLPIDS 56 exit $RC 57 fi 58 59 echo "Testing modify, add, and delete..." 60 $LDAPMODIFY -v -D "$MANAGERDN" -H $URI1 -w $PASSWD > \ 61 $TESTOUT -f $LDIFMODIFY 62 RC=$? 63 if test $RC != 0 ; then 64 echo "ldapmodify failed ($RC)!" 65 test $KILLSERVERS != no && kill -HUP $KILLPIDS 66 exit $RC 67 fi 68 69 echo "Using ldapmodify to add an empty entry (should fail with protocolError)..." 70 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 71 >> $TESTOUT 2>&1 << EOMODS 72 dn: cn=Foo Bar,dc=example,dc=com 73 changetype: add 74 # EMPTY SEQUENCE OF ATTRS 75 EOMODS 76 77 RC=$? 78 case $RC in 79 2) 80 echo " ldapmodify failed ($RC)" 81 ;; 82 0) 83 echo " ldapmodify should have failed ($RC)!" 84 test $KILLSERVERS != no && kill -HUP $KILLPIDS 85 exit 1 86 ;; 87 *) 88 echo " ldapmodify failed ($RC)!" 89 test $KILLSERVERS != no && kill -HUP $KILLPIDS 90 exit $RC 91 ;; 92 esac 93 94 echo "Using ldapsearch to retrieve all the entries..." 95 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \ 96 'objectClass=*' > $SEARCHOUT 2>&1 97 RC=$? 98 test $KILLSERVERS != no && kill -HUP $KILLPIDS 99 if test $RC != 0 ; then 100 echo "ldapsearch failed ($RC)!" 101 exit $RC 102 fi 103 104 LDIF=$MODIFYOUTPROVIDER 105 106 echo "Filtering ldapsearch results..." 107 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT 108 echo "Filtering original ldif used to create database..." 109 $LDIFFILTER < $LDIF > $LDIFFLT 110 echo "Comparing filter output..." 111 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT 112 113 if test $? != 0 ; then 114 echo "comparison failed - modify operations did not complete correctly" 115 exit 1 116 fi 117 118 echo ">>>>> Test succeeded" 119 120 test $KILLSERVERS != no && wait 121 122 exit 0 123