set -u
set -e
-usage() {
+usage()
+{
echo "usage: $0 PATH_TO_ASN1ATE_CHECKOUT PATH_TO_ASN1_INPUT_FILE > PATH_TO_PYASN1_OUTPUT_FILE"
}
# Test for 'samba-tool computer edit'
if [ $# -lt 3 ]; then
-cat <<EOF
+ cat <<EOF
Usage: computer_edit.sh SERVER USERNAME PASSWORD
EOF
-exit 1;
+ exit 1
fi
SERVER="$1"
tmpeditor=$(mktemp --suffix .sh -p $SELFTEST_TMPDIR samba-tool-editor-XXXXXXXX)
chmod +x $tmpeditor
-create_test_computer() {
+create_test_computer()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
computer create testmachine1 \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-edit_computer() {
+edit_computer()
+{
# create editor.sh
# enable computer account
cat >$tmpeditor <<-'EOF'
}
# Test edit computer - add base64 attributes
-add_attribute_base64() {
+add_attribute_base64()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_attribute_base64() {
+get_attribute_base64()
+{
${STpath}/bin/ldbsearch '(sAMAccountName=testmachine1$)' displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-delete_attribute() {
+delete_attribute()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
}
# Test edit computer - add base64 attribute value including control character
-add_attribute_base64_control() {
+add_attribute_base64_control()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_attribute_base64_control() {
+get_attribute_base64_control()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool computer show \
testmachine1 --attributes=displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_attribute_force_no_base64() {
+get_attribute_force_no_base64()
+{
# LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
$PYTHON ${STpath}/source4/scripting/bin/samba-tool computer show \
testmachine1 --attributes=displayName \
}
# Test edit computer - change base64 attribute value including control character
-change_attribute_base64_control() {
+change_attribute_base64_control()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
}
# Test edit computer - change attributes with LDB_FLAG_FORCE_NO_BASE64_LDIF
-change_attribute_force_no_base64() {
+change_attribute_force_no_base64()
+{
# create editor.sh
# Expects that the original attribute is available as clear text,
# because the LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_changed_attribute_force_no_base64() {
+get_changed_attribute_force_no_base64()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool computer show \
- testmachine1 --attributes=displayName \
- -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
+ testmachine1 --attributes=displayName \
+ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-delete_computer() {
+delete_computer()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
computer delete testmachine1 \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
failed=0
-testit "create_test_computer" create_test_computer || failed=`expr $failed + 1`
-testit "edit_computer" edit_computer || failed=`expr $failed + 1`
-testit "add_attribute_base64" add_attribute_base64 || failed=`expr $failed + 1`
-testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=`expr $failed + 1`
-testit "delete_attribute" delete_attribute || failed=`expr $failed + 1`
-testit "add_attribute_base64_control" add_attribute_base64_control || failed=`expr $failed + 1`
-testit_grep "get_attribute_base64_control" "^displayName:: $display_name_con_b64" get_attribute_base64_control || failed=`expr $failed + 1`
-testit "change_attribute_base64_control" change_attribute_base64_control || failed=`expr $failed + 1`
-testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=`expr $failed + 1`
-testit_grep "get_attribute_force_no_base64" "^displayName: $display_name" get_attribute_force_no_base64 || failed=`expr $failed + 1`
-testit "change_attribute_force_no_base64" change_attribute_force_no_base64 || failed=`expr $failed + 1`
-testit_grep "get_changed_attribute_force_no_base64" "^displayName: $display_name_new" get_changed_attribute_force_no_base64 || failed=`expr $failed + 1`
-testit "delete_computer" delete_computer || failed=`expr $failed + 1`
+testit "create_test_computer" create_test_computer || failed=$(expr $failed + 1)
+testit "edit_computer" edit_computer || failed=$(expr $failed + 1)
+testit "add_attribute_base64" add_attribute_base64 || failed=$(expr $failed + 1)
+testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=$(expr $failed + 1)
+testit "delete_attribute" delete_attribute || failed=$(expr $failed + 1)
+testit "add_attribute_base64_control" add_attribute_base64_control || failed=$(expr $failed + 1)
+testit_grep "get_attribute_base64_control" "^displayName:: $display_name_con_b64" get_attribute_base64_control || failed=$(expr $failed + 1)
+testit "change_attribute_base64_control" change_attribute_base64_control || failed=$(expr $failed + 1)
+testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=$(expr $failed + 1)
+testit_grep "get_attribute_force_no_base64" "^displayName: $display_name" get_attribute_force_no_base64 || failed=$(expr $failed + 1)
+testit "change_attribute_force_no_base64" change_attribute_force_no_base64 || failed=$(expr $failed + 1)
+testit_grep "get_changed_attribute_force_no_base64" "^displayName: $display_name_new" get_changed_attribute_force_no_base64 || failed=$(expr $failed + 1)
+testit "delete_computer" delete_computer || failed=$(expr $failed + 1)
rm -f $tmpeditor
# Test for 'samba-tool contact edit'
if [ $# -lt 3 ]; then
-cat <<EOF
+ cat <<EOF
Usage: contact_edit.sh SERVER USERNAME PASSWORD
EOF
-exit 1;
+ exit 1
fi
SERVER="$1"
samba_ldbsearch=ldbsearch
if test -x $BINDIR/ldbsearch; then
- samba_ldbsearch=$BINDIR/ldbsearch
+ samba_ldbsearch=$BINDIR/ldbsearch
fi
STpath=$(pwd)
tmpeditor=$(mktemp --suffix .sh -p $SELFTEST_TMPDIR samba-tool-editor-XXXXXXXX)
chmod +x $tmpeditor
-create_test_contact() {
+create_test_contact()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
contact create testcontact1 \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
# Test edit contact - add base64 attributes
-add_attribute_base64() {
+add_attribute_base64()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_attribute_base64() {
+get_attribute_base64()
+{
$samba_ldbsearch '(&(objectClass=contact)(name=testcontact1))' \
displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-delete_attribute() {
+delete_attribute()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
}
# Test edit contact - add base64 attribute value including control character
-add_attribute_base64_control() {
+add_attribute_base64_control()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_attribute_base64_control() {
+get_attribute_base64_control()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool contact show \
testcontact1 --attributes=displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_attribute_force_no_base64() {
- # LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
- $PYTHON ${STpath}/source4/scripting/bin/samba-tool contact show \
- testcontact1 --attributes=displayName \
- -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
+get_attribute_force_no_base64()
+{
+ # LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
+ $PYTHON ${STpath}/source4/scripting/bin/samba-tool contact show \
+ testcontact1 --attributes=displayName \
+ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
# Test edit contact - change base64 attribute value including control character
-change_attribute_base64_control() {
+change_attribute_base64_control()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
}
# Test edit contact - change attributes with LDB_FLAG_FORCE_NO_BASE64_LDIF
-change_attribute_force_no_base64() {
+change_attribute_force_no_base64()
+{
# create editor.sh
# Expects that the original attribute is available as clear text,
# because the LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_changed_attribute_force_no_base64() {
+get_changed_attribute_force_no_base64()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool contact show \
- testcontact1 --attributes=displayName \
- -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
+ testcontact1 --attributes=displayName \
+ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-delete_contact() {
+delete_contact()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
contact delete testcontact1 \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
failed=0
-testit "create_test_contact" create_test_contact || failed=`expr $failed + 1`
-testit "add_attribute_base64" add_attribute_base64 || failed=`expr $failed + 1`
-testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=`expr $failed + 1`
-testit "delete_attribute" delete_attribute || failed=`expr $failed + 1`
-testit "add_attribute_base64_control" add_attribute_base64_control || failed=`expr $failed + 1`
-testit_grep "get_attribute_base64_control" "^displayName:: $display_name_con_b64" get_attribute_base64_control || failed=`expr $failed + 1`
-testit "change_attribute_base64_control" change_attribute_base64_control || failed=`expr $failed + 1`
-testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=`expr $failed + 1`
-testit_grep "get_attribute_force_no_base64" "^displayName: $display_name" get_attribute_force_no_base64 || failed=`expr $failed + 1`
-testit "change_attribute_force_no_base64" change_attribute_force_no_base64 || failed=`expr $failed + 1`
-testit_grep "get_changed_attribute_force_no_base64" "^displayName: $display_name_new" get_changed_attribute_force_no_base64 || failed=`expr $failed + 1`
-testit "delete_contact" delete_contact || failed=`expr $failed + 1`
+testit "create_test_contact" create_test_contact || failed=$(expr $failed + 1)
+testit "add_attribute_base64" add_attribute_base64 || failed=$(expr $failed + 1)
+testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=$(expr $failed + 1)
+testit "delete_attribute" delete_attribute || failed=$(expr $failed + 1)
+testit "add_attribute_base64_control" add_attribute_base64_control || failed=$(expr $failed + 1)
+testit_grep "get_attribute_base64_control" "^displayName:: $display_name_con_b64" get_attribute_base64_control || failed=$(expr $failed + 1)
+testit "change_attribute_base64_control" change_attribute_base64_control || failed=$(expr $failed + 1)
+testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=$(expr $failed + 1)
+testit_grep "get_attribute_force_no_base64" "^displayName: $display_name" get_attribute_force_no_base64 || failed=$(expr $failed + 1)
+testit "change_attribute_force_no_base64" change_attribute_force_no_base64 || failed=$(expr $failed + 1)
+testit_grep "get_changed_attribute_force_no_base64" "^displayName: $display_name_new" get_changed_attribute_force_no_base64 || failed=$(expr $failed + 1)
+testit "delete_contact" delete_contact || failed=$(expr $failed + 1)
rm -f $tmpeditor
# Test for 'samba-tool group edit'
if [ $# -lt 3 ]; then
-cat <<EOF
+ cat <<EOF
Usage: group_edit.sh SERVER USERNAME PASSWORD
EOF
-exit 1;
+ exit 1
fi
SERVER="$1"
samba_ldbsearch=ldbsearch
if test -x $BINDIR/ldbsearch; then
- samba_ldbsearch=$BINDIR/ldbsearch
+ samba_ldbsearch=$BINDIR/ldbsearch
fi
STpath=$(pwd)
tmpeditor=$(mktemp --suffix .sh -p $SELFTEST_TMPDIR samba-tool-editor-XXXXXXXX)
chmod +x $tmpeditor
-create_test_group() {
+create_test_group()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
group add testgroup1 \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-delete_test_group() {
+delete_test_group()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
group delete testgroup1 \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-create_test_user() {
+create_test_user()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
user create testuser1 --random-password \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-delete_test_user() {
+delete_test_user()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
user delete testuser1 \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-add_member() {
+add_member()
+{
user_dn=$($PYTHON ${STpath}/source4/scripting/bin/samba-tool \
user show testuser1 --attributes=dn \
- -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" | \
+ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" |
grep ^dn: | cut -d' ' -f2)
# create editor.sh
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_member() {
+get_member()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
group listmembers testgroup1 \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
# Test edit group - add base64 attributes
-add_attribute_base64() {
+add_attribute_base64()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_attribute_base64() {
+get_attribute_base64()
+{
$samba_ldbsearch '(sAMAccountName=testgroup1)' displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-delete_attribute() {
+delete_attribute()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
}
# Test edit group - add base64 attribute value including control character
-add_attribute_base64_control() {
+add_attribute_base64_control()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_attribute_base64_control() {
+get_attribute_base64_control()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool group show \
testgroup1 --attributes=displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_attribute_force_no_base64() {
- # LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
- $PYTHON ${STpath}/source4/scripting/bin/samba-tool group show \
- testgroup1 --attributes=displayName \
- -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
+get_attribute_force_no_base64()
+{
+ # LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
+ $PYTHON ${STpath}/source4/scripting/bin/samba-tool group show \
+ testgroup1 --attributes=displayName \
+ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
# Test edit group - change base64 attribute value including control character
-change_attribute_base64_control() {
+change_attribute_base64_control()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
}
# Test edit group - change attributes with LDB_FLAG_FORCE_NO_BASE64_LDIF
-change_attribute_force_no_base64() {
+change_attribute_force_no_base64()
+{
# create editor.sh
# Expects that the original attribute is available as clear text,
# because the LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_changed_attribute_force_no_base64() {
+get_changed_attribute_force_no_base64()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool group show \
- testgroup1 --attributes=displayName \
- -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
+ testgroup1 --attributes=displayName \
+ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
failed=0
-testit "create_test_group" create_test_group || failed=`expr $failed + 1`
-testit "create_test_user" create_test_user || failed=`expr $failed + 1`
-testit "add_member" add_member || failed=`expr $failed + 1`
-testit_grep "get_member" "^testuser1" get_member || failed=`expr $failed + 1`
-testit "add_attribute_base64" add_attribute_base64 || failed=`expr $failed + 1`
-testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=`expr $failed + 1`
-testit "delete_attribute" delete_attribute || failed=`expr $failed + 1`
-testit "add_attribute_base64_control" add_attribute_base64_control || failed=`expr $failed + 1`
-testit_grep "get_attribute_base64_control" "^displayName:: $display_name_con_b64" get_attribute_base64_control || failed=`expr $failed + 1`
-testit "change_attribute_base64_control" change_attribute_base64_control || failed=`expr $failed + 1`
-testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=`expr $failed + 1`
-testit_grep "get_attribute_force_no_base64" "^displayName: $display_name" get_attribute_force_no_base64 || failed=`expr $failed + 1`
-testit "change_attribute_force_no_base64" change_attribute_force_no_base64 || failed=`expr $failed + 1`
-testit_grep "get_changed_attribute_force_no_base64" "^displayName: $display_name_new" get_changed_attribute_force_no_base64 || failed=`expr $failed + 1`
-testit "delete_test_group" delete_test_group || failed=`expr $failed + 1`
-testit "delete_test_user" delete_test_user || failed=`expr $failed + 1`
+testit "create_test_group" create_test_group || failed=$(expr $failed + 1)
+testit "create_test_user" create_test_user || failed=$(expr $failed + 1)
+testit "add_member" add_member || failed=$(expr $failed + 1)
+testit_grep "get_member" "^testuser1" get_member || failed=$(expr $failed + 1)
+testit "add_attribute_base64" add_attribute_base64 || failed=$(expr $failed + 1)
+testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=$(expr $failed + 1)
+testit "delete_attribute" delete_attribute || failed=$(expr $failed + 1)
+testit "add_attribute_base64_control" add_attribute_base64_control || failed=$(expr $failed + 1)
+testit_grep "get_attribute_base64_control" "^displayName:: $display_name_con_b64" get_attribute_base64_control || failed=$(expr $failed + 1)
+testit "change_attribute_base64_control" change_attribute_base64_control || failed=$(expr $failed + 1)
+testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=$(expr $failed + 1)
+testit_grep "get_attribute_force_no_base64" "^displayName: $display_name" get_attribute_force_no_base64 || failed=$(expr $failed + 1)
+testit "change_attribute_force_no_base64" change_attribute_force_no_base64 || failed=$(expr $failed + 1)
+testit_grep "get_changed_attribute_force_no_base64" "^displayName: $display_name_new" get_changed_attribute_force_no_base64 || failed=$(expr $failed + 1)
+testit "delete_test_group" delete_test_group || failed=$(expr $failed + 1)
+testit "delete_test_user" delete_test_user || failed=$(expr $failed + 1)
rm -f $tmpeditor
# Test for 'samba-tool user edit'
if [ $# -lt 3 ]; then
-cat <<EOF
+ cat <<EOF
Usage: user_edit.sh SERVER USERNAME PASSWORD
EOF
-exit 1;
+ exit 1
fi
SERVER="$1"
samba_ldbsearch=ldbsearch
if test -x $BINDIR/ldbsearch; then
- samba_ldbsearch=$BINDIR/ldbsearch
+ samba_ldbsearch=$BINDIR/ldbsearch
fi
STpath=$(pwd)
tmpeditor=$(mktemp --suffix .sh -p ${SELFTEST_TMPDIR} samba-tool-editor-XXXXXXXX)
chmod +x $tmpeditor
-create_test_user() {
+create_test_user()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
user create sambatool1 --random-password \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-edit_user() {
+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
+ EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
- user edit sambatool1 --editor=$tmpeditor \
- -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
+ user edit sambatool1 --editor=$tmpeditor \
+ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
# Test edit user - add base64 attributes
-add_attribute_base64() {
+add_attribute_base64()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_attribute_base64() {
+get_attribute_base64()
+{
$samba_ldbsearch '(sAMAccountName=sambatool1)' displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-delete_attribute() {
+delete_attribute()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
}
# Test edit user - add base64 attribute value including control character
-add_attribute_base64_control() {
+add_attribute_base64_control()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_attribute_base64_control() {
+get_attribute_base64_control()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool user show \
sambatool1 --attributes=displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_attribute_force_no_base64() {
+get_attribute_force_no_base64()
+{
# LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
$PYTHON ${STpath}/source4/scripting/bin/samba-tool user show \
sambatool1 --attributes=displayName \
}
# Test edit user - change base64 attribute value including control character
-change_attribute_base64_control() {
+change_attribute_base64_control()
+{
# create editor.sh
cat >$tmpeditor <<EOF
#!/usr/bin/env bash
}
# Test edit user - change attributes with LDB_FLAG_FORCE_NO_BASE64_LDIF
-change_attribute_force_no_base64() {
+change_attribute_force_no_base64()
+{
# create editor.sh
# Expects that the original attribute is available as clear text,
# because the LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-get_changed_attribute_force_no_base64() {
+get_changed_attribute_force_no_base64()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool user show \
- sambatool1 --attributes=displayName \
- -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
+ sambatool1 --attributes=displayName \
+ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
-delete_user() {
+delete_user()
+{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
user delete sambatool1 \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
failed=0
-testit "create_test_user" create_test_user || failed=`expr $failed + 1`
-testit "edit_user" edit_user || failed=`expr $failed + 1`
-testit "add_attribute_base64" add_attribute_base64 || failed=`expr $failed + 1`
-testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=`expr $failed + 1`
-testit "delete_attribute" delete_attribute || failed=`expr $failed + 1`
-testit "add_attribute_base64_control" add_attribute_base64_control || failed=`expr $failed + 1`
-testit_grep "get_attribute_base64_control" "^displayName:: $display_name_con_b64" get_attribute_base64_control || failed=`expr $failed + 1`
-testit "change_attribute_base64_control" change_attribute_base64_control || failed=`expr $failed + 1`
-testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=`expr $failed + 1`
-testit_grep "get_attribute_force_no_base64" "^displayName: $display_name" get_attribute_force_no_base64 || failed=`expr $failed + 1`
-testit "change_attribute_force_no_base64" change_attribute_force_no_base64 || failed=`expr $failed + 1`
-testit_grep "get_changed_attribute_force_no_base64" "^displayName: $display_name_new" get_changed_attribute_force_no_base64 || failed=`expr $failed + 1`
-testit "delete_user" delete_user || failed=`expr $failed + 1`
+testit "create_test_user" create_test_user || failed=$(expr $failed + 1)
+testit "edit_user" edit_user || failed=$(expr $failed + 1)
+testit "add_attribute_base64" add_attribute_base64 || failed=$(expr $failed + 1)
+testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=$(expr $failed + 1)
+testit "delete_attribute" delete_attribute || failed=$(expr $failed + 1)
+testit "add_attribute_base64_control" add_attribute_base64_control || failed=$(expr $failed + 1)
+testit_grep "get_attribute_base64_control" "^displayName:: $display_name_con_b64" get_attribute_base64_control || failed=$(expr $failed + 1)
+testit "change_attribute_base64_control" change_attribute_base64_control || failed=$(expr $failed + 1)
+testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=$(expr $failed + 1)
+testit_grep "get_attribute_force_no_base64" "^displayName: $display_name" get_attribute_force_no_base64 || failed=$(expr $failed + 1)
+testit "change_attribute_force_no_base64" change_attribute_force_no_base64 || failed=$(expr $failed + 1)
+testit_grep "get_changed_attribute_force_no_base64" "^displayName: $display_name_new" get_changed_attribute_force_no_base64 || failed=$(expr $failed + 1)
+testit "delete_user" delete_user || failed=$(expr $failed + 1)
rm -f $tmpeditor
service_file="$service_dir/samba"
mkdir $service_dir
-echo "auth required $pam_winbind debug debug_state $PAM_OPTIONS" > $service_file
-echo "account required $pam_winbind debug debug_state $PAM_OPTIONS" >> $service_file
-echo "password required $pam_winbind debug debug_state $PAM_OPTIONS" >> $service_file
-echo "session required $pam_winbind debug debug_state $PAM_OPTIONS" >> $service_file
+echo "auth required $pam_winbind debug debug_state $PAM_OPTIONS" >$service_file
+echo "account required $pam_winbind debug debug_state $PAM_OPTIONS" >>$service_file
+echo "password required $pam_winbind debug debug_state $PAM_OPTIONS" >>$service_file
+echo "session required $pam_winbind debug debug_state $PAM_OPTIONS" >>$service_file
PAM_WRAPPER="1"
export PAM_WRAPPER
samba_tool="$samba_bindir/samba-tool"
if [ "$CREATE_USER" = yes ]; then
- CREATE_SERVER="$1"
- CREATE_USERNAME="$2"
- CREATE_PASSWORD="$3"
- shift 3
- $PYTHON $samba_tool user create "$USERNAME" "$PASSWORD" -H "ldap://$CREATE_SERVER" -U "$CREATE_USERNAME%$CREATE_PASSWORD"
- # reset password policies beside of minimum password age of 0 days
- $PYTHON $samba_tool domain passwordsettings set --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=0 --max-pwd-age=default -H "ldap://$CREATE_SERVER" -U "$CREATE_USERNAME%$CREATE_PASSWORD"
+ CREATE_SERVER="$1"
+ CREATE_USERNAME="$2"
+ CREATE_PASSWORD="$3"
+ shift 3
+ $PYTHON $samba_tool user create "$USERNAME" "$PASSWORD" -H "ldap://$CREATE_SERVER" -U "$CREATE_USERNAME%$CREATE_PASSWORD"
+ # reset password policies beside of minimum password age of 0 days
+ $PYTHON $samba_tool domain passwordsettings set --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=0 --max-pwd-age=default -H "ldap://$CREATE_SERVER" -U "$CREATE_USERNAME%$CREATE_PASSWORD"
fi
PAM_WRAPPER_PATH="$BINDIR/default/third_party/pam_wrapper"
service_file="$service_dir/samba"
mkdir $service_dir
-echo "auth required $pam_winbind debug debug_state $PAM_OPTIONS" > $service_file
-echo "account required $pam_winbind debug debug_state $PAM_OPTIONS" >> $service_file
-echo "password required $PAM_SET_ITEMS_SO_PATH" >> $service_file
-echo "password required $pam_winbind debug debug_state $PAM_OPTIONS" >> $service_file
-echo "session required $pam_winbind debug debug_state $PAM_OPTIONS" >> $service_file
+echo "auth required $pam_winbind debug debug_state $PAM_OPTIONS" >$service_file
+echo "account required $pam_winbind debug debug_state $PAM_OPTIONS" >>$service_file
+echo "password required $PAM_SET_ITEMS_SO_PATH" >>$service_file
+echo "password required $pam_winbind debug debug_state $PAM_OPTIONS" >>$service_file
+echo "session required $pam_winbind debug debug_state $PAM_OPTIONS" >>$service_file
PAM_WRAPPER_SERVICE_DIR="$service_dir"
export PAM_WRAPPER_SERVICE_DIR
export PAM_WRAPPER_DEBUGLEVEL
case $PAM_OPTIONS in
- *use_authtok*)
- PAM_AUTHTOK="$NEWPASSWORD"
- export PAM_AUTHTOK
- ;;
- *try_authtok*)
- PAM_AUTHTOK="$NEWPASSWORD"
- export PAM_AUTHTOK
- ;;
+*use_authtok*)
+ PAM_AUTHTOK="$NEWPASSWORD"
+ export PAM_AUTHTOK
+ ;;
+*try_authtok*)
+ PAM_AUTHTOK="$NEWPASSWORD"
+ export PAM_AUTHTOK
+ ;;
esac
PAM_WRAPPER="1" PYTHONPATH="$PYTHONPATH:$PAM_WRAPPER_PATH:$(dirname $0)" $PYTHON -m samba.subunit.run samba.tests.pam_winbind_chauthtok
rm -rf $service_dir
if [ "$CREATE_USER" = yes ]; then
- $PYTHON $samba_tool user delete "$USERNAME" -H "ldap://$CREATE_SERVER" -U "$CREATE_USERNAME%$CREATE_PASSWORD"
- # reset password policies
- $PYTHON $samba_tool domain passwordsettings set --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=default --max-pwd-age=default -H "ldap://$CREATE_SERVER" -U "$CREATE_USERNAME%$CREATE_PASSWORD"
+ $PYTHON $samba_tool user delete "$USERNAME" -H "ldap://$CREATE_SERVER" -U "$CREATE_USERNAME%$CREATE_PASSWORD"
+ # reset password policies
+ $PYTHON $samba_tool domain passwordsettings set --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=default --max-pwd-age=default -H "ldap://$CREATE_SERVER" -U "$CREATE_USERNAME%$CREATE_PASSWORD"
fi
exit $exit_code
WARN_PWD_EXPIRE="50"
export WARN_PWD_EXPIRE
-echo "auth required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" > $service_file
-echo "account required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >> $service_file
-echo "password required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >> $service_file
-echo "session required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >> $service_file
+echo "auth required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >$service_file
+echo "account required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >>$service_file
+echo "password required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >>$service_file
+echo "session required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >>$service_file
PYTHONPATH="$PYTHONPATH:$PAM_WRAPPER_PATH:$(dirname $0)" $PYTHON -m samba.subunit.run samba.tests.pam_winbind_warn_pwd_expire
exit_code=$?
WARN_PWD_EXPIRE="0"
export WARN_PWD_EXPIRE
-echo "auth required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" > $service_file
-echo "account required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >> $service_file
-echo "password required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >> $service_file
-echo "session required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >> $service_file
+echo "auth required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >$service_file
+echo "account required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >>$service_file
+echo "password required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >>$service_file
+echo "session required $pam_winbind debug debug_state warn_pwd_expire=$WARN_PWD_EXPIRE $PAM_OPTIONS" >>$service_file
PYTHONPATH="$PYTHONPATH:$PAM_WRAPPER_PATH:$(dirname $0)" $PYTHON -m samba.subunit.run samba.tests.pam_winbind_warn_pwd_expire
exit_code=$?