From 5e18db48d3b4ed207fb54901b99c1603fb4b389d Mon Sep 17 00:00:00 2001 From: kitos Date: Wed, 20 May 2026 14:27:41 +0200 Subject: [PATCH] fix(qa11): fix get_token to use form data + fix check() bug --- scripts/qa_phase11.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/qa_phase11.py b/scripts/qa_phase11.py index cb45ab6..3b27e7a 100644 --- a/scripts/qa_phase11.py +++ b/scripts/qa_phase11.py @@ -23,21 +23,19 @@ def check(label: str, condition: bool, detail: str = ""): print(f" {PASS} {label}") else: failed += 1 - print(f" {FAIL} {label}" + (f" — {detail}" for _ in [1] if detail).__next__() - if detail else f" {FAIL} {label}") + msg = f" {FAIL} {label}" + if detail: + msg += f" — {detail}" + print(msg) def get_token(username="admin", password="admin123"): + # Auth router uses OAuth2PasswordRequestForm (form data) r = requests.post(f"{BASE}/auth/login", - json={"username": username, "password": password}) - if r.status_code == 200: - return r.json().get("access_token") or r.json().get("token") - # try form - r = requests.post(f"{BASE}/auth/token", data={"username": username, "password": password}) if r.status_code == 200: - return r.json().get("access_token") - raise RuntimeError(f"Login failed: {r.status_code} {r.text}") + return r.json().get("access_token") or r.json().get("token") + raise RuntimeError(f"Login failed: {r.status_code} {r.text[:200]}") def auth(token):