48 lines
1.3 KiB
Bash
48 lines
1.3 KiB
Bash
|
|
#!/bin/bash
|
|||
|
|
|
|||
|
|
# Скрипт для тестирования API backend
|
|||
|
|
|
|||
|
|
echo "🔍 Testing Mnemo Cards Backend API"
|
|||
|
|
echo "=================================="
|
|||
|
|
echo ""
|
|||
|
|
|
|||
|
|
BASE_URL="http://localhost:8000"
|
|||
|
|
|
|||
|
|
echo "1️⃣ Testing: GET /packs/previews"
|
|||
|
|
echo "--------------------------------"
|
|||
|
|
curl -s -w "\nHTTP Status: %{http_code}\n" \
|
|||
|
|
-H "Content-Type: application/json" \
|
|||
|
|
-H "app_version: 1.1.0" \
|
|||
|
|
"$BASE_URL/packs/previews" | head -20
|
|||
|
|
echo ""
|
|||
|
|
echo ""
|
|||
|
|
|
|||
|
|
echo "2️⃣ Testing: GET /games"
|
|||
|
|
echo "--------------------------------"
|
|||
|
|
curl -s -w "\nHTTP Status: %{http_code}\n" \
|
|||
|
|
-H "Content-Type: application/json" \
|
|||
|
|
-H "app_version: 1.1.0" \
|
|||
|
|
"$BASE_URL/games" | head -20
|
|||
|
|
echo ""
|
|||
|
|
echo ""
|
|||
|
|
|
|||
|
|
echo "3️⃣ Testing: OPTIONS /packs/previews (CORS preflight)"
|
|||
|
|
echo "--------------------------------"
|
|||
|
|
curl -s -w "\nHTTP Status: %{http_code}\n" \
|
|||
|
|
-X OPTIONS \
|
|||
|
|
-H "Origin: http://localhost:8080" \
|
|||
|
|
-H "Access-Control-Request-Method: GET" \
|
|||
|
|
-H "Access-Control-Request-Headers: Content-Type,app_version" \
|
|||
|
|
-v \
|
|||
|
|
"$BASE_URL/packs/previews" 2>&1 | grep -E "(< HTTP|< Access-Control)"
|
|||
|
|
echo ""
|
|||
|
|
echo ""
|
|||
|
|
|
|||
|
|
echo "✅ Test complete!"
|
|||
|
|
echo ""
|
|||
|
|
echo "📝 Expected results:"
|
|||
|
|
echo " - /packs/previews should return 200 with JSON array"
|
|||
|
|
echo " - /games should return 200 with JSON array"
|
|||
|
|
echo " - OPTIONS should return CORS headers"
|
|||
|
|
|