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 "Adding entry..." 25$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 26 -f data/test002-01-entry.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 34echo "Configuring entry as variant..." 35. $CONFFILTER $BACKEND $MONITORDB < data/additional-config.ldif | \ 36$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 37 >> $TESTOUT 2>&1 38RC=$? 39if test $RC != 0 ; then 40 echo "ldapmodify failed ($RC)!" 41 test $KILLSERVERS != no && kill -HUP $KILLPIDS 42 exit $RC 43fi 44 45echo "Removing entry..." 46$LDAPDELETE -D $MANAGERDN -H $URI1 -w $PASSWD \ 47 "cn=Gern Jensen,ou=Information Technology Division,ou=People,$BASEDN" \ 48 >> $TESTOUT 2>&1 49RC=$? 50if test $RC != 0 ; then 51 echo "ldapdelete failed ($RC)!" 52 test $KILLSERVERS != no && kill -HUP $KILLPIDS 53 exit $RC 54fi 55 56echo "Adding entry again (should fail)..." 57$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 58 -f data/test002-01-entry.ldif >> $TESTOUT 2>&1 59RC=$? 60case $RC in 610) 62 echo "ldapmodify should have failed ($RC)!" 63 test $KILLSERVERS != no && kill -HUP $KILLPIDS 64 exit 1 65 ;; 6619) 67 echo "ldapmodify failed ($RC)" 68 ;; 69*) 70 echo "ldapmodify failed ($RC)!" 71 test $KILLSERVERS != no && kill -HUP $KILLPIDS 72 exit $RC 73 ;; 74esac 75 76echo "Adding a regex entry (should fail)..." 77$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 78 -f data/test002-02-regex.ldif >> $TESTOUT 2>&1 79RC=$? 80case $RC in 810) 82 echo "ldapmodify should have failed ($RC)!" 83 test $KILLSERVERS != no && kill -HUP $KILLPIDS 84 exit 1 85 ;; 8619) 87 echo "ldapmodify failed ($RC)" 88 ;; 89*) 90 echo "ldapmodify failed ($RC)!" 91 test $KILLSERVERS != no && kill -HUP $KILLPIDS 92 exit $RC 93 ;; 94esac 95 96echo "Adding entry with offending attributes removed..." 97grep -v '^description:' data/test002-01-entry.ldif | \ 98$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 99 >> $TESTOUT 2>&1 100RC=$? 101if test $RC != 0 ; then 102 echo "ldapmodify failed ($RC)!" 103 test $KILLSERVERS != no && kill -HUP $KILLPIDS 104 exit $RC 105fi 106 107test $KILLSERVERS != no && kill -HUP $KILLPIDS 108 109echo ">>>>> Test succeeded" 110 111test $KILLSERVERS != no && wait 112 113exit 0 114