Skip to content

Commit 5caab44

Browse files
Merge branch 'trial-testing:main' into main
2 parents 61b25ed + 3e85da2 commit 5caab44

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

.github/workflows/auth.yml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,39 @@ jobs:
8181
# 5. Send POST request with JSON payload to "/"
8282
- name: 🚀 Send POST request with JSON payload to root
8383
run: |
84-
echo "🚀 POST $API_BASE/"
85-
echo "📄 Payload contents:"
84+
85+
echo "🚀 POST $API_BASE/"
86+
echo "📄 Payload contents:"
87+
cat "$JSON_PAYLOAD_PATH" || { echo "❌ files_payload.json not found"; exit 1; }
8688
87-
echo "Sending JSON payload to API"
88-
89-
response=$(curl -s -X POST "$API_URL" \
89+
# Send POST and capture both body and status code
90+
response=$(curl -s -w "\n%{http_code}" -X POST "$API_BASE/" \
9091
-H "Authorization: Bearer $TOKEN" \
9192
-H "Content-Type: application/json" \
9293
--data-binary "@$JSON_PAYLOAD_PATH")
9394
94-
status=$(jq -r '.status' <<< "$response")
95-
message=$(jq -r '.message' <<< "$response")
95+
# Split response into body and status code
96+
body=$(echo "$response" | head -n -1)
97+
status_code=$(echo "$response" | tail -n1)
98+
99+
echo "🌐 HTTP status: $status_code"
100+
echo "🌐 Response body:"
101+
echo "$body" | jq . || echo "⚠️ Response is not valid JSON"
96102
97-
if [ "$status" != "passed" ]; then
98-
echo "❌ Test Fail : $message"
103+
# Check HTTP status
104+
if [ "$status_code" -ne 200 ]; then
105+
echo "❌ POST failed (HTTP $status_code)"
99106
exit 1
100-
fi
107+
fi
108+
109+
# Parse JSON safely
110+
result_status=$(echo "$body" | jq -r '.status // empty')
111+
result_message=$(echo "$body" | jq -r '.message // "No message provided"')
112+
113+
if [ "$result_status" != "passed" ]; then
114+
echo "❌ Validation failed: $result_message"
115+
exit 1
116+
fi
117+
118+
echo "✅ Validation passed: $result_message"
101119
102-
echo "✅ $message"

0 commit comments

Comments
 (0)