2012-06-26 20:59:25 +10:00
#!/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
2014-05-16 14:30:43 +12:00
Usage: test_pdbtest.sh SERVER PREFIX USER SMBCLIENT SMB_CONF
2012-06-26 20:59:25 +10:00
EOF
exit 1;
fi
SERVER = $1
PREFIX = $2
2014-05-16 14:30:43 +12:00
USER = $3
smbclient = $4
SMB_CONF = $5
shift 5
2012-06-26 20:59:25 +10:00
failed = 0
samba4bindir = " $BINDIR "
pdbtest = " $samba4bindir /pdbtest "
pdbedit = " $samba4bindir /pdbedit "
net = " $samba4bindir /net "
smbpasswd = " $samba4bindir /smbpasswd "
2014-08-26 18:01:10 +02:00
texpect = " $samba4bindir /texpect "
2016-04-24 11:09:05 -07:00
unc = " // $SERVER /tmp "
2012-06-26 20:59:25 +10:00
. ` dirname $0 ` /subunit.sh
2016-04-24 11:09:05 -07:00
. ` dirname $0 ` /common_test_fns.inc
2012-06-26 20:59:25 +10:00
2013-07-29 13:50:06 +02:00
UID_WRAPPER_ROOT = 1
export UID_WRAPPER_ROOT
2014-05-16 14:30:43 +12:00
testit "pdbtest" $VALGRIND $BINDIR /pdbtest -u $USER $@ || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
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
2014-08-26 18:01:10 +02:00
testit "create user with pdbedit" $texpect ./tmpsmbpasswdscript $VALGRIND $pdbedit -a $USER --account-desc= "pdbedit-test-user" $@ || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
USERPASS = $NEWUSERPASS
2016-04-24 11:09:05 -07:00
test_smbclient "Test login with user (ntlm)" 'ls' " $unc " -k no -U$USER %$NEWUSERPASS $@ || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
2014-05-16 14:30:43 +12:00
testit "modify user" $VALGRIND $pdbedit --modify $USER --drive= "D:" $@ || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
2016-04-24 11:09:05 -07:00
test_smbclient "Test login with user (ntlm)" 'ls' " $unc " -k no -U$USER %$NEWUSERPASS $@ || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
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
2014-08-26 18:01:10 +02:00
testit "set user password with smbpasswd" $texpect ./tmpsmbpasswdscript $smbpasswd -L $USER -c $SMB_CONF || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
USERPASS = $NEWUSERPASS
2016-04-24 11:09:05 -07:00
test_smbclient "Test login with user (ntlm)" 'ls' " $unc " -k no -U$USER %$NEWUSERPASS $@ || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
2014-05-16 14:30:43 +12:00
testit "modify user - disabled" $VALGRIND $net sam set disabled $USER yes $@ || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
2014-05-16 14:30:43 +12:00
testit_expect_failure "Test login with disabled suer" $VALGRIND $smbclient //$SERVER /tmp -c 'ls' -k no -U$USER @%$USERPASS && failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
2014-05-16 14:30:43 +12:00
testit "modify user - enabled" $VALGRIND $net sam set disabled $USER no $@ || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
2016-04-24 11:09:05 -07:00
test_smbclient "Test login with re-enabled user (ntlm)" 'ls' " $unc " -k no -U$USER %$NEWUSERPASS || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
2014-05-16 14:30:43 +12:00
testit "modify user - must change password now" $VALGRIND $net sam set pwdmustchangenow $USER yes $@ || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
2014-05-16 14:30:43 +12:00
testit_expect_failure "Test login with expired password" $VALGRIND $smbclient //$SERVER /tmp -c 'ls' -k no -U$USER @%$USERPASS && failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
2014-05-16 14:30:43 +12:00
testit "modify user - disable password expiry" $VALGRIND $net sam set pwnoexp $USER yes $@ || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
2016-04-24 11:09:05 -07:00
test_smbclient "Test login with no expiry (ntlm)" 'ls' " $unc " -k no -U$USER %$NEWUSERPASS || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
2015-11-30 14:24:06 +13:00
NEWUSERPASS = testPaSS@03%
NEWUSERHASH = 062519096c45739c1938800f80906731
testit "Set user password with password hash" $VALGRIND $pdbedit -u $USER --set-nt-hash $NEWUSERHASH $@ || failed = ` expr $failed + 1`
2016-04-24 11:09:05 -07:00
test_smbclient "Test login with new password (from hash)" 'ls' " $unc " -k no -U$USER %$NEWUSERPASS || failed = ` expr $failed + 1`
2015-11-30 14:24:06 +13:00
2014-05-16 14:30:43 +12:00
testit "del user" $VALGRIND $pdbedit -x $USER $@ || failed = ` expr $failed + 1`
2012-06-26 20:59:25 +10:00
rm ./tmpsmbpasswdscript
exit $failed