gates / gates (push) Successful in 25s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
26 lines
1.8 KiB
Python
26 lines
1.8 KiB
Python
# Part B4/B5 — immich's phone app (no browser cookies; Bearer token) and latency. Run with arg "gated" or "open".
|
|
import json, statistics, sys, time
|
|
sys.path.insert(0, '.')
|
|
from browser import Browser
|
|
D = "enkisfelhom.hu"; phase = sys.argv[1]
|
|
creds = json.load(open('creds.json'))
|
|
app = Browser("immich-mobile") # the phone app: no cookie jar from any browser
|
|
st, b, h = app.req(f"https://g-immich.{D}/api/auth/login", "POST", accept="application/json",
|
|
body={"email": creds["immich"][0], "password": creds["immich"][1]})
|
|
tok = json.loads(b).get("accessToken") if st in (200, 201) else None
|
|
print(f"[{phase}] immich phone app: POST /api/auth/login -> {st} token={'yes' if tok else 'no'} body={b[:60] if not tok else '<token>'}")
|
|
if tok:
|
|
for p in ("/api/users/me", "/api/server/ping", "/api/server/version"):
|
|
st, b, h = app.req(f"https://g-immich.{D}{p}", accept="application/json", headers={"Authorization": "Bearer " + tok})
|
|
print(f"[{phase}] GET {p} (Bearer) -> {st} {b[:50].replace(creds['immich'][0],'<email>')!r}")
|
|
n8 = Browser("n8n-api")
|
|
st, b, h = n8.req(f"https://g-n8n.{D}/rest/login", "POST", accept="application/json",
|
|
body={"emailOrLdapLoginId": creds["n8n"][0], "password": creds["n8n"][1]})
|
|
print(f"[{phase}] n8n login without a browser gate cookie: POST /rest/login -> {st}")
|
|
# latency: the household browser (gate cookie when gated), 40 x GET /api/server/ping
|
|
hh = Browser("household"); hh.jar = json.load(open('jars.json'))["hh"]
|
|
ts = []
|
|
for _ in range(40):
|
|
t0 = time.perf_counter(); st, b, h = hh.req(f"https://g-immich.{D}/api/server/ping", accept="application/json"); ts.append((time.perf_counter() - t0) * 1000)
|
|
print(f"[{phase}] latency household GET /api/server/ping x40: last={st} median={statistics.median(ts):.1f} ms p90={sorted(ts)[35]:.1f} ms (new TLS connection each)")
|