35 lines
907 B
Bash
35 lines
907 B
Bash
#!/bin/bash
|
|
# backend/test-vhosts.sh — Test Nginx VHost management endpoints
|
|
|
|
# Configuration
|
|
API_URL="http://127.0.0.1:3001/api/v1/vhosts"
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m'
|
|
|
|
echo "Starting Nginx VHost API tests..."
|
|
echo "-----------------------------------"
|
|
|
|
test_get() {
|
|
echo -n "Test: GET VHost list... "
|
|
local response=$(curl -s -X GET "$API_URL/")
|
|
local status=$(curl -s -o /dev/null -w "%{http_code}" -X GET "$API_URL/")
|
|
|
|
if [ "$status" -eq 200 ]; then
|
|
echo -e "${GREEN}PASS${NC}"
|
|
echo " Data: $response"
|
|
else
|
|
echo -e "${RED}FAIL${NC} (Status: $status)"
|
|
echo " Error: $response"
|
|
fi
|
|
}
|
|
|
|
# Note: Toggle tests are dangerous in production, so we only test GET here.
|
|
# For full verification, a mock NGINX_DIR should be used.
|
|
|
|
test_get
|
|
|
|
echo "-----------------------------------"
|
|
echo "Tests completed."
|