s4:torture/smb2: skip lease tests if the server doesn't support them
[Samba.git] / testprogs / blackbox / test_pdbtest.sh
blob017116c206e8489300d0b4ca9537321f3e2de25a
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"
28 . `dirname $0`/subunit.sh
30 test_smbclient() {
31 name="$1"
32 cmd="$2"
33 shift
34 shift
35 echo "test: $name"
36 $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" $@
37 status=$?
38 if [ x$status = x0 ]; then
39 echo "success: $name"
40 else
41 echo "failure: $name"
43 return $status
46 UID_WRAPPER_ROOT=1
47 export UID_WRAPPER_ROOT
49 testit "pdbtest" $VALGRIND $BINDIR/pdbtest -u $USER $@ || failed=`expr $failed + 1`
51 NEWUSERPASS=testPaSS@01%
53 echo "set password with pdbedit"
54 cat > ./tmpsmbpasswdscript <<EOF
55 expect new password:
56 send ${NEWUSERPASS}\n
57 expect retype new password:
58 send ${NEWUSERPASS}\n
59 EOF
61 testit "create user with pdbedit" $texpect ./tmpsmbpasswdscript $VALGRIND $pdbedit -a $USER --account-desc="pdbedit-test-user" $@ || failed=`expr $failed + 1`
62 USERPASS=$NEWUSERPASS
64 test_smbclient "Test login with user (ntlm)" 'ls' -k no -U$USER%$NEWUSERPASS $@ || failed=`expr $failed + 1`
66 testit "modify user" $VALGRIND $pdbedit --modify $USER --drive="D:" $@ || failed=`expr $failed + 1`
68 test_smbclient "Test login with user (ntlm)" 'ls' -k no -U$USER%$NEWUSERPASS $@|| failed=`expr $failed + 1`
70 NEWUSERPASS=testPaSS@02%
72 echo "set password with smbpasswd"
73 cat > ./tmpsmbpasswdscript <<EOF
74 expect New SMB password:
75 send ${NEWUSERPASS}\n
76 expect Retype new SMB password:
77 send ${NEWUSERPASS}\n
78 EOF
80 testit "set user password with smbpasswd" $texpect ./tmpsmbpasswdscript $smbpasswd -L $USER -c $SMB_CONF || failed=`expr $failed + 1`
81 USERPASS=$NEWUSERPASS
83 test_smbclient "Test login with user (ntlm)" 'ls' -k no -U$USER%$NEWUSERPASS $@|| failed=`expr $failed + 1`
85 testit "modify user - disabled" $VALGRIND $net sam set disabled $USER yes $@ || failed=`expr $failed + 1`
87 testit_expect_failure "Test login with disabled suer" $VALGRIND $smbclient //$SERVER/tmp -c 'ls' -k no -U$USER@%$USERPASS && failed=`expr $failed + 1`
89 testit "modify user - enabled" $VALGRIND $net sam set disabled $USER no $@ || failed=`expr $failed + 1`
91 test_smbclient "Test login with re-enabled user (ntlm)" 'ls' -k no -U$USER%$NEWUSERPASS || failed=`expr $failed + 1`
93 testit "modify user - must change password now" $VALGRIND $net sam set pwdmustchangenow $USER yes $@ || failed=`expr $failed + 1`
95 testit_expect_failure "Test login with expired password" $VALGRIND $smbclient //$SERVER/tmp -c 'ls' -k no -U$USER@%$USERPASS && failed=`expr $failed + 1`
97 testit "modify user - disable password expiry" $VALGRIND $net sam set pwnoexp $USER yes $@ || failed=`expr $failed + 1`
99 test_smbclient "Test login with no expiry (ntlm)" 'ls' -k no -U$USER%$NEWUSERPASS || failed=`expr $failed + 1`
101 testit "del user" $VALGRIND $pdbedit -x $USER $@ || failed=`expr $failed + 1`
103 rm ./tmpsmbpasswdscript
105 exit $failed