s3: tests: Add blackbox test for scopy.
authorJeremy Allison <jra@samba.org>
Mon, 13 Jul 2015 21:15:45 +0000 (14:15 -0700)
committerRalph Böhme <slow@samba.org>
Tue, 14 Jul 2015 14:10:44 +0000 (16:10 +0200)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Jul 14 16:10:44 CEST 2015 on sn-devel-104

source3/script/tests/test_smbclient_s3.sh

index faf8d98d0c6e9a6711df53d429b4a4bd6b452975..69c7452c1f54abc1af8a04e979cf68efc75acde9 100755 (executable)
@@ -896,6 +896,81 @@ EOF
     fi
 }
 
+# Test using scopy to copy a file on the server.
+test_scopy()
+{
+    tmpfile=$PREFIX/smbclient_interactive_prompt_commands
+    scopy_file=$PREFIX/scopy_file
+
+    rm -f $scopy_file
+    cat > $tmpfile <<EOF
+put ${SMBCLIENT}
+scopy smbclient scopy_file
+lcd ${PREFIX}
+get scopy_file
+del smbclient
+del scopy_file
+quit
+EOF
+    cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -mSMB3 -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    ret=$?
+    out1=`md5sum ${SMBCLIENT} | sed -e 's/ .*//'`
+    out2=`md5sum ${scopy_file} | sed -e 's/ .*//'`
+    rm -f $tmpfile
+    rm -f $scopy_file
+
+    if [ $ret != 0 ] ; then
+       echo "$out"
+       echo "failed scopy test (1) with output $ret"
+       false
+       return
+    fi
+
+    if [ $out1 != $out2 ] ; then
+       echo "$out1 $out2"
+       echo "failed md5sum (1)"
+       false
+    fi
+
+#
+# Now do again using SMB1
+# to force client-side fallback.
+#
+
+    cat > $tmpfile <<EOF
+put ${SMBCLIENT}
+scopy smbclient scopy_file
+lcd ${PREFIX}
+get scopy_file
+del smbclient
+del scopy_file
+quit
+EOF
+    cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -mNT1 -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    ret=$?
+    out1=`md5sum ${SMBCLIENT} | sed -e 's/ .*//'`
+    out2=`md5sum ${scopy_file} | sed -e 's/ .*//'`
+    rm -f $tmpfile
+    rm -f $scopy_file
+
+    if [ $ret != 0 ] ; then
+       echo "$out"
+       echo "failed scopy test (2) with output $ret"
+       false
+       return
+    fi
+
+    if [ $out1 != $out2 ] ; then
+       echo "$out1 $out2"
+       echo "failed md5sum (2)"
+       false
+    fi
+}
+
 
 LOGDIR_PREFIX=test_smbclient_s3
 
@@ -980,6 +1055,10 @@ testit "list a share with a mangled name + acl_xattr object" \
     test_mangled_names || \
     failed=`expr $failed + 1`
 
+testit "server-side file copy" \
+    test_scopy || \
+    failed=`expr $failed + 1`
+
 testit "rm -rf $LOGDIR" \
     rm -rf $LOGDIR || \
     failed=`expr $failed + 1`