From 6efa917a2a5ea24e358123c855ac8094fb338088 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 25 May 2025 15:19:48 +1200 Subject: [PATCH] Bug fixing --- test.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test.sh b/test.sh index 8127359..9b0b923 100755 --- a/test.sh +++ b/test.sh @@ -287,4 +287,23 @@ if ! echo "${RESPONSE}" | jq -r '.error' | grep -q "Too many authentication atte die "Expected rate limit error, got: ${RESPONSE}" fi +echo "Sleeping for 3 seconds to allow rate limit to reset" +echo "(Normally 5 mins, but we set to 2s for this test!)" + +sleep 3 +# Now try a request with a valid token - should be rate limited +echo "Attempting request with valid token (should NOT be rate limited)" +RESPONSE=$(curl -s -X PUT -H "Authorization: Bearer ${WRITE_TOKEN}" -F "file=@${SCRIPT_DIR}/${SCRIPT_NAME}" -F "metadata={\"labeltags\":[\"test:latest\"]}" "${BASE_URL}/upload") +if echo "${RESPONSE}" | jq -r '.error' | grep -q "Too many authentication attempts"; then + die "Expected no rate limit error, got: ${RESPONSE}" +fi + +# delete the object +TODELHASH=$(curl -s "${BASE_URL}/hash/test:latest" | jq -r '.hash') +echo "deleting test:latest ${TODELHASH}" + +if ! curl -s -H "Authorization: Bearer ${WRITE_TOKEN}" "${BASE_URL}/deleteobject?hash=${TODELHASH}" | jq -r '.result' | grep -q 'success'; then + die "failed to delete ${TODELHASH}" +fi + title "ALL TESTS PASSED"