diff options
author | Andrew Bartlett <abartlet@samba.org> | 2012-06-26 20:59:25 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2012-06-27 11:29:17 +0200 |
commit | 471a6b39923f904f42794a81c5d09c581f072699 (patch) | |
tree | 5cb3ef8a24b21cde62e6144c81d7fecacd4892f4 | |
parent | 0b57d36ae32cfe3fb2d2517bdaeeb80816ba28ee (diff) | |
download | samba-471a6b39923f904f42794a81c5d09c581f072699.tar.gz samba-471a6b39923f904f42794a81c5d09c581f072699.tar.bz2 samba-471a6b39923f904f42794a81c5d09c581f072699.zip |
s4-selftest: expand passdb testing
This tests pdb_samba4 in the first instance
-rwxr-xr-x | source4/selftest/tests.py | 1 | ||||
-rwxr-xr-x | testprogs/blackbox/test_pdbtest.sh | 101 |
2 files changed, 102 insertions, 0 deletions
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index ece032568d..7c3409029b 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -310,6 +310,7 @@ plantestsuite("samba4.blackbox.kinit(fl2000dc:local)", "fl2000dc:local", [os.pat plantestsuite("samba4.blackbox.kinit(fl2008r2dc:local)", "fl2008r2dc:local", [os.path.join(bbdir, "test_kinit.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', '$PREFIX', "aes256-cts-hmac-sha1-96", smbclient, configuration]) plantestsuite("samba4.blackbox.ktpass(dc)", "dc", [os.path.join(bbdir, "test_ktpass.sh"), '$PREFIX']) plantestsuite("samba4.blackbox.passwords(dc:local)", "dc:local", [os.path.join(bbdir, "test_passwords.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', "$PREFIX", smbclient]) +plantestsuite("samba4.blackbox.pdbtest(dc:local)", "dc:local", [os.path.join(bbdir, "test_pdbtest.sh"), '$SERVER', "$PREFIX", smbclient, "dc", configuration]) plantestsuite("samba4.blackbox.export.keytab(dc:local)", "dc:local", [os.path.join(bbdir, "test_export_keytab.sh"), '$SERVER', '$USERNAME', '$REALM', '$DOMAIN', "$PREFIX", smbclient]) plantestsuite("samba4.blackbox.cifsdd(dc)", "dc", [os.path.join(samba4srcdir, "client/tests/test_cifsdd.sh"), '$SERVER', '$USERNAME', '$PASSWORD', "$DOMAIN"]) plantestsuite("samba4.blackbox.nmblookup(dc)", "dc", [os.path.join(samba4srcdir, "utils/tests/test_nmblookup.sh"), '$NETBIOSNAME', '$NETBIOSALIAS', '$SERVER', '$SERVER_IP', nmblookup]) diff --git a/testprogs/blackbox/test_pdbtest.sh b/testprogs/blackbox/test_pdbtest.sh new file mode 100755 index 0000000000..d5b5be3277 --- /dev/null +++ b/testprogs/blackbox/test_pdbtest.sh @@ -0,0 +1,101 @@ +#!/bin/sh +# Blackbox tests for pdbtest +# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org> +# Copyright (C) 2006-2012 Andrew Bartlett <abartlet@samba.org> + +if [ $# -lt 2 ]; then +cat <<EOF +Usage: test_pdbtest.sh SERVER PREFIX SMBCLIENT ENV +EOF +exit 1; +fi + +SERVER=$1 +PREFIX=$2 +smbclient=$3 +ENV=$4 +shift 4 +failed=0 + +samba4bindir="$BINDIR" +pdbtest="$samba4bindir/pdbtest" +pdbedit="$samba4bindir/pdbedit" +net="$samba4bindir/net" +smbpasswd="$samba4bindir/smbpasswd" +rkpty="$samba4bindir/rkpty" + +. `dirname $0`/subunit.sh + +test_smbclient() { + name="$1" + cmd="$2" + shift + shift + echo "test: $name" + $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" $@ + status=$? + if [ x$status = x0 ]; then + echo "success: $name" + else + echo "failure: $name" + fi + return $status +} + +testit "pdbtest" $BINDIR/pdbtest -u pdbtest || failed=`expr $failed + 1` + +NEWUSERPASS=testPaSS@01% + +echo "set password with pdbedit" +cat > ./tmpsmbpasswdscript <<EOF +expect new password: +send ${NEWUSERPASS}\n +expect retype new password: +send ${NEWUSERPASS}\n +EOF + +testit "create user with pdbedit" $rkpty ./tmpsmbpasswdscript $VALGRIND $pdbedit -a pdbtest --account-desc="pdbedit-test-user" $@ || failed=`expr $failed + 1` +USERPASS=$NEWUSERPASS + +test_smbclient "Test login with user (ntlm)" 'ls' -k no -Updbtest%$NEWUSERPASS $@ || failed=`expr $failed + 1` + +testit "modify user" $VALGRIND $pdbedit --modify pdbtest --drive="D:" $@ || failed=`expr $failed + 1` + +test_smbclient "Test login with user (ntlm)" 'ls' -k no -Updbtest%$NEWUSERPASS $@|| failed=`expr $failed + 1` + +NEWUSERPASS=testPaSS@02% + +echo "set password with smbpasswd" +cat > ./tmpsmbpasswdscript <<EOF +expect New SMB password: +send ${NEWUSERPASS}\n +expect Retype new SMB password: +send ${NEWUSERPASS}\n +EOF + +testit "set user password with smbpasswd" $rkpty ./tmpsmbpasswdscript $smbpasswd -L pdbtest -c $PREFIX/$ENV/etc/smb.conf || failed=`expr $failed + 1` +USERPASS=$NEWUSERPASS + +test_smbclient "Test login with user (ntlm)" 'ls' -k no -Updbtest%$NEWUSERPASS $@|| failed=`expr $failed + 1` + +testit "modify user - disabled" $VALGRIND $net sam set disabled pdbtest yes $@ || failed=`expr $failed + 1` + +testit_expect_failure "Test login with disabled suer" $VALGRIND $smbclient //$SERVER/tmp -c 'ls' -k no -Updbtest@%$USERPASS && failed=`expr $failed + 1` + +testit "modify user - enabled" $VALGRIND $net sam set disabled pdbtest no $@ || failed=`expr $failed + 1` + +test_smbclient "Test login with re-enabled user (ntlm)" 'ls' -k no -Updbtest%$NEWUSERPASS || failed=`expr $failed + 1` + +testit "modify user - must change password now" $VALGRIND $net sam set pwdmustchangenow pdbtest yes $@ || failed=`expr $failed + 1` + +testit_expect_failure "Test login with expired password" $VALGRIND $smbclient //$SERVER/tmp -c 'ls' -k no -Updbtest@%$USERPASS && failed=`expr $failed + 1` + +testit "modify user - disable password expiry" $VALGRIND $net sam set pwnoexp pdbtest yes $@ || failed=`expr $failed + 1` + +test_smbclient "Test login with no expiry (ntlm)" 'ls' -k no -Updbtest%$NEWUSERPASS || failed=`expr $failed + 1` + +testit "del user" $VALGRIND $pdbedit -x pdbtest $@ || failed=`expr $failed + 1` + +rm ./tmpsmbpasswdscript + +exit $failed |