mirror of
https://github.com/samba-team/samba.git
synced 2024-12-28 07:21:54 +03:00
samba-tool user edit test: use testit instead of subunit_start_test, pass/failed
Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
4c8660dc03
commit
7fd509a09b
@ -16,55 +16,40 @@ PASSWORD="$3"
|
|||||||
STpath=$(pwd)
|
STpath=$(pwd)
|
||||||
. $STpath/testprogs/blackbox/subunit.sh
|
. $STpath/testprogs/blackbox/subunit.sh
|
||||||
|
|
||||||
# create editor.sh
|
|
||||||
tmpeditor=$(mktemp --suffix .sh -p $STpath/bin samba-tool-editor-XXXXXXXX)
|
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
|
#!/usr/bin/env bash
|
||||||
user_ldif="$1"
|
user_ldif="$1"
|
||||||
SED=$(which sed)
|
SED=$(which sed)
|
||||||
$SED -i -e 's/userAccountControl: 512/userAccountControl: 514/' $user_ldif
|
$SED -i -e 's/userAccountControl: 512/userAccountControl: 514/' $user_ldif
|
||||||
EOF
|
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
|
failed=0
|
||||||
|
|
||||||
# Create a test user
|
testit "create_test_user" create_test_user || failed=`expr $failed + 1`
|
||||||
subunit_start_test "Create_User"
|
testit "edit_user" edit_user || failed=`expr $failed + 1`
|
||||||
output=$($PYTHON ${STpath}/source4/scripting/bin/samba-tool user create sambatool1 --random-password \
|
testit "delete_user" delete_user || failed=`expr $failed + 1`
|
||||||
-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
|
|
||||||
|
|
||||||
rm -f $tmpeditor
|
rm -f $tmpeditor
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user