rpcclient3: Factor out cli_rpc_pipe_open_bind_schannel()
[Samba.git] / testprogs / blackbox / test_pdbtest.sh
blob2ffded9af4ed3ebf1847c60752b735feb28ef143
1 #!/bin/sh
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>
6 if [ $# -lt 2 ]; then
7 cat <<EOF
8 Usage: test_pdbtest.sh SERVER PREFIX USER SMBCLIENT SMB_CONF
9 EOF
10 exit 1;
13 SERVER=$1
14 PREFIX=$2
15 USER=$3
16 smbclient=$4
17 SMB_CONF=$5
18 shift 5
19 failed=0
21 samba4bindir="$BINDIR"
22 pdbtest="$samba4bindir/pdbtest"
23 pdbedit="$samba4bindir/pdbedit"
24 net="$samba4bindir/net"
25 smbpasswd="$samba4bindir/smbpasswd"
26 texpect="$samba4bindir/texpect"
27 unc="//$SERVER/tmp"
29 . `dirname $0`/subunit.sh
30 . `dirname $0`/common_test_fns.inc
32 UID_WRAPPER_ROOT=1
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
41 expect new password:
42 send ${NEWUSERPASS}\n
43 expect retype new password:
44 send ${NEWUSERPASS}\n
45 EOF
47 testit "create user with pdbedit" $texpect ./tmpsmbpasswdscript $VALGRIND $pdbedit -a $USER --account-desc="pdbedit-test-user" $@ || failed=`expr $failed + 1`
48 USERPASS=$NEWUSERPASS
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:
61 send ${NEWUSERPASS}\n
62 expect Retype new SMB password:
63 send ${NEWUSERPASS}\n
64 EOF
66 testit "set user password with smbpasswd" $texpect ./tmpsmbpasswdscript $smbpasswd -L $USER -c $SMB_CONF || failed=`expr $failed + 1`
67 USERPASS=$NEWUSERPASS
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
98 exit $failed