2 # Blackbox tests for pdbtest
3 # Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
4 # Copyright (C) 2006-2012 Andrew Bartlett <abartlet@samba.org>
8 Usage: test_pdbtest.sh SERVER PREFIX USER SMBCLIENT SMB_CONF
21 samba4bindir
="$BINDIR"
22 pdbtest
="$samba4bindir/pdbtest"
23 pdbedit
="$samba4bindir/pdbedit"
24 net
="$samba4bindir/net"
25 smbpasswd
="$samba4bindir/smbpasswd"
26 texpect
="$samba4bindir/texpect"
29 . $
(dirname $0)/subunit.sh
30 . $
(dirname $0)/common_test_fns.inc
37 echo "set password with smbpasswd"
38 tmpfile
=$PREFIX/smbpasswd_change_password_script
40 expect New SMB password:
42 expect Retype new SMB password:
46 cmd
='UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $texpect $tmpfile $smbpasswd -L $user -c $SMB_CONF'
52 if [ $ret -ne 0 ]; then
53 echo "Failed to change user password $user"
58 testit
"pdbtest" $VALGRIND $BINDIR/pdbtest
-u $USER "$@" || failed
=$
(expr $failed + 1)
60 NEWUSERPASS
=testPaSS@
01%
62 echo "set password with pdbedit"
63 cat >$PREFIX/tmpsmbpasswdscript
<<EOF
66 expect retype new password:
70 testit
"create user with pdbedit" $texpect $PREFIX/tmpsmbpasswdscript
$VALGRIND $pdbedit --configfile=$SMB_CONF -a $USER --account-desc="pdbedit-test-user" "$@" || failed
=$
(expr $failed + 1)
73 test_smbclient
"Test login with user (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS "$@" || failed
=$
(expr $failed + 1)
75 testit
"modify user" $VALGRIND $pdbedit --configfile=$SMB_CONF --modify $USER --drive="D:" "$@" || failed
=$
(expr $failed + 1)
77 test_smbclient
"Test login with user (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS "$@" || failed
=$
(expr $failed + 1)
79 NEWUSERPASS
=testPaSS@
02%
81 testit
"set user password with smbpasswd" \
82 test_smbpasswd
$USER $NEWUSERPASS ||
83 failed
=$
(expr $failed + 1)
87 test_smbclient
"Test login with user (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS "$@" || failed
=$
(expr $failed + 1)
89 testit
"modify user - disabled" $VALGRIND $net sam
set disabled
$USER yes "$@" || failed
=$
(expr $failed + 1)
91 testit_expect_failure
"Test login with disabled suer" $VALGRIND $smbclient //$SERVER/tmp
-c 'ls' -U$USER@
%$USERPASS || failed
=$
(expr $failed + 1)
93 testit
"modify user - enabled" $VALGRIND $net sam
set disabled
$USER no
"$@" || failed
=$
(expr $failed + 1)
95 test_smbclient
"Test login with re-enabled user (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS || failed
=$
(expr $failed + 1)
97 testit
"modify user - must change password now" $VALGRIND $net sam
set pwdmustchangenow
$USER yes "$@" || failed
=$
(expr $failed + 1)
99 testit_expect_failure
"Test login with expired password" $VALGRIND $smbclient //$SERVER/tmp
-c 'ls' -U$USER@
%$USERPASS || failed
=$
(expr $failed + 1)
101 testit
"modify user - disable password expiry" $VALGRIND $net sam
set pwnoexp
$USER yes "$@" || failed
=$
(expr $failed + 1)
103 test_smbclient
"Test login with no expiry (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS || failed
=$
(expr $failed + 1)
105 NEWUSERPASS
=testPaSS@
03%
106 NEWUSERHASH
=062519096c45739c1938800f80906731
108 testit
"Set user password with password hash" $VALGRIND $pdbedit --configfile=$SMB_CONF -u $USER --set-nt-hash $NEWUSERHASH "$@" || failed
=$
(expr $failed + 1)
110 test_smbclient
"Test login with new password (from hash)" 'ls' "$unc" -U$USER%$NEWUSERPASS || failed
=$
(expr $failed + 1)
112 testit
"del user" $VALGRIND $pdbedit --configfile=$SMB_CONF -x $USER "$@" || failed
=$
(expr $failed + 1)
114 rm $PREFIX/tmpsmbpasswdscript