-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api-gateway.sh
More file actions
executable file
·58 lines (48 loc) · 1.57 KB
/
test-api-gateway.sh
File metadata and controls
executable file
·58 lines (48 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# Test script for the API Gateway /builds endpoint
# This script tests the API Gateway configuration and request validation
echo "🧪 Testing API Gateway /builds endpoint..."
# Get the API Gateway URL from Terraform output
API_URL=$(cd terraform/infra && terraform output -raw api_gateway_url 2>/dev/null)
if [ -z "$API_URL" ]; then
echo "❌ Could not get API Gateway URL. Make sure Terraform is applied."
exit 1
fi
echo "📍 API Gateway URL: $API_URL"
# Test 1: Valid request with commit
echo ""
echo "✅ Test 1: Valid request with commit"
curl -X POST "${API_URL}/builds" \
-H "Content-Type: application/json" \
-d '{"commit": "abc123"}' \
-w "\nHTTP Status: %{http_code}\n" \
-s
# Test 2: Missing commit field
echo ""
echo "❌ Test 2: Missing commit field (should fail validation)"
curl -X POST "${API_URL}/builds" \
-H "Content-Type: application/json" \
-d '{}' \
-w "\nHTTP Status: %{http_code}\n" \
-s
# Test 3: Wrong content type
echo ""
echo "❌ Test 3: Wrong content type (should fail validation)"
curl -X POST "${API_URL}/builds" \
-H "Content-Type: text/plain" \
-d '{"commit": "abc123"}' \
-w "\nHTTP Status: %{http_code}\n" \
-s
# Test 4: Empty body
echo ""
echo "❌ Test 4: Empty body (should fail validation)"
curl -X POST "${API_URL}/builds" \
-H "Content-Type: application/json" \
-w "\nHTTP Status: %{http_code}\n" \
-s
echo ""
echo "🎯 Testing complete!"
echo ""
echo "Expected results:"
echo "- Test 1: Should return 200 OK (if lambda is working)"
echo "- Test 2-4: Should return 400 Bad Request (API Gateway validation)"