-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api.sh
More file actions
executable file
·38 lines (32 loc) · 1.32 KB
/
Copy pathtest_api.sh
File metadata and controls
executable file
·38 lines (32 loc) · 1.32 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
#!/bin/bash
echo "=== Probando API directamente ==="
echo "1. GET /api/v1/planes (público):"
curl -s -X GET http://localhost:8080/api/v1/planes -H "Accept: application/json" | head -200
echo -e "\n\n2. POST /api/v1/auth/login (obtener token):"
TOKEN_RESPONSE=$(curl -s -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"email":"admin@example.com","password":"password","device_name":"Test"}')
echo "$TOKEN_RESPONSE" | head -20
# Extraer token si existe
TOKEN=$(echo "$TOKEN_RESPONSE" | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)
if [ ! -z "$TOKEN" ]; then
echo -e "\n\n3. POST /api/v1/planes (crear plane con token):"
curl -s -X POST http://localhost:8080/api/v1/planes \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"name": "Plan de Prueba",
"monthly_price": 1999,
"currency": "USD",
"user_limit": 5,
"features": ["Feature 1", "Feature 2"]
}' | head -20
else
echo -e "\n\nNo se pudo obtener el token."
fi
echo -e "\n\n=== URLs importantes ==="
echo "- Swagger UI: http://localhost:8080/api/documentation"
echo "- API JSON: http://localhost:8080/docs"
echo "- Test GET: http://localhost:8080/api/v1/planes"