monitoring: fail bank auto-account if payto/webui invalid (like 405)
Public GET /intro/auto-account.json must return 200 with host:port payto and absolute webui; 405/501/404 etc. are hard failures.
This commit is contained in:
parent
9d45a9ba66
commit
f4129e0988
1 changed files with 61 additions and 0 deletions
|
|
@ -173,6 +173,67 @@ if [ "$code" = "200" ]; then
|
||||||
check_url_soft "bank /webui/" 200 "$BANK_PUBLIC/webui/"
|
check_url_soft "bank /webui/" 200 "$BANK_PUBLIC/webui/"
|
||||||
check_url_soft "bank /intro/" 200 "$BANK_PUBLIC/intro/"
|
check_url_soft "bank /intro/" 200 "$BANK_PUBLIC/intro/"
|
||||||
check_url_soft "bank /" 302,301,200 "$BANK_PUBLIC/"
|
check_url_soft "bank /" 302,301,200 "$BANK_PUBLIC/"
|
||||||
|
# Auto-create personal account (landing “Create my bank account”)
|
||||||
|
# Must be GET 200 with valid payto (host:port) + absolute webui — 405/501 = broken
|
||||||
|
aa_code=$(http_body "$BANK_PUBLIC/intro/auto-account.json" "$tmp/aa.json")
|
||||||
|
case "$aa_code" in
|
||||||
|
200)
|
||||||
|
if python3 - "$tmp/aa.json" <<'PY'
|
||||||
|
import json, re, sys
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
try:
|
||||||
|
d = json.load(open(sys.argv[1]))
|
||||||
|
except Exception as e:
|
||||||
|
print("bad json:", e)
|
||||||
|
sys.exit(1)
|
||||||
|
if not d.get("ok"):
|
||||||
|
print("ok!=true")
|
||||||
|
sys.exit(1)
|
||||||
|
payto = d.get("payto_uri") or ""
|
||||||
|
webui = d.get("webui") or d.get("account_url") or ""
|
||||||
|
# payto://x-taler-bank/host:port/account?...
|
||||||
|
m = re.match(r"^payto://x-taler-bank/([^/?#]+)/([^/?#]+)(\?.*)?$", payto)
|
||||||
|
if not m:
|
||||||
|
print("payto shape invalid:", payto[:120])
|
||||||
|
sys.exit(1)
|
||||||
|
auth, acct = m.group(1), m.group(2)
|
||||||
|
if ":" not in auth:
|
||||||
|
print("payto missing port (need host:port):", auth)
|
||||||
|
sys.exit(1)
|
||||||
|
host, port_s = auth.rsplit(":", 1)
|
||||||
|
if not host or not port_s.isdigit():
|
||||||
|
print("payto host:port invalid:", auth)
|
||||||
|
sys.exit(1)
|
||||||
|
if not acct:
|
||||||
|
print("payto account empty")
|
||||||
|
sys.exit(1)
|
||||||
|
u = urlparse(webui)
|
||||||
|
if u.scheme not in ("http", "https") or not u.netloc or "webui" not in (u.path or ""):
|
||||||
|
print("webui not absolute https …/webui/:", webui[:120])
|
||||||
|
sys.exit(1)
|
||||||
|
print(f"user={d.get('username','')} payto={auth}/{acct} webui={webui}")
|
||||||
|
sys.exit(0)
|
||||||
|
PY
|
||||||
|
then
|
||||||
|
ok "bank /intro/auto-account.json" "$(python3 -c 'import json;d=json.load(open("'"$tmp/aa.json"'"));print(d.get("username",""),"·",(d.get("payto_uri") or "")[:60])' 2>/dev/null || true)"
|
||||||
|
else
|
||||||
|
fail "bank /intro/auto-account.json" "invalid payto/webui — $(python3 - "$tmp/aa.json" <<'PY'
|
||||||
|
import json,sys
|
||||||
|
try:
|
||||||
|
d=json.load(open(sys.argv[1])); print((d.get("payto_uri") or "")[:100], (d.get("webui") or "")[:60])
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
PY
|
||||||
|
)"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
405|501|404|502|503|000)
|
||||||
|
fail "bank /intro/auto-account.json" "HTTP $aa_code (want 200; 405/501 = method/proxy broken)"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
fail "bank /intro/auto-account.json" "HTTP $aa_code want 200"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Bank legal docs (landing nginx via Caddy /terms* /privacy* or /intro/*)
|
# Bank legal docs (landing nginx via Caddy /terms* /privacy* or /intro/*)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue