Created comprehensive E2E verification framework: - E2E_VERIFICATION.md: Complete manual testing guide with 9 scenarios - scripts/verify-e2e-rate-limiting.sh: Automated API testing script - scripts/test-concurrent-rate-limit.sh: Concurrent request testing - scripts/reset-rate-limit.sh: Database reset utility for testing - SUBTASK_5-1_VERIFICATION_REPORT.md: Status and blocker documentation Fixed middleware configuration: - Updated src/middleware.ts matcher to exclude /api/ routes - Changed from complex negative lookahead to explicit locale matching - Pattern now: ['/', '/(de|en|sr)/:path*'] Known issue: - Middleware fix requires dev server restart to take effect - API routes currently return 404 until server is restarted - All implementation code is complete and ready for testing Test coverage: - Basic rate limiting flow (5 requests succeed, 6th fails) - Response header verification (X-RateLimit-Remaining, Retry-After) - Persistence testing (across page refreshes, browser sessions) - Multi-locale support (en, de, sr) - Error handling and validation - Concurrent request handling - Database record verification Next steps: 1. Restart dev server: npm run dev 2. Run automated tests: bash ./scripts/verify-e2e-rate-limiting.sh 3. Perform manual browser testing per E2E_VERIFICATION.md 4. Verify database records in Supabase 5. Mark subtask as completed Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
74 lines
2.2 KiB
Bash
74 lines
2.2 KiB
Bash
#!/bin/bash
|
|
|
|
# Reset Rate Limit - Utility Script
|
|
# Helps reset rate limits during testing
|
|
|
|
echo "================================================"
|
|
echo "Rate Limit Reset Utility"
|
|
echo "================================================"
|
|
echo ""
|
|
|
|
echo "This script helps you reset rate limits for testing."
|
|
echo ""
|
|
echo "Options:"
|
|
echo "1. Reset for 'unknown-ip' (default dev identifier)"
|
|
echo "2. Reset for specific IP address"
|
|
echo "3. Reset ALL rate limits (use with caution)"
|
|
echo "4. Show current rate limit records"
|
|
echo ""
|
|
|
|
read -p "Select option (1-4): " option
|
|
|
|
case $option in
|
|
1)
|
|
echo ""
|
|
echo "SQL to run in Supabase SQL Editor:"
|
|
echo "https://app.supabase.com/project/mxadgucxhmstlzsbgmoz/sql"
|
|
echo ""
|
|
echo "DELETE FROM rate_limits WHERE identifier = 'unknown-ip';"
|
|
echo ""
|
|
echo "After running this query, rate limits will reset for the dev environment."
|
|
;;
|
|
2)
|
|
echo ""
|
|
read -p "Enter IP address to reset: " ip_address
|
|
echo ""
|
|
echo "SQL to run in Supabase SQL Editor:"
|
|
echo "https://app.supabase.com/project/mxadgucxhmstlzsbgmoz/sql"
|
|
echo ""
|
|
echo "DELETE FROM rate_limits WHERE identifier = '$ip_address';"
|
|
echo ""
|
|
;;
|
|
3)
|
|
echo ""
|
|
echo "⚠️ WARNING: This will reset ALL rate limits!"
|
|
read -p "Are you sure? (yes/no): " confirm
|
|
if [ "$confirm" = "yes" ]; then
|
|
echo ""
|
|
echo "SQL to run in Supabase SQL Editor:"
|
|
echo "https://app.supabase.com/project/mxadgucxhmstlzsbgmoz/sql"
|
|
echo ""
|
|
echo "TRUNCATE TABLE rate_limits;"
|
|
echo ""
|
|
else
|
|
echo "Cancelled."
|
|
fi
|
|
;;
|
|
4)
|
|
echo ""
|
|
echo "SQL to run in Supabase SQL Editor:"
|
|
echo "https://app.supabase.com/project/mxadgucxhmstlzsbgmoz/sql"
|
|
echo ""
|
|
echo "SELECT * FROM rate_limits ORDER BY window_start DESC;"
|
|
echo ""
|
|
echo "This will show all current rate limit records."
|
|
;;
|
|
*)
|
|
echo "Invalid option."
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
echo ""
|
|
echo "Note: Rate limits can also naturally expire after 1 hour."
|