Remove script duplicado da pasta specs 028
This commit is contained in:
parent
a8e3732bda
commit
cb07e3bf88
1 changed files with 0 additions and 64 deletions
|
|
@ -1,64 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# Spec 028 — Teste de confirmação OpenPanel API multidomínio (Ligbox Re-engenharia)
|
||||
# Uso repetível: bash scripts/test-openpanel-multidomain-api.sh
|
||||
set -euo pipefail
|
||||
|
||||
API_URL="${API_URL:-http://10.10.10.122:8080}"
|
||||
DESK_USER="${DESK_USER:-root}"
|
||||
DESK_PASS="${DESK_PASS:-}"
|
||||
BRIDGE_URL="${BRIDGE_URL:-http://10.10.10.123:18087}"
|
||||
BRIDGE_TOKEN="${BRIDGE_TOKEN:-ligbox-community-bridge-token}"
|
||||
MODE="${MODE:-desk}" # desk | bridge
|
||||
|
||||
log() { echo "[$(date -Iseconds)] $*"; }
|
||||
fail() { log "FAIL: $*"; exit 1; }
|
||||
ok() { log "OK: $*"; }
|
||||
|
||||
if [[ "$MODE" == "desk" ]]; then
|
||||
[[ -n "$DESK_PASS" ]] || fail "defina DESK_PASS (senha Desk do utilizador $DESK_USER)"
|
||||
log "=== Teste via Desk API ($API_URL) ==="
|
||||
TOKEN=$(curl -sf -X POST "$API_URL/api/v1/auth/login" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"username\":\"$DESK_USER\",\"password\":\"$DESK_PASS\"}" \
|
||||
| python3 -c "import sys,json; print(json.load(sys.stdin)['access_token'])") \
|
||||
|| fail "login Desk falhou"
|
||||
ok "login $DESK_USER"
|
||||
RESULT=$(curl -sf --max-time 300 -X POST "$API_URL/api/v1/vm123/openpanel/test-confirm" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json")
|
||||
else
|
||||
log "=== Teste directo bridge ($BRIDGE_URL) ==="
|
||||
SUFFIX=$(date +%s | tail -c 6)
|
||||
USER="apitest${SUFFIX}"
|
||||
D1="apitest${SUFFIX}.ligbox.com.br"
|
||||
D2="apitestb${SUFFIX}.ligbox.com.br"
|
||||
PASS="LbOpenTest805353"
|
||||
HDR=(-H "Authorization: Bearer $BRIDGE_TOKEN" -H "Content-Type: application/json")
|
||||
|
||||
curl -sf "${HDR[@]}" "$BRIDGE_URL/api" | grep -q bridge || fail "bridge health"
|
||||
ok "bridge health"
|
||||
|
||||
curl -sf --max-time 180 -X POST "${HDR[@]}" -d "{\"username\":\"$USER\",\"password\":\"$PASS\",\"email\":\"hosting@$D1\",\"domain\":\"$D1\",\"plan_name\":\"ligbox-site-cms\"}" \
|
||||
"$BRIDGE_URL/api/users" | python3 -c "import sys,json; d=json.load(sys.stdin); exit(0 if d.get('success') else 1)" \
|
||||
|| fail "provision domain1"
|
||||
ok "provision $USER + $D1"
|
||||
|
||||
curl -sf --max-time 180 -X POST "${HDR[@]}" -d "{\"username\":\"$USER\",\"domain\":\"$D2\"}" \
|
||||
"$BRIDGE_URL/api/domains" | python3 -c "import sys,json; d=json.load(sys.stdin); exit(0 if d.get('success') else 1)" \
|
||||
|| fail "add domain2"
|
||||
ok "add domain2 $D2"
|
||||
|
||||
DOMS=$(curl -sf "${HDR[@]}" "$BRIDGE_URL/api/users/$USER" | python3 -c "import sys,json; print(json.load(sys.stdin).get('domains',''))")
|
||||
echo "$DOMS" | grep -q "$D1" && echo "$DOMS" | grep -q "$D2" || fail "verify multidomain: $DOMS"
|
||||
ok "verify multidomain"
|
||||
|
||||
curl -sf -X DELETE "${HDR[@]}" "$BRIDGE_URL/api/users/$USER" | python3 -c "import sys,json; d=json.load(sys.stdin); exit(0 if d.get('success') else 1)" \
|
||||
|| fail "cleanup"
|
||||
ok "cleanup $USER"
|
||||
RESULT='{"ok":true,"suite":"openpanel-multidomain-api-confirm","mode":"bridge"}'
|
||||
fi
|
||||
|
||||
echo "$RESULT" | python3 -m json.tool
|
||||
echo "$RESULT" | python3 -c "import sys,json; d=json.load(sys.stdin); sys.exit(0 if d.get('ok') else 1)" \
|
||||
&& ok "TESTE CONCLUÍDO — OpenPanel multidomínio confirmado" \
|
||||
|| fail "um ou mais passos falharam"
|
||||
Loading…
Reference in a new issue