s3:rpc_server: let auth_generic_server_step() handle gensec_security == NULL
[Samba.git] / testprogs / blackbox / test_pdbtest.sh
blobaf822f9cc704d0dc2206d431b812370a9d2b28ed
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 SMBCLIENT SMB_CONF
9 EOF
10 exit 1;
13 SERVER=$1
14 PREFIX=$2
15 smbclient=$3
16 SMB_CONF=$4
17 shift 4
18 failed=0
20 samba4bindir="$BINDIR"
21 pdbtest="$samba4bindir/pdbtest"
22 pdbedit="$samba4bindir/pdbedit"
23 net="$samba4bindir/net"
24 smbpasswd="$samba4bindir/smbpasswd"
25 rkpty="$samba4bindir/rkpty"
27 . `dirname $0`/subunit.sh
29 test_smbclient() {
30 name="$1"
31 cmd="$2"
32 shift
33 shift
34 echo "test: $name"
35 $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" $@
36 status=$?
37 if [ x$status = x0 ]; then
38 echo "success: $name"
39 else
40 echo "failure: $name"
42 return $status
45 UID_WRAPPER_ROOT=1
46 export UID_WRAPPER_ROOT
48 testit "pdbtest" $BINDIR/pdbtest -u pdbtest || failed=`expr $failed + 1`
50 NEWUSERPASS=testPaSS@01%
52 echo "set password with pdbedit"
53 cat > ./tmpsmbpasswdscript <<EOF
54 expect new password:
55 send ${NEWUSERPASS}\n
56 expect retype new password:
57 send ${NEWUSERPASS}\n
58 EOF
60 testit "create user with pdbedit" $rkpty ./tmpsmbpasswdscript $VALGRIND $pdbedit -a pdbtest --account-desc="pdbedit-test-user" $@ || failed=`expr $failed + 1`
61 USERPASS=$NEWUSERPASS
63 test_smbclient "Test login with user (ntlm)" 'ls' -k no -Updbtest%$NEWUSERPASS $@ || failed=`expr $failed + 1`
65 testit "modify user" $VALGRIND $pdbedit --modify pdbtest --drive="D:" $@ || failed=`expr $failed + 1`
67 test_smbclient "Test login with user (ntlm)" 'ls' -k no -Updbtest%$NEWUSERPASS $@|| failed=`expr $failed + 1`
69 NEWUSERPASS=testPaSS@02%
71 echo "set password with smbpasswd"
72 cat > ./tmpsmbpasswdscript <<EOF
73 expect New SMB password:
74 send ${NEWUSERPASS}\n
75 expect Retype new SMB password:
76 send ${NEWUSERPASS}\n
77 EOF
79 testit "set user password with smbpasswd" $rkpty ./tmpsmbpasswdscript $smbpasswd -L pdbtest -c $SMB_CONF || failed=`expr $failed + 1`
80 USERPASS=$NEWUSERPASS
82 test_smbclient "Test login with user (ntlm)" 'ls' -k no -Updbtest%$NEWUSERPASS $@|| failed=`expr $failed + 1`
84 testit "modify user - disabled" $VALGRIND $net sam set disabled pdbtest yes $@ || failed=`expr $failed + 1`
86 testit_expect_failure "Test login with disabled suer" $VALGRIND $smbclient //$SERVER/tmp -c 'ls' -k no -Updbtest@%$USERPASS && failed=`expr $failed + 1`
88 testit "modify user - enabled" $VALGRIND $net sam set disabled pdbtest no $@ || failed=`expr $failed + 1`
90 test_smbclient "Test login with re-enabled user (ntlm)" 'ls' -k no -Updbtest%$NEWUSERPASS || failed=`expr $failed + 1`
92 testit "modify user - must change password now" $VALGRIND $net sam set pwdmustchangenow pdbtest yes $@ || failed=`expr $failed + 1`
94 testit_expect_failure "Test login with expired password" $VALGRIND $smbclient //$SERVER/tmp -c 'ls' -k no -Updbtest@%$USERPASS && failed=`expr $failed + 1`
96 testit "modify user - disable password expiry" $VALGRIND $net sam set pwnoexp pdbtest yes $@ || failed=`expr $failed + 1`
98 test_smbclient "Test login with no expiry (ntlm)" 'ls' -k no -Updbtest%$NEWUSERPASS || failed=`expr $failed + 1`
100 testit "del user" $VALGRIND $pdbedit -x pdbtest $@ || failed=`expr $failed + 1`
102 rm ./tmpsmbpasswdscript
104 exit $failed