summaryrefslogtreecommitdiff
path: root/source3/script
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2020-02-13 13:48:17 +0100
committerJeremy Allison <jra@samba.org>2020-02-18 21:07:44 +0000
commite2ea059e671140b32ea2ab1a35691a8e35d4a5f4 (patch)
tree4048939edff5af63fd8a4d4252d739f7c8446f51 /source3/script
parentf1577c2bc13c91ea912ae461870e470065f250c1 (diff)
downloadsamba-e2ea059e671140b32ea2ab1a35691a8e35d4a5f4.tar.gz
s3:tests: Add test for a dropbox with dir mode 0733
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Feb 18 21:07:44 UTC 2020 on sn-devel-184
Diffstat (limited to 'source3/script')
-rwxr-xr-xsource3/script/tests/test_dropbox.sh88
1 files changed, 88 insertions, 0 deletions
diff --git a/source3/script/tests/test_dropbox.sh b/source3/script/tests/test_dropbox.sh
new file mode 100755
index 00000000000..d9d5101da30
--- /dev/null
+++ b/source3/script/tests/test_dropbox.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# Blackbox test for valid users.
+#
+
+if [ $# -lt 7 ]; then
+cat <<EOF
+Usage: $0 SERVER DOMAIN USERNAME PASSWORD PREFIX TARGET_ENV SMBCLIENT
+EOF
+exit 1;
+fi
+
+SERVER=${1}
+DOMAIN=${2}
+USERNAME=${3}
+PASSWORD=${4}
+PREFIX=${5}
+TARGET_ENV=${6}
+SMBCLIENT=${7}
+shift 7
+SMBCLIENT="$VALGRIND ${SMBCLIENT}"
+ADDARGS="$@"
+
+incdir=`dirname $0`/../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+failed=0
+
+# Test listing a share with valid users succeeds
+test_dropbox()
+{
+ local filename="wurst.$$"
+ local filename_path="$PREFIX/$filename"
+ local dropbox_path="$PREFIX/$TARGET_ENV/share/$1/dirmode733"
+
+ local tmpfile=$PREFIX/smbclient.in.$$
+
+ echo "wurstbar" > $filename_path
+
+ cat > $tmpfile <<EOF
+lcd $PREFIX
+put $filename dirmode733\\$filename
+quit
+EOF
+
+ # Create dropbox directory and set permissions
+ mkdir -p $dropbox_path
+ chmod 0333 $dropbox_path
+
+ local cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT //$SERVER/$1 -U$USERNAME%$PASSWORD $ADDARGS < $tmpfile 2>&1'
+ eval echo "$cmd"
+ out=`eval $cmd`
+ ret=$?
+
+ # Reset dropbox permissions
+ chmod 0755 $dropbox_path
+ rm -f $tmpfile
+
+ if [ $ret != 0 ] ; then
+ echo "Failed accessing share $ret"
+ echo "$out"
+
+ return 1
+ fi
+ rm -f $filename_path
+
+ dropped_file="$dropbox_path/$filename"
+ if [ ! -r "$dropped_file" ]; then
+ echo "Failed to drop file $filename"
+ echo "$out"
+ return 1
+ fi
+
+ content=`cat $dropped_file`
+ if [ "$content" != "wurstbar" ]; then
+ echo "Invalid file content: $content"
+ echo "$out"
+ return 1
+ fi
+
+ return 0
+}
+
+testit "dropbox dirmode 0733" \
+ test_dropbox dropbox || \
+ failed=`expr $failed + 1`
+
+exit $failed