61 lines
1.7 KiB
Bash
61 lines
1.7 KiB
Bash
#!/bin/bash
|
|
|
|
# Script de test de l'API Secure Proxy
|
|
|
|
BASE_URL="http://localhost:3000"
|
|
ADMIN_TOKEN=""
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
RED='\033[0;31m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${YELLOW}🔐 Secure Proxy API Test Suite${NC}\n"
|
|
|
|
# Test 1: Health check
|
|
echo -e "${YELLOW}Test 1: Home page${NC}"
|
|
curl -s -X GET "$BASE_URL/" \
|
|
-H "Accept: text/html" \
|
|
-w "\nStatus: %{http_code}\n\n"
|
|
|
|
# Test 2: Login page
|
|
echo -e "${YELLOW}Test 2: Login page${NC}"
|
|
curl -s -X GET "$BASE_URL/auth/login-page" \
|
|
-w "Status: %{http_code}\n\n"
|
|
|
|
# Test 3: Get user profile (should fail without auth)
|
|
echo -e "${YELLOW}Test 3: Get profile (no auth)${NC}"
|
|
curl -s -X GET "$BASE_URL/auth/profile" \
|
|
-H "Content-Type: application/json" \
|
|
-w "Status: %{http_code}\n\n"
|
|
|
|
# Test 4: List services (should fail without admin)
|
|
echo -e "${YELLOW}Test 4: List services (no auth)${NC}"
|
|
curl -s -X GET "$BASE_URL/api/services" \
|
|
-H "Content-Type: application/json" \
|
|
-w "Status: %{http_code}\n\n"
|
|
|
|
# Test 5: Create service (should fail without admin)
|
|
echo -e "${YELLOW}Test 5: Create service (no auth)${NC}"
|
|
curl -s -X POST "$BASE_URL/api/services" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"name": "Test Service",
|
|
"path": "/test",
|
|
"targetUrl": "http://localhost:8080",
|
|
"requireAuth": true
|
|
}' \
|
|
-w "Status: %{http_code}\n\n"
|
|
|
|
# Test 6: Get dashboard stats (should fail without admin)
|
|
echo -e "${YELLOW}Test 6: Dashboard stats (no auth)${NC}"
|
|
curl -s -X GET "$BASE_URL/dashboard/stats" \
|
|
-H "Content-Type: application/json" \
|
|
-w "Status: %{http_code}\n\n"
|
|
|
|
echo -e "${GREEN}✓ Tests completed${NC}"
|
|
echo ""
|
|
echo -e "${YELLOW}Note: Most API tests will fail without authentication.${NC}"
|
|
echo -e "${YELLOW}Log in at: $BASE_URL/auth/login-page${NC}"
|