From 7fd509a09b929933b8363d33aebb2e976abd2c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Baumbach?= Date: Thu, 14 Mar 2019 16:55:42 +0100 Subject: [PATCH] samba-tool user edit test: use testit instead of subunit_start_test, pass/failed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Björn Baumbach Reviewed-by: Andrew Bartlett --- python/samba/tests/samba_tool/user_edit.sh | 61 ++++++++-------------- 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/python/samba/tests/samba_tool/user_edit.sh b/python/samba/tests/samba_tool/user_edit.sh index 66ae1d00721..166d45ae4d6 100755 --- a/python/samba/tests/samba_tool/user_edit.sh +++ b/python/samba/tests/samba_tool/user_edit.sh @@ -16,55 +16,40 @@ PASSWORD="$3" STpath=$(pwd) . $STpath/testprogs/blackbox/subunit.sh -# create editor.sh tmpeditor=$(mktemp --suffix .sh -p $STpath/bin samba-tool-editor-XXXXXXXX) +chmod +x $tmpeditor -cat >$tmpeditor <<-'EOF' +create_test_user() { + $PYTHON ${STpath}/source4/scripting/bin/samba-tool \ + user create sambatool1 --random-password \ + -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" +} + +edit_user() { + # create editor.sh + cat >$tmpeditor <<-'EOF' #!/usr/bin/env bash user_ldif="$1" SED=$(which sed) $SED -i -e 's/userAccountControl: 512/userAccountControl: 514/' $user_ldif EOF -chmod +x $tmpeditor + $PYTHON ${STpath}/source4/scripting/bin/samba-tool \ + user edit sambatool1 --editor=$tmpeditor \ + -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" +} + +delete_user() { + $PYTHON ${STpath}/source4/scripting/bin/samba-tool \ + user delete sambatool1 \ + -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" +} failed=0 -# Create a test user -subunit_start_test "Create_User" -output=$($PYTHON ${STpath}/source4/scripting/bin/samba-tool user create sambatool1 --random-password \ --H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD") -status=$? -if [ "x$status" = "x0" ]; then - subunit_pass_test "Create_User" -else - echo "$output" | subunit_fail_test "Create_User" - failed=$((failed + 1)) -fi - -# Edit test user -subunit_start_test "Edit_User" -output=$($PYTHON ${STpath}/source4/scripting/bin/samba-tool user edit sambatool1 --editor=$tmpeditor \ --H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD") -status=$? -if [ "x$status" = "x0" ]; then - subunit_pass_test "Edit_User" -else - echo "$output" | subunit_fail_test "Edit_User" - failed=$((failed + 1)) -fi - -# Delete test user -subunit_start_test "Delete_User" -output=$($PYTHON ${STpath}/source4/scripting/bin/samba-tool user delete sambatool1 \ --H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD") -status=$? -if [ "x$status" = "x0" ]; then - subunit_pass_test "Delete_User" -else - echo "$output" | subunit_fail_test "Delete_User" - failed=$((failed + 1)) -fi +testit "create_test_user" create_test_user || failed=`expr $failed + 1` +testit "edit_user" edit_user || failed=`expr $failed + 1` +testit "delete_user" delete_user || failed=`expr $failed + 1` rm -f $tmpeditor