62 lines
1.9 KiB
Bash
62 lines
1.9 KiB
Bash
|
|
#!/bin/bash
|
|||
|
|
# furt-lua/scripts/test_modular.sh
|
|||
|
|
# Test der modularen Furt-Architektur
|
|||
|
|
|
|||
|
|
BASE_URL="http://127.0.0.1:8080"
|
|||
|
|
HUGO_API_KEY="hugo-dev-key-change-in-production"
|
|||
|
|
|
|||
|
|
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"
|
|||
|
|
|