Files
phpsite/test-e2e.sh
alex d629689473 Redesign as VM webshop with NetBox virtualization integration
- Split single-page into 3 pages:
  - index.php: product catalog with VM size cards
  - create.php: order form (name, domain, description)
  - requests.php: request history with pagination
- Rewrite NetBox integration to create Virtual Machines
  (/virtualization/virtual-machines/) instead of DCIM devices
- Add netbox_integration/netbox_api.php: NetBoxClient with
  createVirtualMachine(), findCluster(), findTag(), getList()
- Generate new sleek product-card images (420x280) with
  aligned spec boxes (vcpus/ram/disk)
- Add webshop CSS: product cards, nav links, hero section,
  order layout, responsive grid
- Update redirects: send.php -> requests.php, cancel.php -> requests.php
- Update E2E test for new page structure
- Add .gitignore, deploy-local.sh, setup_database.sql to repo
2026-05-09 23:49:02 +02:00

57 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
APP_URL="${PHPSITE_URL:-http://127.0.0.1}"
ADMIN_USER="${PHPSITE_ADMIN_USER:-admin}"
ADMIN_PASS="${PHPSITE_ADMIN_PASS:-admin123}"
COOKIE_JAR="$(mktemp)"
LOGIN_HTML="$(mktemp)"
APP_HTML="$(mktemp)"
HEALTH_JSON="$(mktemp)"
trap 'rm -f "$COOKIE_JAR" "$LOGIN_HTML" "$APP_HTML" "$HEALTH_JSON"' EXIT
# Syntax check all PHP files
for f in config.php sizes.php health.php index.php login.php logout.php send.php create.php requests.php cancel.php; do
php -l "$f" >/dev/null
done
# Health
curl -fsS "${APP_URL}/health.php" -o "$HEALTH_JSON"
grep -q '"status": "ok"' "$HEALTH_JSON"
grep -q '"database": "connected"' "$HEALTH_JSON"
# Login page
curl -fsS "${APP_URL}/login.php" -o "$LOGIN_HTML"
grep -q 'Sign in' "$LOGIN_HTML"
# Sign in
curl -fsS -c "$COOKIE_JAR" -b "$COOKIE_JAR" \
-d "username=${ADMIN_USER}" \
-d "password=${ADMIN_PASS}" \
-o "$APP_HTML" \
-L "${APP_URL}/login.php"
grep -q 'VM Shop' "$APP_HTML"
# CSRF token (from shop page)
CSRF_TOKEN="$(grep -oP 'name="csrf_token" value=\K[^"]+' "$APP_HTML" | head -n1)"
if [[ -z "$CSRF_TOKEN" ]]; then
echo "Missing CSRF token after login" >&2
exit 1
fi
# Submit a VM request
VM_NAME="e2e-$(date +%s%N)"
curl -fsS -c "$COOKIE_JAR" -b "$COOKIE_JAR" \
-d "csrf_token=${CSRF_TOKEN}" \
-d "VM_Name=${VM_NAME}" \
-d "domain=domain1" \
-d "size=small" \
-o "$APP_HTML" \
-L "${APP_URL}/send.php"
# Verify request shows up on My Requests page (sent.php redirects there)
grep -q 'VM request cancelled\|created\|My VM Requests' "$APP_HTML"
grep -q "$VM_NAME" "$APP_HTML"
echo "E2E passed for ${APP_URL} with VM ${VM_NAME}"