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 "Adding entry..." 25 $LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 26 -f data/test002-01-entry.ldif >> $TESTOUT 2>&1 27 RC=$? 28 if test $RC != 0 ; then 29 echo "ldapmodify failed ($RC)!" 30 test $KILLSERVERS != no && kill -HUP $KILLPIDS 31 exit $RC 32 fi 33 34 echo "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 38 RC=$? 39 if test $RC != 0 ; then 40 echo "ldapmodify failed ($RC)!" 41 test $KILLSERVERS != no && kill -HUP $KILLPIDS 42 exit $RC 43 fi 44 45 echo "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 49 RC=$? 50 if test $RC != 0 ; then 51 echo "ldapdelete failed ($RC)!" 52 test $KILLSERVERS != no && kill -HUP $KILLPIDS 53 exit $RC 54 fi 55 56 echo "Adding entry again (should fail)..." 57 $LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 58 -f data/test002-01-entry.ldif >> $TESTOUT 2>&1 59 RC=$? 60 case $RC in 61 0) 62 echo "ldapmodify should have failed ($RC)!" 63 test $KILLSERVERS != no && kill -HUP $KILLPIDS 64 exit 1 65 ;; 66 19) 67 echo "ldapmodify failed ($RC)" 68 ;; 69 *) 70 echo "ldapmodify failed ($RC)!" 71 test $KILLSERVERS != no && kill -HUP $KILLPIDS 72 exit $RC 73 ;; 74 esac 75 76 echo "Adding a regex entry (should fail)..." 77 $LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 78 -f data/test002-02-regex.ldif >> $TESTOUT 2>&1 79 RC=$? 80 case $RC in 81 0) 82 echo "ldapmodify should have failed ($RC)!" 83 test $KILLSERVERS != no && kill -HUP $KILLPIDS 84 exit 1 85 ;; 86 19) 87 echo "ldapmodify failed ($RC)" 88 ;; 89 *) 90 echo "ldapmodify failed ($RC)!" 91 test $KILLSERVERS != no && kill -HUP $KILLPIDS 92 exit $RC 93 ;; 94 esac 95 96 echo "Adding entry with offending attributes removed..." 97 grep -v '^description:' data/test002-01-entry.ldif | \ 98 $LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 99 >> $TESTOUT 2>&1 100 RC=$? 101 if test $RC != 0 ; then 102 echo "ldapmodify failed ($RC)!" 103 test $KILLSERVERS != no && kill -HUP $KILLPIDS 104 exit $RC 105 fi 106 107 test $KILLSERVERS != no && kill -HUP $KILLPIDS 108 109 echo ">>>>> Test succeeded" 110 111 test $KILLSERVERS != no && wait 112 113 exit 0 114