1#! /bin/sh 2# $OpenLDAP$ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 1998-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 16echo "running defines.sh" 17. $SRCDIR/scripts/defines.sh 18LVL=acl 19 20mkdir -p $TESTDIR $DBDIR1 21 22echo "Running slapadd to build slapd database..." 23. $CONFFILTER $BACKEND < $VALREGEXCONF > $CONF1 24$SLAPADD -f $CONF1 -l $LDIFORDERED 25RC=$? 26if test $RC != 0 ; then 27 echo "slapadd failed ($RC)!" 28 exit $RC 29fi 30 31echo "Starting slapd on TCP/IP port $PORT1..." 32$SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 & 33PID=$! 34if test $WAIT != 0 ; then 35 echo PID $PID 36 read foo 37fi 38KILLPIDS="$PID" 39 40sleep 1 41 42echo "Testing attribute value regex substitution..." 43for i in 0 1 2 3 4 5; do 44 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ 45 'objectclass=*' > /dev/null 2>&1 46 RC=$? 47 if test $RC = 0 ; then 48 break 49 fi 50 echo "Waiting 5 seconds for slapd to start..." 51 sleep 5 52done 53 54if test $RC != 0 ; then 55 echo "ldapsearch failed ($RC)!" 56 test $KILLSERVERS != no && kill -HUP $KILLPIDS 57 exit $RC 58fi 59 60cat /dev/null > $SEARCHOUT 61 62echo "# Try an attribute vale regex that match, but substitute does not" 63echo "# this should fail" 64$LDAPMODIFY -D "$JAJDN" -H $URI1 -w jaj >> \ 65 $TESTOUT 2>&1 << EOMODS 66dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com 67changetype: modify 68replace: sn 69sn: foobarbuz 70EOMODS 71RC=$? 72case $RC in 7350) 74 echo "ldapmodify failed as expected" 75 ;; 760) 77 if test $BACKEND != null ; then 78 echo "ldapmodify should have failed ($RC)!" 79 test $KILLSERVERS != no && kill -HUP $KILLPIDS 80 exit -1 81 fi 82 ;; 83*) 84 echo "ldapmodify failed ($RC)!" 85 test $KILLSERVERS != no && kill -HUP $KILLPIDS 86 exit $RC 87 ;; 88esac 89 90echo "# Try an attribute vale regex that match and substitute does" 91echo "# this should succeed" 92$LDAPMODIFY -D "$JAJDN" -H $URI1 -w jaj >> \ 93 $TESTOUT 2>&1 << EOMODS 94dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com 95changetype: modify 96replace: sn 97sn: James A Jones 1 98EOMODS 99RC=$? 100 101test $KILLSERVERS != no && kill -HUP $KILLPIDS 102 103case $RC in 1040) 105 echo "ldapmodify succeed as expected" 106 ;; 107*) 108 echo "ldapmodify failed ($RC)!" 109 exit $RC 110 ;; 111esac 112 113echo ">>>>> Test succeeded" 114 115test $KILLSERVERS != no && wait 116 117exit 0 118