#! /bin/bash SCRIPT_DIR=$(dirname $0) SCRIPT_NAME=$(basename $0) # FUNCTIONS function title() { echo "----------------------------------------" # Center the text local text="$1" local line_length=40 local text_length=${#text} local padding=$(( (line_length - text_length) / 2 )) printf "%*s%s%*s\n" $padding "" "$text" $padding "" echo "----------------------------------------" } function die() { title "error: $1" exit 1 } # test jq is installed if ! command -v jq &> /dev/null; then echo "jq could not be found" echo "sudo apt-get install jq" exit 1 fi # read ~/.config/simple_object_storage/config.json CONFIG_PATH="${HOME}/.config/simple_object_storage/config.json" if [ ! -f "${CONFIG_PATH}" ]; then echo "config file not found at ${CONFIG_PATH}" exit 1 fi CONFIG=$(cat "${CONFIG_PATH}") # get the host and port from the config HOST=$(echo $CONFIG | jq -r '.host') PORT=$(echo $CONFIG | jq -r '.port') # extract the first write token from the config WRITE_TOKEN=$(echo $CONFIG | jq -r '.write_tokens[0]') BASE_URL="http://${HOST}:${PORT}" BASE_TAG="autotest" # test every action in the README.md file, leaving the system in the same state it was found # and print the output of each action # Construct metadata JSON METADATA_JSON=$(cat < /dev/null # Test 2: Verify tag versioning behavior title "Testing tag versioning behavior" # Upload first version with tag 'latest' FIRST_METADATA_JSON=$(cat < /dev/null curl -s -H "Authorization: Bearer ${WRITE_TOKEN}" "${BASE_URL}/deleteobject?hash=${SECOND_HASH}" > /dev/null title "ALL TESTS PASSED"