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
35 testit
"pdbtest" $VALGRIND $BINDIR/pdbtest
-u $USER $@ || failed
=`expr $failed + 1`
37 NEWUSERPASS
=testPaSS@
01%
39 echo "set password with pdbedit"
40 cat > .
/tmpsmbpasswdscript
<<EOF
43 expect retype new password:
47 testit
"create user with pdbedit" $texpect .
/tmpsmbpasswdscript
$VALGRIND $pdbedit -a $USER --account-desc="pdbedit-test-user" $@ || failed
=`expr $failed + 1`
50 test_smbclient
"Test login with user (ntlm)" 'ls' "$unc" -k no
-U$USER%$NEWUSERPASS $@ || failed
=`expr $failed + 1`
52 testit
"modify user" $VALGRIND $pdbedit --modify $USER --drive="D:" $@ || failed
=`expr $failed + 1`
54 test_smbclient
"Test login with user (ntlm)" 'ls' "$unc" -k no
-U$USER%$NEWUSERPASS $@|| failed
=`expr $failed + 1`
56 NEWUSERPASS
=testPaSS@
02%
58 echo "set password with smbpasswd"
59 cat > .
/tmpsmbpasswdscript
<<EOF
60 expect New SMB password:
62 expect Retype new SMB password:
66 testit
"set user password with smbpasswd" $texpect .
/tmpsmbpasswdscript
$smbpasswd -L $USER -c $SMB_CONF || failed
=`expr $failed + 1`
69 test_smbclient
"Test login with user (ntlm)" 'ls' "$unc" -k no
-U$USER%$NEWUSERPASS $@|| failed
=`expr $failed + 1`
71 testit
"modify user - disabled" $VALGRIND $net sam
set disabled
$USER yes $@ || failed
=`expr $failed + 1`
73 testit_expect_failure
"Test login with disabled suer" $VALGRIND $smbclient //$SERVER/tmp
-c 'ls' -k no
-U$USER@
%$USERPASS && failed
=`expr $failed + 1`
75 testit
"modify user - enabled" $VALGRIND $net sam
set disabled
$USER no $@ || failed
=`expr $failed + 1`
77 test_smbclient
"Test login with re-enabled user (ntlm)" 'ls' "$unc" -k no
-U$USER%$NEWUSERPASS || failed
=`expr $failed + 1`
79 testit
"modify user - must change password now" $VALGRIND $net sam
set pwdmustchangenow
$USER yes $@ || failed
=`expr $failed + 1`
81 testit_expect_failure
"Test login with expired password" $VALGRIND $smbclient //$SERVER/tmp
-c 'ls' -k no
-U$USER@
%$USERPASS && failed
=`expr $failed + 1`
83 testit
"modify user - disable password expiry" $VALGRIND $net sam
set pwnoexp
$USER yes $@ || failed
=`expr $failed + 1`
85 test_smbclient
"Test login with no expiry (ntlm)" 'ls' "$unc" -k no
-U$USER%$NEWUSERPASS || failed
=`expr $failed + 1`
87 NEWUSERPASS
=testPaSS@
03%
88 NEWUSERHASH
=062519096c45739c1938800f80906731
90 testit
"Set user password with password hash" $VALGRIND $pdbedit -u $USER --set-nt-hash $NEWUSERHASH $@ || failed
=`expr $failed + 1`
92 test_smbclient
"Test login with new password (from hash)" 'ls' "$unc" -k no
-U$USER%$NEWUSERPASS || failed
=`expr $failed + 1`
94 testit
"del user" $VALGRIND $pdbedit -x $USER $@ || failed
=`expr $failed + 1`
96 rm .
/tmpsmbpasswdscript