#!/bin/bash # furt-lua/scripts/test_modular.sh # Test der modularen Furt-Architektur BASE_URL="http://127.0.0.1:8080" HUGO_API_KEY="YOUR_API_KEY_HERE" echo "🧩 Testing Modular Furt Architecture" echo "====================================" # Test 1: Module dependencies check echo -e "\n1ļøāƒ£ Testing module imports (should not error on startup):" echo "Starting server in background..." cd "$(dirname "$0")/.." lua src/main.lua & SERVER_PID=$! sleep 2 if kill -0 $SERVER_PID 2>/dev/null; then echo "āœ… Server started successfully - all modules loaded" else echo "āŒ Server failed to start - module import error" exit 1 fi # Test 2: Public endpoints (no auth) echo -e "\n2ļøāƒ£ Testing public endpoints:" curl -s -w "Status: %{http_code}\n" "$BASE_URL/health" | jq '.features' # Test 3: Protected endpoints without auth (should fail) echo -e "\n3ļøāƒ£ Testing auth protection:" curl -s -w "Status: %{http_code}\n" \ -X POST \ -H "Content-Type: application/json" \ -d '{"name":"Test","email":"test@example.com","message":"Test"}' \ "$BASE_URL/v1/mail/send" | jq '.error' # Test 4: Protected endpoints with auth (should work) echo -e "\n4ļøāƒ£ Testing authenticated request:" curl -s -w "Status: %{http_code}\n" \ -H "X-API-Key: $HUGO_API_KEY" \ "$BASE_URL/v1/auth/status" | jq '.' # Test 5: Rate limiting headers echo -e "\n5ļøāƒ£ Testing rate limit headers:" curl -s -i -H "X-API-Key: $HUGO_API_KEY" "$BASE_URL/v1/auth/status" | grep -E "X-RateLimit|HTTP" # Cleanup echo -e "\n🧹 Cleanup:" kill $SERVER_PID 2>/dev/null wait $SERVER_PID 2>/dev/null echo "Server stopped" echo -e "\nāœ… Modular Architecture Test Complete!" echo "Expected behavior:" echo "- Test 1: āœ… Server starts without module errors" echo "- Test 2: āœ… Health endpoint works, shows features" echo "- Test 3: āŒ 401 Unauthorized (missing API key)" echo "- Test 4: āœ… 200 OK with auth details" echo "- Test 5: āœ… Rate limit headers present"