14e6df137Slukem#! /bin/sh 2d11b170bStron# $OpenLDAP$ 34e6df137Slukem## This work is part of OpenLDAP Software <http://www.openldap.org/>. 44e6df137Slukem## 5*e670fd5cSchristos## Copyright 1998-2021 The OpenLDAP Foundation. 64e6df137Slukem## All rights reserved. 74e6df137Slukem## 84e6df137Slukem## Redistribution and use in source and binary forms, with or without 94e6df137Slukem## modification, are permitted only as authorized by the OpenLDAP 104e6df137Slukem## Public License. 114e6df137Slukem## 124e6df137Slukem## A copy of this license is available in the file LICENSE in the 134e6df137Slukem## top-level directory of the distribution or, alternatively, at 144e6df137Slukem## <http://www.OpenLDAP.org/license.html>. 154e6df137Slukem 164e6df137Slukemecho "running defines.sh" 174e6df137Slukem. $SRCDIR/scripts/defines.sh 184e6df137SlukemLVL=acl 194e6df137Slukem 204e6df137Slukemmkdir -p $TESTDIR $DBDIR1 214e6df137Slukem 224e6df137Slukemecho "Running slapadd to build slapd database..." 23*e670fd5cSchristos. $CONFFILTER $BACKEND < $VALREGEXCONF > $CONF1 244e6df137Slukem$SLAPADD -f $CONF1 -l $LDIFORDERED 254e6df137SlukemRC=$? 264e6df137Slukemif test $RC != 0 ; then 274e6df137Slukem echo "slapadd failed ($RC)!" 284e6df137Slukem exit $RC 294e6df137Slukemfi 304e6df137Slukem 314e6df137Slukemecho "Starting slapd on TCP/IP port $PORT1..." 32*e670fd5cSchristos$SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 & 334e6df137SlukemPID=$! 344e6df137Slukemif test $WAIT != 0 ; then 354e6df137Slukem echo PID $PID 364e6df137Slukem read foo 374e6df137Slukemfi 384e6df137SlukemKILLPIDS="$PID" 394e6df137Slukem 404e6df137Slukemsleep 1 414e6df137Slukem 42*e670fd5cSchristosecho "Testing attribute value regex substitution..." 434e6df137Slukemfor i in 0 1 2 3 4 5; do 44*e670fd5cSchristos $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ 454e6df137Slukem 'objectclass=*' > /dev/null 2>&1 464e6df137Slukem RC=$? 474e6df137Slukem if test $RC = 0 ; then 484e6df137Slukem break 494e6df137Slukem fi 504e6df137Slukem echo "Waiting 5 seconds for slapd to start..." 514e6df137Slukem sleep 5 524e6df137Slukemdone 534e6df137Slukem 544e6df137Slukemif test $RC != 0 ; then 554e6df137Slukem echo "ldapsearch failed ($RC)!" 564e6df137Slukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 574e6df137Slukem exit $RC 584e6df137Slukemfi 594e6df137Slukem 604e6df137Slukemcat /dev/null > $SEARCHOUT 614e6df137Slukem 624e6df137Slukemecho "# Try an attribute vale regex that match, but substitute does not" 634e6df137Slukemecho "# this should fail" 64*e670fd5cSchristos$LDAPMODIFY -D "$JAJDN" -H $URI1 -w jaj >> \ 654e6df137Slukem $TESTOUT 2>&1 << EOMODS 664e6df137Slukemdn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com 674e6df137Slukemchangetype: modify 684e6df137Slukemreplace: sn 694e6df137Slukemsn: foobarbuz 704e6df137SlukemEOMODS 714e6df137SlukemRC=$? 724e6df137Slukemcase $RC in 734e6df137Slukem50) 744e6df137Slukem echo "ldapmodify failed as expected" 754e6df137Slukem ;; 764e6df137Slukem0) 77ef2f90d3Sadam if test $BACKEND != null ; then 784e6df137Slukem echo "ldapmodify should have failed ($RC)!" 794e6df137Slukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 804e6df137Slukem exit -1 81ef2f90d3Sadam fi 824e6df137Slukem ;; 834e6df137Slukem*) 844e6df137Slukem echo "ldapmodify failed ($RC)!" 854e6df137Slukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 864e6df137Slukem exit $RC 874e6df137Slukem ;; 884e6df137Slukemesac 894e6df137Slukem 904e6df137Slukemecho "# Try an attribute vale regex that match and substitute does" 914e6df137Slukemecho "# this should succeed" 92*e670fd5cSchristos$LDAPMODIFY -D "$JAJDN" -H $URI1 -w jaj >> \ 934e6df137Slukem $TESTOUT 2>&1 << EOMODS 944e6df137Slukemdn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com 954e6df137Slukemchangetype: modify 964e6df137Slukemreplace: sn 974e6df137Slukemsn: James A Jones 1 984e6df137SlukemEOMODS 994e6df137SlukemRC=$? 1004e6df137Slukem 1014e6df137Slukemtest $KILLSERVERS != no && kill -HUP $KILLPIDS 1024e6df137Slukem 1034e6df137Slukemcase $RC in 1044e6df137Slukem0) 1054e6df137Slukem echo "ldapmodify succeed as expected" 1064e6df137Slukem ;; 1074e6df137Slukem*) 1084e6df137Slukem echo "ldapmodify failed ($RC)!" 1094e6df137Slukem exit $RC 1104e6df137Slukem ;; 1114e6df137Slukemesac 1124e6df137Slukem 1134e6df137Slukemecho ">>>>> Test succeeded" 1144e6df137Slukem 1154e6df137Slukemtest $KILLSERVERS != no && wait 1164e6df137Slukem 1174e6df137Slukemexit 0 118