From caf5425a76884fdcbbb8679dd96723c1ec29deac Mon Sep 17 00:00:00 2001 From: Caffeine Fueled Date: Wed, 1 Oct 2025 19:37:45 +0000 Subject: [PATCH] Add Bash/linedump-ratelimit-test --- Bash%2Flinedump-ratelimit-test.-.md | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Bash%2Flinedump-ratelimit-test.-.md diff --git a/Bash%2Flinedump-ratelimit-test.-.md b/Bash%2Flinedump-ratelimit-test.-.md new file mode 100644 index 0000000..6df1e50 --- /dev/null +++ b/Bash%2Flinedump-ratelimit-test.-.md @@ -0,0 +1,52 @@ +```bash +#!/bin/bash + +# Test script for linedump rate limiting +# This script will attempt to upload files rapidly to test the rate limit + +SERVER_URL=${1:-"http://localhost:8000"} +TEST_UPLOADS=${2:-55} # Test more than the default 50/hour limit + +echo "Testing rate limit on $SERVER_URL" +echo "Attempting $TEST_UPLOADS uploads..." +echo "Expected: First ~50 should succeed, then rate limit should kick in" +echo + +success_count=0 +rate_limited_count=0 + +for i in $(seq 1 $TEST_UPLOADS); do + # Create unique test content for each upload + test_content="Test upload #$i - $(date '+%H:%M:%S')" + + # Make the upload request and capture HTTP status + response=$(curl -s -w "%{http_code}" -X POST -d "$test_content" "$SERVER_URL/") + http_code="${response: -3}" # Last 3 characters are the HTTP code + response_body="${response%???}" # Everything except last 3 characters + + if [ "$http_code" = "200" ]; then + success_count=$((success_count + 1)) + echo "✓ Upload $i: SUCCESS (HTTP $http_code) - $response_body" + elif [ "$http_code" = "429" ]; then + rate_limited_count=$((rate_limited_count + 1)) + echo "✗ Upload $i: RATE LIMITED (HTTP $http_code)" + else + echo "! Upload $i: UNEXPECTED (HTTP $http_code) - $response_body" + fi + + # Small delay to avoid overwhelming the server + sleep 0.1 +done + +echo +echo "=== RESULTS ===" +echo "Successful uploads: $success_count" +echo "Rate limited: $rate_limited_count" +echo "Total attempts: $TEST_UPLOADS" + +if [ $rate_limited_count -gt 0 ]; then + echo "✓ Rate limiting is working!" +else + echo "⚠ No rate limiting detected - check server configuration" +fi +``` \ No newline at end of file