62 lines
2.1 KiB
Bash
Executable File
62 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Test API endpoints with the provided token
|
|
TOKEN="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoib3BlbmNvZGUiLCJuYW1lIjoiT3BlbkNvZGUiLCJBUElfVElNRSI6MTc2MTczNDQ4Nn0.vjukCjNwBCElzP7iT_eWEHhxzL5KPDZ7e05DR1OZEbE"
|
|
BASE_URL="https://flexinit.nl/portal"
|
|
|
|
echo "Testing API endpoints with token..."
|
|
echo "Base URL: $BASE_URL"
|
|
echo "Token: ${TOKEN:0:50}..."
|
|
echo ""
|
|
|
|
# Test 1: Basic customers endpoint
|
|
echo "Test 1: GET /api/customers"
|
|
response=$(curl -s -w "\nHTTP_STATUS:%{http_code}" -H "Authtoken: $TOKEN" "$BASE_URL/api/customers")
|
|
http_status=$(echo "$response" | grep "HTTP_STATUS:" | cut -d: -f2)
|
|
body=$(echo "$response" | sed '/HTTP_STATUS:/d')
|
|
|
|
if [ "$http_status" = "200" ]; then
|
|
echo "✅ SUCCESS: HTTP $http_status"
|
|
echo "Response preview: ${body:0:100}..."
|
|
else
|
|
echo "❌ FAILED: HTTP $http_status"
|
|
echo "Response: $body"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Test 2: GET /api/login/view"
|
|
response=$(curl -s -w "\nHTTP_STATUS:%{http_code}" -H "Authtoken: $TOKEN" "$BASE_URL/api/login/view")
|
|
http_status=$(echo "$response" | grep "HTTP_STATUS:" | cut -d: -f2)
|
|
body=$(echo "$response" | sed '/HTTP_STATUS:/d')
|
|
|
|
if [ "$http_status" = "200" ]; then
|
|
echo "✅ SUCCESS: HTTP $http_status"
|
|
echo "Response preview: ${body:0:100}..."
|
|
else
|
|
echo "❌ FAILED: HTTP $http_status"
|
|
echo "Response: $body"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Test 3: GET /api/staff"
|
|
response=$(curl -s -w "\nHTTP_STATUS:%{http_code}" -H "Authtoken: $TOKEN" "$BASE_URL/api/staff")
|
|
http_status=$(echo "$response" | grep "HTTP_STATUS:" | cut -d: -f2)
|
|
body=$(echo "$response" | sed '/HTTP_STATUS:/d')
|
|
|
|
if [ "$http_status" = "200" ]; then
|
|
echo "✅ SUCCESS: HTTP $http_status"
|
|
echo "Response preview: ${body:0:100}..."
|
|
else
|
|
echo "❌ FAILED: HTTP $http_status"
|
|
echo "Response: $body"
|
|
fi
|
|
|
|
echo ""
|
|
echo "=== API Test Complete ==="
|
|
echo "If you see SUCCESS messages above, the API is working with your token!"
|
|
echo ""
|
|
echo "You can also test in your browser:"
|
|
echo "$BASE_URL/api/playground"
|
|
echo ""
|
|
echo "Or use this curl command for more testing:"
|
|
echo "curl -H \"Authtoken: $TOKEN\" $BASE_URL/api/customers" |