1#! /bin/sh 2## $OpenLDAP$ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 2016-2021 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 Ondřej Kuzník for Symas Corp. 18 19echo "running defines.sh" 20. $SRCDIR/scripts/defines.sh 21 22. ${SCRIPTDIR}/common.sh 23 24echo "Modifying entry..." 25$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 26 -f data/test005-changes.ldif >> $TESTOUT 2>&1 27RC=$? 28if test $RC != 0 ; then 29 echo "ldapmodify failed ($RC)!" 30 test $KILLSERVERS != no && kill -HUP $KILLPIDS 31 exit $RC 32fi 33 34# for now, overlay returns success just after the modifications to the main 35# entry succeed, ignoring the rest should they fail 36echo "Modifying a nonexistent variant of an existing entry..." 37$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 38 -f data/test005-variant-missing.ldif >> $TESTOUT 2>&1 39RC=$? 40if test $RC != 0 ; then 41 echo "ldapmodify failed ($RC)!" 42 test $KILLSERVERS != no && kill -HUP $KILLPIDS 43 exit $RC 44fi 45 46echo "Configuring nonexistent entry as variant..." 47. $CONFFILTER $BACKEND $MONITORDB < data/additional-config.ldif | \ 48$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 49 >> $TESTOUT 2>&1 50RC=$? 51if test $RC != 0 ; then 52 echo "ldapmodify failed ($RC)!" 53 test $KILLSERVERS != no && kill -HUP $KILLPIDS 54 exit $RC 55fi 56 57echo "Modifying an existing variant of above missing entry..." 58$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 59 -f data/test005-modify-missing.ldif >> $TESTOUT 2>&1 60RC=$? 61case $RC in 620) 63 echo "ldapmodify should have failed ($RC)!" 64 test $KILLSERVERS != no && kill -HUP $KILLPIDS 65 exit 1 66 ;; 6732) 68 echo "ldapmodify failed ($RC)" 69 ;; 70*) 71 echo "ldapmodify failed ($RC)!" 72 test $KILLSERVERS != no && kill -HUP $KILLPIDS 73 exit $RC 74 ;; 75esac 76 77echo "Reading affected entries back..." 78echo "# Reading affected entries back..." >> $SEARCHOUT 79$LDAPSEARCH -b "$BASEDN" -H $URI1 \ 80 '(|(description=*heard*)(st=*)(ou=alabama)(ou=*IT*))' \ 81 >> $SEARCHOUT 2>&1 82RC=$? 83if test $RC != 0 ; then 84 echo "ldapsearch failed ($RC)!" 85 test $KILLSERVERS != no && kill -HUP $KILLPIDS 86 exit $RC 87fi 88 89echo >>$SEARCHOUT 90$LDAPSEARCH -H $URI1 -s base \ 91 -b "cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN" \ 92 >> $SEARCHOUT 2>&1 93RC=$? 94if test $RC != 0 ; then 95 echo "ldapsearch failed ($RC)!" 96 test $KILLSERVERS != no && kill -HUP $KILLPIDS 97 exit $RC 98fi 99 100test $KILLSERVERS != no && kill -HUP $KILLPIDS 101 102LDIF=data/test005-out.ldif 103 104echo "Filtering ldapsearch results..." 105$LDIFFILTER -s e < $SEARCHOUT > $SEARCHFLT 106echo "Filtering expected entries..." 107$LDIFFILTER -s e < $LDIF > $LDIFFLT 108echo "Comparing filter output..." 109$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 110 111if test $? != 0 ; then 112 echo "Comparison failed" 113 exit 1 114fi 115 116echo ">>>>> Test succeeded" 117 118test $KILLSERVERS != no && wait 119 120exit 0 121