2006-01-26 09:35:13 +03:00
#!/bin/sh
2007-05-28 18:24:36 +04:00
# Blackbox tests for smbclient
# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
# Copyright (C) 2006-2007 Andrew Bartlett <abartlet@samba.org>
2006-01-26 09:35:13 +03:00
if [ $# -lt 5 ] ; then
cat <<EOF
2012-05-30 13:48:02 +04:00
Usage: test_smbclient.sh SERVER USERNAME PASSWORD DOMAIN PREFIX SMBCLIENT
2006-01-26 09:35:13 +03:00
EOF
exit 1;
fi
SERVER = $1
USERNAME = $2
PASSWORD = $3
DOMAIN = $4
PREFIX = $5
2012-05-30 13:48:02 +04:00
smbclient = $6
shift 6
2006-01-26 09:35:13 +03:00
failed = 0
2008-06-26 12:56:59 +04:00
. ` dirname $0 ` /../../../testprogs/blackbox/subunit.sh
2006-01-26 09:35:13 +03:00
2007-01-14 04:33:16 +03:00
runcmd( ) {
name = " $1 "
2007-07-19 10:40:42 +04:00
cmd = " $2 "
2007-01-14 04:33:16 +03:00
shift
2007-07-19 10:40:42 +04:00
shift
echo " test: $name "
2007-09-02 04:04:27 +04:00
$VALGRIND $smbclient $CONFIGURATION //$SERVER /tmp -c " $cmd " -W " $DOMAIN " -U" $USERNAME % $PASSWORD " $@
2007-07-19 10:40:42 +04:00
status = $?
if [ x$status = x0 ] ; then
echo " success: $name "
else
echo " failure: $name "
fi
return $status
2007-01-14 04:33:16 +03:00
}
2006-01-26 09:35:13 +03:00
2007-09-02 04:04:27 +04:00
testit "share and server list" $VALGRIND $smbclient -L $SERVER $CONFIGURATION -W " $DOMAIN " -U" $USERNAME % $PASSWORD " $@ || failed = ` expr $failed + 1`
2007-07-12 10:15:47 +04:00
2007-09-02 04:04:27 +04:00
testit "share and server list anonymously" $VALGRIND $smbclient -N -L $SERVER $CONFIGURATION $@ || failed = ` expr $failed + 1`
2007-08-11 22:31:27 +04:00
2009-08-04 05:12:33 +04:00
# Use the smbclient binary as our test file
2020-11-23 11:58:30 +03:00
cat $smbclient >$PREFIX /tmpfile
2006-01-26 09:35:13 +03:00
# put that file
2020-11-23 11:58:30 +03:00
runcmd "MPutting file" " lcd $PREFIX ; mput tmpfile " || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
# check file info
2007-07-19 10:40:42 +04:00
runcmd "Getting alternative name" 'altname tmpfile' || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
# run allinfo on that file
2007-07-19 10:40:42 +04:00
runcmd "Checking info on file" 'allinfo tmpfile' || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
# get that file
2020-11-23 11:58:30 +03:00
mv $PREFIX /tmpfile $PREFIX /tmpfile-old
runcmd "MGetting file" " lcd $PREFIX ; mget tmpfile " || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
# remove that file
2007-07-19 10:40:42 +04:00
runcmd "Removing file" 'rm tmpfile' || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
# compare locally
2020-11-23 11:58:30 +03:00
testit "Comparing files" diff $PREFIX /tmpfile-old $PREFIX /tmpfile || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
# create directory
# cd to directory
# cd to top level directory
# remove directory
2007-08-27 04:36:26 +04:00
runcmd "Creating directory, Changing directory, Going back" 'mkdir bla; cd bla; cd ..; rmdir bla' || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
# enable recurse, create nested directory
2007-07-19 10:40:42 +04:00
runcmd "Creating nested directory" 'mkdir bla/bloe' || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
# remove child directory
2008-04-15 12:05:29 +04:00
runcmd "Removing directory" 'rmdir bla/bloe' || failed = ` expr $failed + 1`
# remove parent directory
2007-07-19 10:40:42 +04:00
runcmd "Removing directory" 'rmdir bla' || failed = ` expr $failed + 1`
2008-04-15 12:05:29 +04:00
# enable recurse, create nested directory
runcmd "Creating nested directory" 'mkdir bla' || failed = ` expr $failed + 1`
# rename bla to bla2
runcmd "rename of nested directory" 'rename bla bla2' || failed = ` expr $failed + 1`
# deltree
runcmd "deltree of nested directory" 'deltree bla2' || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
# run fsinfo
2008-04-15 12:05:29 +04:00
runcmd "Getting file system info" 'fsinfo allocation' || failed = ` expr $failed + 1`
runcmd "Getting file system info" 'fsinfo volume' || failed = ` expr $failed + 1`
runcmd "Getting file system info" 'fsinfo volumeinfo' || failed = ` expr $failed + 1`
runcmd "Getting file system info" 'fsinfo sizeinfo' || failed = ` expr $failed + 1`
runcmd "Getting file system info" 'fsinfo deviceinfo' || failed = ` expr $failed + 1`
runcmd "Getting file system info" 'fsinfo attributeinfo' || failed = ` expr $failed + 1`
runcmd "Getting file system info" 'fsinfo volume-information' || failed = ` expr $failed + 1`
runcmd "Getting file system info" 'fsinfo size-information' || failed = ` expr $failed + 1`
runcmd "Getting file system info" 'fsinfo device-information' || failed = ` expr $failed + 1`
runcmd "Getting file system info" 'fsinfo attribute-information' || failed = ` expr $failed + 1`
runcmd "Getting file system info" 'fsinfo quota-information' || failed = ` expr $failed + 1`
runcmd "Getting file system info" 'fsinfo fullsize-information' || failed = ` expr $failed + 1`
2007-07-19 10:40:42 +04:00
runcmd "Getting file system info" 'fsinfo objectid' || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
2006-05-25 02:15:03 +04:00
# put that file
2020-11-23 11:58:30 +03:00
runcmd "Putting file" " lcd $PREFIX ; put tmpfile " || failed = ` expr $failed + 1`
2006-05-25 02:15:03 +04:00
# get that file
2020-11-23 11:58:30 +03:00
mv $PREFIX /tmpfile $PREFIX /tmpfile-old
runcmd "Getting file" " lcd $PREFIX ; get tmpfile " || failed = ` expr $failed + 1`
2008-04-15 12:05:29 +04:00
runcmd "Getting file EA info" 'eainfo tmpfile' || failed = ` expr $failed + 1`
2006-05-25 02:15:03 +04:00
# remove that file
2007-07-19 10:40:42 +04:00
runcmd "Removing file" 'rm tmpfile' || failed = ` expr $failed + 1`
2006-05-25 02:15:03 +04:00
# compare locally
2020-11-23 11:58:30 +03:00
testit "Comparing files" diff $PREFIX /tmpfile-old $PREFIX /tmpfile || failed = ` expr $failed + 1`
2006-05-25 02:15:03 +04:00
# put that file
2020-11-23 11:58:30 +03:00
runcmd "Putting file with different name" " lcd $PREFIX ; put tmpfile tmpfilex " || failed = ` expr $failed + 1`
2006-05-25 02:15:03 +04:00
# get that file
2020-11-23 11:58:30 +03:00
runcmd "Getting file again" " lcd $PREFIX ; get tmpfilex " || failed = ` expr $failed + 1`
2006-05-25 02:15:03 +04:00
# compare locally
2020-11-23 11:58:30 +03:00
testit "Comparing files" diff $PREFIX /tmpfilex $PREFIX /tmpfile || failed = ` expr $failed + 1`
2006-05-25 02:15:03 +04:00
# remove that file
2007-07-19 10:40:42 +04:00
runcmd "Removing file" 'rm tmpfilex' || failed = ` expr $failed + 1`
2006-05-25 02:15:03 +04:00
2008-04-15 12:05:29 +04:00
runcmd "Lookup name" " lookup $DOMAIN \\ $USERNAME " || failed = ` expr $failed + 1`
2009-10-19 11:47:33 +04:00
#Fails unless there are privileges
2008-04-15 12:05:29 +04:00
#runcmd "Lookup privs of name" "privileges $DOMAIN\\$USERNAME" || failed=`expr $failed + 1`
2006-07-27 22:10:56 +04:00
# do some simple operations using old protocol versions
2010-12-04 09:02:49 +03:00
runcmd "List directory with LANMAN1" 'ls' -m LANMAN1 --option= clientntlmv2auth = no || failed = ` expr $failed + 1`
runcmd "List directory with LANMAN2" 'ls' -m LANMAN2 --option= clientntlmv2auth = no || failed = ` expr $failed + 1`
2006-07-27 22:10:56 +04:00
2007-07-19 10:40:42 +04:00
runcmd "Print current working directory" 'pwd' || failed = ` expr $failed + 1`
2007-05-28 18:24:36 +04:00
2007-03-07 07:20:10 +03:00
(
echo " password= $PASSWORD "
echo " username= $USERNAME "
echo " domain= $DOMAIN "
2020-11-23 11:58:30 +03:00
) > $PREFIX /tmpauthfile
2007-03-07 07:20:10 +03:00
2020-11-23 11:58:30 +03:00
testit "Test login with --authentication-file" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER /tmp --authentication-file= $PREFIX /tmpauthfile || failed = ` expr $failed + 1`
2007-03-07 07:20:10 +03:00
2020-11-23 11:58:30 +03:00
PASSWD_FILE = " $PREFIX /tmppassfile "
2007-03-07 07:20:10 +03:00
echo " $PASSWORD " > $PASSWD_FILE
export PASSWD_FILE
2007-09-02 04:04:27 +04:00
testit "Test login with PASSWD_FILE" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER /tmp -W " $DOMAIN " -U" $USERNAME " || failed = ` expr $failed + 1`
2007-03-07 07:20:10 +03:00
PASSWD_FILE = ""
export PASSWD_FILE
unset PASSWD_FILE
PASSWD = " $PASSWORD "
export PASSWD
2007-09-02 04:04:27 +04:00
testit "Test login with PASSWD" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER /tmp -W " $DOMAIN " -U" $USERNAME " || failed = ` expr $failed + 1`
2007-03-07 07:20:10 +03:00
oldUSER = $USER
USER = " $USERNAME "
export USER
2020-11-19 19:43:58 +03:00
testit "Test login with USER and PASSWD" $VALGRIND $smbclient --use-kerberos= disabled -c 'ls' $CONFIGURATION //$SERVER /tmp -W " $DOMAIN " || failed = ` expr $failed + 1`
2007-03-07 07:20:10 +03:00
PASSWD =
export PASSWD
unset PASSWD
USER = $oldUSER
export USER
2007-01-23 02:09:07 +03:00
2020-11-23 11:58:30 +03:00
rm -f $PREFIX /tmpfile $PREFIX /tmpfile-old $PREFIX /tmpfilex $PREFIX /tmpauthfile $PREFIX /tmppassfile
2007-01-14 04:33:16 +03:00
exit $failed