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
33 export UID_WRAPPER_ROOT
40 echo "set password with smbpasswd"
41 tmpfile
=$PREFIX/smbpasswd_change_password_script
43 expect New SMB password:
45 expect Retype new SMB password:
49 cmd
='UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $texpect $tmpfile $smbpasswd -L $user -c $SMB_CONF'
55 if [ $ret -ne 0 ]; then
56 echo "Failed to change user password $user"
61 testit
"pdbtest" $VALGRIND $BINDIR/pdbtest
-u $USER $@ || failed
=`expr $failed + 1`
63 NEWUSERPASS
=testPaSS@
01%
65 echo "set password with pdbedit"
66 cat > $PREFIX/tmpsmbpasswdscript
<<EOF
69 expect retype new password:
73 testit
"create user with pdbedit" $texpect $PREFIX/tmpsmbpasswdscript
$VALGRIND $pdbedit --configfile=$SMB_CONF -a $USER --account-desc="pdbedit-test-user" $@ || failed
=`expr $failed + 1`
76 test_smbclient
"Test login with user (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS $@ || failed
=`expr $failed + 1`
78 testit
"modify user" $VALGRIND $pdbedit --configfile=$SMB_CONF --modify $USER --drive="D:" $@ || failed
=`expr $failed + 1`
80 test_smbclient
"Test login with user (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS $@|| failed
=`expr $failed + 1`
82 NEWUSERPASS
=testPaSS@
02%
84 testit
"set user password with smbpasswd" \
85 test_smbpasswd
$USER $NEWUSERPASS \
86 || failed
=$
(expr $failed + 1)
90 test_smbclient
"Test login with user (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS $@|| failed
=`expr $failed + 1`
92 testit
"modify user - disabled" $VALGRIND $net sam
set disabled
$USER yes $@ || failed
=`expr $failed + 1`
94 testit_expect_failure
"Test login with disabled suer" $VALGRIND $smbclient //$SERVER/tmp
-c 'ls' -U$USER@
%$USERPASS && failed
=`expr $failed + 1`
96 testit
"modify user - enabled" $VALGRIND $net sam
set disabled
$USER no $@ || failed
=`expr $failed + 1`
98 test_smbclient
"Test login with re-enabled user (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS || failed
=`expr $failed + 1`
100 testit
"modify user - must change password now" $VALGRIND $net sam
set pwdmustchangenow
$USER yes $@ || failed
=`expr $failed + 1`
102 testit_expect_failure
"Test login with expired password" $VALGRIND $smbclient //$SERVER/tmp
-c 'ls' -U$USER@
%$USERPASS && failed
=`expr $failed + 1`
104 testit
"modify user - disable password expiry" $VALGRIND $net sam
set pwnoexp
$USER yes $@ || failed
=`expr $failed + 1`
106 test_smbclient
"Test login with no expiry (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS || failed
=`expr $failed + 1`
108 NEWUSERPASS
=testPaSS@
03%
109 NEWUSERHASH
=062519096c45739c1938800f80906731
111 testit
"Set user password with password hash" $VALGRIND $pdbedit --configfile=$SMB_CONF -u $USER --set-nt-hash $NEWUSERHASH $@ || failed
=`expr $failed + 1`
113 test_smbclient
"Test login with new password (from hash)" 'ls' "$unc" -U$USER%$NEWUSERPASS || failed
=`expr $failed + 1`
115 testit
"del user" $VALGRIND $pdbedit --configfile=$SMB_CONF -x $USER $@ || failed
=`expr $failed + 1`
117 rm $PREFIX/tmpsmbpasswdscript