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
Usage: test_smbclient.sh SERVER USERNAME PASSWORD DOMAIN PREFIX
EOF
exit 1;
fi
SERVER = $1
USERNAME = $2
PASSWORD = $3
DOMAIN = $4
PREFIX = $5
shift 5
failed = 0
2007-01-14 04:33:16 +03:00
testit( ) {
2006-07-27 22:10:56 +04:00
name = " $1 "
shift
2007-01-14 04:33:16 +03:00
cmdline = " $* "
echo " test: $name "
$cmdline
status = $?
if [ x$status = x0 ] ; then
echo " success: $name "
else
echo " failure: $name "
fi
return $status
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 "
$VALGRIND bin/smbclient $CONFIGURATION //$SERVER /tmp -c " $cmd " -W " $DOMAIN " -U" $USERNAME % $PASSWORD " $@
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-07-12 10:15:47 +04:00
testit "share and server list" $VALGRIND bin/smbclient -L $SERVER $CONFIGURATION -W " $DOMAIN " -U" $USERNAME % $PASSWORD " $@ || failed = ` expr $failed + 1`
2007-08-11 22:31:27 +04:00
testit "share and server list anonymously" $VALGRIND bin/smbclient -N -L $SERVER $CONFIGURATION $@ || failed = ` expr $failed + 1`
2007-04-11 16:10:40 +04:00
testit "domain join" $VALGRIND bin/net join $DOMAIN $CONFIGURATION -W " $DOMAIN " -U" $USERNAME % $PASSWORD " $@ || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
# Generate random file
cat >tmpfile<<EOF
foo
bar
bloe
blah
EOF
# put that file
2007-07-19 10:40:42 +04:00
runcmd "MPutting file" '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
mv tmpfile tmpfile-old
2007-07-19 10:40:42 +04:00
runcmd "MGetting file" '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
2006-01-26 14:47:45 +03:00
testit "Comparing files" diff tmpfile-old 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 parent directory
2007-07-19 10:40:42 +04:00
runcmd "Removing directory" 'rmdir bla/bloe' || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
# remove child directory
2007-07-19 10:40:42 +04:00
runcmd "Removing directory" 'rmdir bla' || failed = ` expr $failed + 1`
2006-01-26 09:35:13 +03:00
# run fsinfo
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
2007-07-19 10:40:42 +04:00
runcmd "Putting file" 'put tmpfile' || failed = ` expr $failed + 1`
2006-05-25 02:15:03 +04:00
# get that file
mv tmpfile tmpfile-old
2007-07-19 10:40:42 +04:00
runcmd "Getting file" 'get 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
testit "Comparing files" diff tmpfile-old tmpfile || failed = ` expr $failed + 1`
# put that file
2007-07-19 10:40:42 +04:00
runcmd "Putting file with different name" 'put tmpfile tmpfilex' || failed = ` expr $failed + 1`
2006-05-25 02:15:03 +04:00
# get that file
2007-07-19 10:40:42 +04:00
runcmd "Getting file again" 'get tmpfilex' || failed = ` expr $failed + 1`
2006-05-25 02:15:03 +04:00
# compare locally
testit "Comparing files" diff tmpfilex tmpfile || failed = ` expr $failed + 1`
# 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
2006-07-27 22:10:56 +04:00
# do some simple operations using old protocol versions
2007-07-19 10:40:42 +04:00
runcmd "List directory with LANMAN1" 'ls' -m LANMAN1 || failed = ` expr $failed + 1`
runcmd "List directory with LANMAN2" 'ls' -m LANMAN2 || 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-07-19 10:40:42 +04:00
testit "Test login with --machine-pass without kerberos" $VALGRIND bin/smbclient -c 'ls' $CONFIGURATION //$SERVER /tmp --machine-pass -k no || failed = ` expr $failed + 1`
2007-04-12 14:25:01 +04:00
2007-07-19 10:40:42 +04:00
testit "Test login with --machine-pass and kerberos" $VALGRIND bin/smbclient -c 'ls' $CONFIGURATION //$SERVER /tmp --machine-pass -k yes || failed = ` expr $failed + 1`
2007-03-07 07:20:10 +03:00
(
echo " password= $PASSWORD "
echo " username= $USERNAME "
echo " domain= $DOMAIN "
) > tmpauthfile
2007-07-19 10:40:42 +04:00
testit "Test login with --authentication-file" $VALGRIND bin/smbclient -c 'ls' $CONFIGURATION //$SERVER /tmp --authentication-file= tmpauthfile || failed = ` expr $failed + 1`
2007-03-07 07:20:10 +03:00
PASSWD_FILE = "tmppassfile"
echo " $PASSWORD " > $PASSWD_FILE
export PASSWD_FILE
2007-07-19 10:40:42 +04:00
testit "Test login with PASSWD_FILE" $VALGRIND bin/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-07-19 10:40:42 +04:00
testit "Test login with PASSWD" $VALGRIND bin/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
2007-08-12 04:50:25 +04:00
testit "Test login with USER and PASSWD" $VALGRIND bin/smbclient -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
rm -f tmpfile tmpfile-old tmpfilex tmpauthfile tmppassfile
2007-01-14 04:33:16 +03:00
exit $failed