--- a/test/bin-test/test-dav-put.sh Sun Jun 17 07:11:31 2018 +0200 +++ b/test/bin-test/test-dav-put.sh Sun Jun 17 07:49:25 2018 +0200 @@ -35,11 +35,13 @@ BASE_URL=`dav repo-url dav-test-repo` -# test +# +# test simple file upload +# echo "hello world" > hello dav put dav-test-repo/tests/ hello DAV_RES=$? -rm hello +rm -f hello if [ $DAV_RES -ne 0 ]; then echo "dav put returned" $DAV_RES @@ -59,4 +61,133 @@ exit 2 fi +echo "hello world" > hello +curl --silent -o cmphello $BASE_URL/tests/hello +diff hello cmphello > /dev/null +RES=$? +rm -f hello +rm -f cmphello +if [ $RES -ne 0 ]; then + echo "wrong content" + exit 2 +fi +# +# test dir upload +# +dav put -R dav-test-repo/tests/ testdir > /dev/null +if [ $? -ne 0 ]; then + echo "dir upload failed" + exit 2 +fi + +# check file1 +curl --silent -o tmp_file1 $BASE_URL/tests/file1 +if [ $? -ne 0 ]; then + echo "cannot download file1" + rm -f tmp_file1 + exit 2 +fi + +diff testdir/file1 tmp_file1 > /dev/null +if [ $? -ne 0 ]; then + echo "file1 has wrong content" + rm -f tmp_file1 + exit 2 +fi +rm tmp_file1 + +# check subdir file +curl --silent -o tmp_sub1 $BASE_URL/tests/subdir/sub1 +if [ $? -ne 0 ]; then + echo "cannot download subdir/sub1" + rm tmp_sub1 + exit 2 +fi + +diff testdir/subdir/sub1 tmp_sub1 > /dev/null +if [ $? -ne 0 ]; then + echo "subdir/sub1 has wrong content" + rm -f tmp_sub1 + exit 2 +fi +rm -f tmp_sub1 + +# check subdir +OUT=`dav info dav-test-repo/tests/subdir` +if [ $? -ne 0 ]; then + echo "cannot get subdir infos" + exit 2 +fi + +echo $OUT | grep "type: collection" > /dev/null +if [ $? -ne 0 ]; +then + echo "subdir has wrong type" + exit 2 +fi + +# +# test upload to specific url +# +dav put dav-test-repo/tests/uploaded_file testdir/file1 +if [ $? -ne 0 ]; then + echo "upload to /tests/uploaded_file failed" + exit 2 +fi +curl --silent -o /dev/null $BASE_URL/tests/uploaded_file +if [ $? -ne 0 ]; then + echo "uploaded_file has wrong content" + exit 2 +fi + +# +# test upload with automatic collection creation +# +dav put dav-test-repo/tests/newdir/newsubdir/newfile testdir/file2 +if [ $? -ne 0 ]; then + echo "upload to /tests/newdir/newsubdir/newfile failed" + exit 2 +fi +curl --silent -o /dev/null $BASE_URL/tests/newdir/newsubdir/newfile +if [ $? -ne 0 ]; then + echo "newfile has wrong content" + exit 2 +fi + +# +# test dir upload to specific url +# +dav put -R dav-test-repo/tests/testdir testdir > /dev/null +if [ $? -ne 0 ]; then + echo "dir upload to /tests/testdir failed" + exit 2 +fi + +OUT=`dav info dav-test-repo/tests/testdir` +if [ $? -ne 0 ]; then + echo "cannot get /tests/testdir infos" + exit 2 +fi + +echo $OUT | grep "type: collection" > /dev/null +if [ $? -ne 0 ]; +then + echo "/tests/testdir has wrong type" + exit 2 +fi + +curl --silent -o tmp_file3 $BASE_URL/tests/testdir/file3 +CURL_RES=$? +diff tmp_file3 testdir/file3 > /dev/null +DIFF_RES=$? +rm -f tmp_file3 + +if [ $CURL_RES -ne 0 ]; then + echo "cannot download /tests/testdir/file3" + exit 2 +fi +if [ $DIFF_RES -ne 0 ]; then + echo "/tests/testdir/file3 has wrong content" + exit 2 +fi