source: vendor/current/testprogs/blackbox/test_pdbtest.sh

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 3.5 KB
Line 
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>
5
6if [ $# -lt 2 ]; then
7cat <<EOF
8Usage: test_pdbtest.sh SERVER PREFIX USER SMBCLIENT SMB_CONF
9EOF
10exit 1;
11fi
12
13SERVER=$1
14PREFIX=$2
15USER=$3
16smbclient=$4
17SMB_CONF=$5
18shift 5
19failed=0
20
21samba4bindir="$BINDIR"
22pdbtest="$samba4bindir/pdbtest"
23pdbedit="$samba4bindir/pdbedit"
24net="$samba4bindir/net"
25smbpasswd="$samba4bindir/smbpasswd"
26texpect="$samba4bindir/texpect"
27
28. `dirname $0`/subunit.sh
29
30test_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"
42 fi
43 return $status
44}
45
46UID_WRAPPER_ROOT=1
47export UID_WRAPPER_ROOT
48
49testit "pdbtest" $VALGRIND $BINDIR/pdbtest -u $USER $@ || failed=`expr $failed + 1`
50
51NEWUSERPASS=testPaSS@01%
52
53echo "set password with pdbedit"
54cat > ./tmpsmbpasswdscript <<EOF
55expect new password:
56send ${NEWUSERPASS}\n
57expect retype new password:
58send ${NEWUSERPASS}\n
59EOF
60
61testit "create user with pdbedit" $texpect ./tmpsmbpasswdscript $VALGRIND $pdbedit -a $USER --account-desc="pdbedit-test-user" $@ || failed=`expr $failed + 1`
62USERPASS=$NEWUSERPASS
63
64test_smbclient "Test login with user (ntlm)" 'ls' -k no -U$USER%$NEWUSERPASS $@ || failed=`expr $failed + 1`
65
66testit "modify user" $VALGRIND $pdbedit --modify $USER --drive="D:" $@ || failed=`expr $failed + 1`
67
68test_smbclient "Test login with user (ntlm)" 'ls' -k no -U$USER%$NEWUSERPASS $@|| failed=`expr $failed + 1`
69
70NEWUSERPASS=testPaSS@02%
71
72echo "set password with smbpasswd"
73cat > ./tmpsmbpasswdscript <<EOF
74expect New SMB password:
75send ${NEWUSERPASS}\n
76expect Retype new SMB password:
77send ${NEWUSERPASS}\n
78EOF
79
80testit "set user password with smbpasswd" $texpect ./tmpsmbpasswdscript $smbpasswd -L $USER -c $SMB_CONF || failed=`expr $failed + 1`
81USERPASS=$NEWUSERPASS
82
83test_smbclient "Test login with user (ntlm)" 'ls' -k no -U$USER%$NEWUSERPASS $@|| failed=`expr $failed + 1`
84
85testit "modify user - disabled" $VALGRIND $net sam set disabled $USER yes $@ || failed=`expr $failed + 1`
86
87testit_expect_failure "Test login with disabled suer" $VALGRIND $smbclient //$SERVER/tmp -c 'ls' -k no -U$USER@%$USERPASS && failed=`expr $failed + 1`
88
89testit "modify user - enabled" $VALGRIND $net sam set disabled $USER no $@ || failed=`expr $failed + 1`
90
91test_smbclient "Test login with re-enabled user (ntlm)" 'ls' -k no -U$USER%$NEWUSERPASS || failed=`expr $failed + 1`
92
93testit "modify user - must change password now" $VALGRIND $net sam set pwdmustchangenow $USER yes $@ || failed=`expr $failed + 1`
94
95testit_expect_failure "Test login with expired password" $VALGRIND $smbclient //$SERVER/tmp -c 'ls' -k no -U$USER@%$USERPASS && failed=`expr $failed + 1`
96
97testit "modify user - disable password expiry" $VALGRIND $net sam set pwnoexp $USER yes $@ || failed=`expr $failed + 1`
98
99test_smbclient "Test login with no expiry (ntlm)" 'ls' -k no -U$USER%$NEWUSERPASS || failed=`expr $failed + 1`
100
101NEWUSERPASS=testPaSS@03%
102NEWUSERHASH=062519096c45739c1938800f80906731
103
104testit "Set user password with password hash" $VALGRIND $pdbedit -u $USER --set-nt-hash $NEWUSERHASH $@ || failed=`expr $failed + 1`
105
106test_smbclient "Test login with new password (from hash)" 'ls' -k no -U$USER%$NEWUSERPASS || failed=`expr $failed + 1`
107
108testit "del user" $VALGRIND $pdbedit -x $USER $@ || failed=`expr $failed + 1`
109
110rm ./tmpsmbpasswdscript
111
112exit $failed
Note: See TracBrowser for help on using the repository browser.