Bug fixing
This commit is contained in:
20
test.sh
20
test.sh
@@ -267,4 +267,24 @@ fi
|
||||
curl -s -H "Authorization: Bearer ${WRITE_TOKEN}" "${BASE_URL}/deleteobject?hash=${FIRST_HASH}" > /dev/null
|
||||
curl -s -H "Authorization: Bearer ${WRITE_TOKEN}" "${BASE_URL}/deleteobject?hash=${SECOND_HASH}" > /dev/null
|
||||
|
||||
# Test 3: Verify rate limiting behavior
|
||||
title "Testing rate limiting behavior"
|
||||
|
||||
# Use a known invalid token
|
||||
INVALID_TOKEN="invalid_token"
|
||||
|
||||
# Make 5 requests with an invalid token
|
||||
for i in {1..5}; do
|
||||
echo "Attempt $i with invalid token"
|
||||
RESPONSE=$(curl -s -X PUT -H "Authorization: Bearer ${INVALID_TOKEN}" -F "file=@${SCRIPT_DIR}/${SCRIPT_NAME}" -F "metadata={\"labeltags\":[\"test:latest\"]}" "${BASE_URL}/upload")
|
||||
echo "Response: ${RESPONSE}"
|
||||
done
|
||||
|
||||
# Now try a request with a valid token - should be rate limited
|
||||
echo "Attempting request with valid token (should 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 rate limit error, got: ${RESPONSE}"
|
||||
fi
|
||||
|
||||
title "ALL TESTS PASSED"
|
||||
|
Reference in New Issue
Block a user