:-'Generic Commit'
This commit is contained in:
56
test.sh
56
test.sh
@@ -137,6 +137,62 @@ MD5SUM_DOWNLOADED2=$(md5sum "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded2" | awk '{p
|
|||||||
rm "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1"
|
rm "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1"
|
||||||
rm "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded2"
|
rm "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded2"
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------------------------
|
||||||
|
LABELTAG="finangle-wrangler:fuzzy_test"
|
||||||
|
title "3b: Upload script to ${LABELTAG}"
|
||||||
|
|
||||||
|
|
||||||
|
METADATA_JSON=$(cat <<EOF
|
||||||
|
{
|
||||||
|
"labeltags": ["${LABELTAG}"],
|
||||||
|
"description": "Test File for fuzzy test",
|
||||||
|
"custom_field": "Upload2!!!111 Yay. This is a test file for the fuzzy test."
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
# upload this script as an object
|
||||||
|
echo "uploading ${SCRIPT_DIR}/${SCRIPT_NAME} to ${LABELTAG}"
|
||||||
|
UPLOAD_RESPONSE=$(curl -X PUT \
|
||||||
|
-H "Authorization: Bearer ${WRITE_TOKEN}" \
|
||||||
|
-F "file=@${SCRIPT_DIR}/${SCRIPT_NAME}" \
|
||||||
|
-F "metadata=${METADATA_JSON}" \
|
||||||
|
"http://localhost:8123/upload")
|
||||||
|
|
||||||
|
echo "upload response: ${UPLOAD_RESPONSE}"
|
||||||
|
|
||||||
|
OBJECT_HASH2=$(echo "${UPLOAD_RESPONSE}" | jq -r '.hash')
|
||||||
|
|
||||||
|
if [ ! "${OBJECT_HASH}" == "${OBJECT_HASH2}" ]; then
|
||||||
|
die "object hash does not match: ${OBJECT_HASH} != ${OBJECT_HASH2}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# test the description and custom field matches our new ones.
|
||||||
|
METADATA_RESPONSE=$(curl "http://localhost:8123/meta/${OBJECT_HASH2}")
|
||||||
|
|
||||||
|
echo "metadata response: ${METADATA_RESPONSE}"
|
||||||
|
|
||||||
|
if ! echo "${METADATA_RESPONSE}" | jq -r '.metadata.description' | grep -q "Test File for fuzzy test"; then
|
||||||
|
die "description does not match"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! echo "${METADATA_RESPONSE}" | jq -r '.metadata.custom_field' | grep -q "Upload2!!!111 Yay. This is a test file for the fuzzy test."; then
|
||||||
|
die "custom field does not match"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# download via the label:tag
|
||||||
|
echo "downloading ${LABELTAG} to ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3"
|
||||||
|
if ! curl -s "${BASE_URL}/object/${LABELTAG}" -o "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3"; then
|
||||||
|
die "failed to download ${LABELTAG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get md5sum of the downloaded file
|
||||||
|
MD5SUM_DOWNLOADED3=$(md5sum "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3" | awk '{print $1}')
|
||||||
|
echo "md5sum of ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3 is ${MD5SUM_DOWNLOADED3}"
|
||||||
|
[ "${MD5SUM}" != "${MD5SUM_DOWNLOADED3}" ] && die "md5sums do not match"
|
||||||
|
|
||||||
|
rm "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
title "4: Delete the object"
|
title "4: Delete the object"
|
||||||
|
Reference in New Issue
Block a user