From 21be539590b7af40ea8af7301cd539f6433a8928 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 21 Sep 2013 22:34:31 +0200 Subject: selftest: add regression test for setting invalid parameters in registry config via "net [rpc] conf" Signed-off-by: Michael Adam Reviewed-by: Andrew Bartlett --- source3/script/tests/test_net_conf.sh | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'source3/script') diff --git a/source3/script/tests/test_net_conf.sh b/source3/script/tests/test_net_conf.sh index 1a773fa61f..c432c3e183 100755 --- a/source3/script/tests/test_net_conf.sh +++ b/source3/script/tests/test_net_conf.sh @@ -422,6 +422,51 @@ test_conf_setparm_existing() fi } +test_conf_setparm_forbidden() +{ + FORBIDDEN_PARAMS="lock directory +lock dir +config backend +include" + + echo '\nTrying to set forbidden parameters' >> $LOG + + echo '\nDropping existing configuration' >> $LOG + $NETCMD conf drop + log_print $NETCMD conf drop + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + OLD_IFS="$IFS" + IFS=' +' + for PARAM in $FORBIDDEN_PARAMS ; do + IFS="$OLD_IFS" + echo "Trying to set parameter '$PARAM'" | tee -a $LOG + $NETCMD conf setparm global "$PARAM" "value" > $DIR/setparm_forbidden_out 2>&1 + log_print $NETCMD conf setparm global \""$PARAM"\" "value" + test "x$?" = "x0" && { + echo "ERROR: setting forbidden parameter '$PARAM' succeeded" | tee -a $LOG + return 1 + } + + echo "output of net command: " | tee -a $LOG + cat $DIR/setparm_forbidden_out | tee -a $LOG + + SEARCH="Parameter '$PARAM' not allowed in registry." + grep "$SEARCH" $DIR/setparm_forbidden_out >/dev/null 2>>$LOG + test "x$?" = "x0" || { + echo "ERROR: expected '$SEARCH'" | tee -a $LOG + return 1 + } + done + + IFS="$OLD_IFS" + return 0 +} + test_conf_setparm_usage() { echo '\nChecking usage' >>$LOG @@ -884,6 +929,10 @@ CONF_FILES=$SERVERCONFFILE test_conf_setparm_existing \ || failed=`expr $failed + 1` + testit "conf_setparm_forbidden" \ + test_conf_setparm_forbidden \ + || failed=`expr $failed + 1` + testit "conf_setparm_usage" \ test_conf_setparm_usage \ || failed=`expr $failed + 1` -- cgit