selftest: add regression test for setting invalid parameters in registry config via...
authorMichael Adam <obnox@samba.org>
Sat, 21 Sep 2013 20:34:31 +0000 (22:34 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 24 Sep 2013 05:44:29 +0000 (07:44 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/script/tests/test_net_conf.sh

index 1a773fa61fd13d12ec1e51a34a91683c350b05e2..c432c3e18305922e28cc724c183230ddc666eec7 100755 (executable)
@@ -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`