69 lines
2.1 KiB
Bash
Executable File
69 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Simple test script to check content-type validation
|
|
BASE_URL="${BASE_URL:-http://localhost:8080}"
|
|
API_BASE="${BASE_URL}/api"
|
|
USER_EMAIL="${USER_EMAIL:-test@example.com}"
|
|
USER_ID="${USER_ID:-test-user-123}"
|
|
|
|
echo "Testing content-type validation..."
|
|
|
|
# Test 1: POST without Content-Type header (should return 400)
|
|
echo "Test 1: POST without Content-Type header"
|
|
response=$(curl -s -w "\n%{http_code}" -X POST "$API_BASE/applications" \
|
|
-H "X-User-Email: $USER_EMAIL" \
|
|
-H "X-User-ID: $USER_ID" \
|
|
-d '{
|
|
"app_id": "test-content-type-validation",
|
|
"app_link": "https://example.com/test-app",
|
|
"type": ["static"],
|
|
"callback_url": "https://example.com/callback"
|
|
}' 2>/dev/null || echo -e "\n000")
|
|
|
|
status_code=$(echo "$response" | tail -n1)
|
|
body=$(echo "$response" | head -n -1)
|
|
|
|
echo "Status Code: $status_code"
|
|
echo "Response Body: $body"
|
|
|
|
if [[ "$status_code" == "400" ]]; then
|
|
echo "✅ PASS: Content-type validation working correctly"
|
|
else
|
|
echo "❌ FAIL: Expected 400, got $status_code"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# Test 2: POST with correct Content-Type header (should work)
|
|
echo "Test 2: POST with correct Content-Type header"
|
|
response2=$(curl -s -w "\n%{http_code}" -X POST "$API_BASE/applications" \
|
|
-H "Content-Type: application/json" \
|
|
-H "X-User-Email: $USER_EMAIL" \
|
|
-H "X-User-ID: $USER_ID" \
|
|
-d '{
|
|
"app_id": "test-content-type-validation-2",
|
|
"app_link": "https://example.com/test-app",
|
|
"type": ["static"],
|
|
"callback_url": "https://example.com/callback",
|
|
"token_renewal_duration": 604800000000000,
|
|
"max_token_duration": 2592000000000000,
|
|
"owner": {
|
|
"type": "individual",
|
|
"name": "Test User",
|
|
"owner": "test@example.com"
|
|
}
|
|
}' 2>/dev/null || echo -e "\n000")
|
|
|
|
status_code2=$(echo "$response2" | tail -n1)
|
|
body2=$(echo "$response2" | head -n -1)
|
|
|
|
echo "Status Code: $status_code2"
|
|
echo "Response Body: $body2" | head -c 200
|
|
echo ""
|
|
|
|
if [[ "$status_code2" == "201" ]]; then
|
|
echo "✅ PASS: Request with correct Content-Type works"
|
|
else
|
|
echo "❌ FAIL: Expected 201, got $status_code2"
|
|
fi
|