feat: harden runtime import and frontend verification workflows
This commit is contained in:
109
scripts/acceptance/verify_accounts_admin_ui.sh
Normal file
109
scripts/acceptance/verify_accounts_admin_ui.sh
Normal file
@@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
# shellcheck disable=SC1091
|
||||
source "$ROOT_DIR/scripts/acceptance/route_acceptance_lib.sh"
|
||||
|
||||
ACCOUNTS_ACCEPTANCE_ROOT="${ACCOUNTS_ACCEPTANCE_ROOT:-$ROOT_DIR/artifacts/frontend-acceptance-matrix}"
|
||||
TS="${TS:-$(timestamp_token)}"
|
||||
ARTIFACT_DIR="${ARTIFACT_DIR:-$ACCOUNTS_ACCEPTANCE_ROOT/${TS}_accounts_admin_ui}"
|
||||
|
||||
ACCOUNTS_PAGE_URL="${ACCOUNTS_PAGE_URL:-https://sub.tksea.top/portal/admin/accounts.html}"
|
||||
ACCOUNT_ID="${ACCOUNT_ID:-}"
|
||||
HOST_ID_FILTER="${HOST_ID_FILTER:-}"
|
||||
PROVIDER_ID_FILTER="${PROVIDER_ID_FILTER:-}"
|
||||
BINDING_STATE_FILTER="${BINDING_STATE_FILTER:-}"
|
||||
LIMIT="${LIMIT:-50}"
|
||||
ALLOW_EMPTY_ACCOUNTS="${ALLOW_EMPTY_ACCOUNTS:-0}"
|
||||
|
||||
require_var CRM_BASE
|
||||
crm_auth_init
|
||||
ensure_artifact_dir
|
||||
curl_status_to_file "$ACCOUNTS_PAGE_URL" "$ARTIFACT_DIR/00-accounts-admin.html"
|
||||
|
||||
query="$(
|
||||
python3 - "$HOST_ID_FILTER" "$PROVIDER_ID_FILTER" "$BINDING_STATE_FILTER" "$LIMIT" <<'PY'
|
||||
import sys
|
||||
from urllib.parse import urlencode
|
||||
|
||||
host_id, provider_id, binding_state, limit = sys.argv[1:5]
|
||||
params = {}
|
||||
if host_id:
|
||||
params["host_id"] = host_id
|
||||
if provider_id:
|
||||
params["provider_id"] = provider_id
|
||||
if binding_state:
|
||||
params["binding_state"] = binding_state
|
||||
if limit:
|
||||
params["limit"] = limit
|
||||
print(urlencode(params))
|
||||
PY
|
||||
)"
|
||||
|
||||
list_path="/api/provider-accounts"
|
||||
if [[ -n "$query" ]]; then
|
||||
list_path="$list_path?$query"
|
||||
fi
|
||||
|
||||
save_json 01-provider-accounts "$(crm_curl_json GET "$list_path")"
|
||||
|
||||
if [[ -z "$ACCOUNT_ID" ]]; then
|
||||
ACCOUNT_ID="$(
|
||||
python3 - "$ARTIFACT_DIR/01-provider-accounts.json" "$ALLOW_EMPTY_ACCOUNTS" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
|
||||
payload = json.load(open(sys.argv[1], "r", encoding="utf-8"))
|
||||
allow_empty = sys.argv[2] == "1"
|
||||
items = payload.get("provider_accounts") or []
|
||||
if not items:
|
||||
if allow_empty:
|
||||
raise SystemExit(3)
|
||||
raise SystemExit(2)
|
||||
first = items[0]
|
||||
print(first.get("id") or "")
|
||||
PY
|
||||
)" || ACCOUNT_ID=""
|
||||
fi
|
||||
|
||||
if [[ -n "$ACCOUNT_ID" ]]; then
|
||||
save_json 02-binding-candidates "$(crm_curl_json GET "/api/provider-accounts/$ACCOUNT_ID/binding-candidates")"
|
||||
fi
|
||||
|
||||
python3 - "$ARTIFACT_DIR" "$ACCOUNT_ID" "$ALLOW_EMPTY_ACCOUNTS" >"$ARTIFACT_DIR/99-summary.json" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
art_dir = Path(sys.argv[1])
|
||||
account_id = sys.argv[2]
|
||||
allow_empty = sys.argv[3] == "1"
|
||||
|
||||
page = (art_dir / "00-accounts-admin.html").read_text(encoding="utf-8")
|
||||
accounts = json.loads((art_dir / "01-provider-accounts.json").read_text(encoding="utf-8")).get("provider_accounts") or []
|
||||
|
||||
assert "Provider Accounts Admin" in page
|
||||
if not accounts and not allow_empty:
|
||||
raise AssertionError("provider_accounts list is empty")
|
||||
|
||||
summary = {
|
||||
"page_title_seen": "Provider Accounts Admin" in page,
|
||||
"account_count": len(accounts),
|
||||
"selected_account_id": account_id or "",
|
||||
}
|
||||
|
||||
if accounts:
|
||||
first = accounts[0]
|
||||
summary["first_account_provider_id"] = first.get("provider_id")
|
||||
summary["first_account_status"] = first.get("status") or first.get("account_status")
|
||||
summary["first_account_binding_state"] = first.get("binding_state")
|
||||
|
||||
if account_id:
|
||||
candidates = json.loads((art_dir / "02-binding-candidates.json").read_text(encoding="utf-8")).get("binding_candidates") or []
|
||||
summary["binding_candidate_count"] = len(candidates)
|
||||
|
||||
print(json.dumps(summary, ensure_ascii=False, indent=2))
|
||||
PY
|
||||
|
||||
cat "$ARTIFACT_DIR/99-summary.json"
|
||||
Reference in New Issue
Block a user