Fix inventory and supplier API field names
This commit is contained in:
58
test_endpoints.sh
Executable file
58
test_endpoints.sh
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
ADMIN_TOKEN="eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImlhdCI6MTc3MjczMzAxOSwiZXhwIjoxNzcyODE5NDE5fQ.__RqJbY2_HMjMlF6MoU8LagTu8pxjmizYYg4BQ0ahxRn9PV5iSQO3WRnCnujyE04AOY5yjTDEakOZOTEpiDFSw"
|
||||
STAFF_TOKEN="eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJzdGFmZiIsImlhdCI6MTc3MjczMzAyMCwiZXhwIjoxNzcyODE5NDIwfQ.m7jC_QMWmJsj-kc4Qb-9cQwUEnJEAYJ7mbpKJOMISSup1rONwloN3Heio6Iw5ysIkjNt6uZbwIX2SZygbxQSVg"
|
||||
BASE_URL="http://localhost:8080/api/v1"
|
||||
|
||||
PASS=0
|
||||
FAIL=0
|
||||
TOTAL=0
|
||||
|
||||
test_endpoint() {
|
||||
local method=$1
|
||||
local path=$2
|
||||
local token=$3
|
||||
local expected_status=$4
|
||||
local data=$5
|
||||
local desc=$6
|
||||
|
||||
TOTAL=$((TOTAL + 1))
|
||||
|
||||
if [ -z "$data" ]; then
|
||||
response=$(curl -s -w "\n%{http_code}" -X $method "$BASE_URL$path" -H "Authorization: Bearer $token" -H "Content-Type: application/json")
|
||||
else
|
||||
response=$(curl -s -w "\n%{http_code}" -X $method "$BASE_URL$path" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -d "$data")
|
||||
fi
|
||||
|
||||
status=$(echo "$response" | tail -n1)
|
||||
body=$(echo "$response" | head -n-1)
|
||||
|
||||
if [ "$status" = "$expected_status" ]; then
|
||||
echo "✓ PASS: $desc ($method $path) - $status"
|
||||
PASS=$((PASS + 1))
|
||||
echo "$body" | jq '.' 2>/dev/null || echo "$body"
|
||||
else
|
||||
echo "✗ FAIL: $desc ($method $path) - Expected $expected_status, got $status"
|
||||
FAIL=$((FAIL + 1))
|
||||
echo "$body"
|
||||
fi
|
||||
echo "---"
|
||||
}
|
||||
|
||||
echo "========================================="
|
||||
echo "PHASE 1: DROPDOWN ENDPOINTS (7 endpoints)"
|
||||
echo "========================================="
|
||||
|
||||
test_endpoint "GET" "/dropdowns/pets" "$STAFF_TOKEN" "200" "" "Get pets dropdown"
|
||||
test_endpoint "GET" "/dropdowns/customers" "$STAFF_TOKEN" "200" "" "Get customers dropdown"
|
||||
test_endpoint "GET" "/dropdowns/services" "$STAFF_TOKEN" "200" "" "Get services dropdown"
|
||||
test_endpoint "GET" "/dropdowns/products" "$STAFF_TOKEN" "200" "" "Get products dropdown"
|
||||
test_endpoint "GET" "/dropdowns/categories" "$STAFF_TOKEN" "200" "" "Get categories dropdown"
|
||||
test_endpoint "GET" "/dropdowns/stores" "$STAFF_TOKEN" "200" "" "Get stores dropdown"
|
||||
test_endpoint "GET" "/dropdowns/suppliers" "$ADMIN_TOKEN" "200" "" "Get suppliers dropdown (admin)"
|
||||
|
||||
echo ""
|
||||
echo "========================================="
|
||||
echo "SUMMARY: Phase 1"
|
||||
echo "========================================="
|
||||
echo "Total: $TOTAL | Pass: $PASS | Fail: $FAIL"
|
||||
Reference in New Issue
Block a user