test027-emptydn revision 1.1.1.5
1#! /bin/sh 2## This work is part of OpenLDAP Software <http://www.openldap.org/>. 3## 4## Copyright 2004-2016 The OpenLDAP Foundation. 5## All rights reserved. 6## 7## Redistribution and use in source and binary forms, with or without 8## modification, are permitted only as authorized by the OpenLDAP 9## Public License. 10## 11## A copy of this license is available in the file LICENSE in the 12## top-level directory of the distribution or, alternatively, at 13## <http://www.OpenLDAP.org/license.html>. 14 15echo "running defines.sh" 16. $SRCDIR/scripts/defines.sh 17 18mkdir -p $TESTDIR $DBDIR1 $DBDIR2 19 20. $CONFFILTER $BACKEND $MONITORDB < $EMPTYDNCONF > $CONF1 21 22echo "Running slapadd to build \"dc=example,dc=com\" slapd database..." 23$SLAPADD -f $CONF1 -n 1 -l $LDIFEMPTYDN1 24RC=$? 25if test $RC != 0 ; then 26 echo "slapadd failed ($RC)!" 27 exit $RC 28fi 29 30echo "Running slapadd to build empty DN slapd database..." 31$SLAPADD -f $CONF1 -b "" -l $LDIFEMPTYDN2 32RC=$? 33if test $RC != 0 ; then 34 echo "slapadd failed ($RC)!" 35 exit $RC 36fi 37 38echo "Starting slapd on TCP/IP port $PORT1..." 39$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & 40PID=$! 41if test $WAIT != 0 ; then 42 echo PID $PID 43 read foo 44fi 45KILLPIDS="$PID" 46 47sleep 1 48 49echo "Testing slapd empty DN handling..." 50for i in 0 1 2 3 4 5; do 51 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ 52 'objectclass=*' > /dev/null 2>&1 53 RC=$? 54 if test $RC = 0 ; then 55 break 56 fi 57 echo "Waiting 5 seconds for slapd to start..." 58 sleep 5 59done 60 61if test $RC != 0 ; then 62 echo "ldapsearch failed ($RC)!" 63 test $KILLSERVERS != no && kill -HUP $KILLPIDS 64 exit $RC 65fi 66 67echo "Searching database..." 68 69$LDAPSEARCH -S "" -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1 70 71RC=$? 72if test $RC != 0 ; then 73 echo "ldapsearch failed ($RC)!" 74 test $KILLSERVERS != no && kill -HUP $KILLPIDS 75 exit $RC 76fi 77 78kill -HUP $KILLPIDS 79wait 80 81echo "Filtering ldapsearch results..." 82$LDIFFILTER < $SEARCHOUT > $SEARCHFLT 83echo "Filtering expected results..." 84$LDIFFILTER < $EMPTYDNOUT1 > $LDIFFLT 85echo "Comparing ldapsearch results against original..." 86$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 87 88if test $? != 0 ; then 89 echo "comparison failed - empty DN write operations did not complete correctly" 90 exit 1 91fi 92 93echo "Comparison of database generated via slapadd succeeded" 94 95echo "Cleaning up database directories..." 96/bin/rm -rf $TESTDIR/db.* 97 98mkdir -p $TESTDIR $DBDIR1 $DBDIR2 99 100echo "Starting slapd on TCP/IP port $PORT1..." 101$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & 102PID=$! 103if test $WAIT != 0 ; then 104 echo PID $PID 105 read foo 106fi 107KILLPIDS="$PID" 108 109sleep 1 110 111echo "Testing slapd empty DN handling..." 112for i in 0 1 2 3 4 5; do 113 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ 114 'objectclass=*' > /dev/null 2>&1 115 RC=$? 116 if test $RC = 0 ; then 117 break 118 fi 119 echo "Waiting 5 seconds for slapd to start..." 120 sleep 5 121done 122 123if test $RC != 0 ; then 124 echo "ldapsearch failed ($RC)!" 125 test $KILLSERVERS != no && kill -HUP $KILLPIDS 126 exit $RC 127fi 128 129echo "Loading database..." 130$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \ 131 -f $LDIFEMPTYDN1 > /dev/null 2>&1 132$LDAPADD -D "$EMPTYDNDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \ 133 -f $LDIFEMPTYDN2 > /dev/null 2>&1 134 135$LDAPMODIFY -D "$EMPTYDNDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \ 136 > /dev/null 2>&1 << EOF 137dn: o=Beispiel,c=DE 138changetype: delete 139 140dn: c=DE 141changetype: delete 142EOF 143 144echo "Searching database..." 145 146$LDAPSEARCH -S "" -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1 147 148RC=$? 149if test $RC != 0 ; then 150 echo "ldapsearch failed ($RC)!" 151 test $KILLSERVERS != no && kill -HUP $KILLPIDS 152 exit $RC 153fi 154 155test $KILLSERVERS != no && kill -HUP $KILLPIDS 156 157echo "Filtering ldapsearch results..." 158$LDIFFILTER < $SEARCHOUT > $SEARCHFLT 159echo "Filtering expected results..." 160$LDIFFILTER < $EMPTYDNOUT2 > $LDIFFLT 161echo "Comparing ldapsearch results against original..." 162$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 163 164if test $? != 0 ; then 165 echo "comparison failed - empty DN write operations did not complete correctly" 166 exit 1 167fi 168 169##### 170 171echo ">>>>> Test succeeded" 172 173test $KILLSERVERS != no && wait 174 175exit 0 176