Add Playwright e2e tests; fix two real bugs they caught
fix: OIDC_ISSUER_URL used Authentik's LAN IP (192.168.1.208:9443). Authentik's discovery doc echoes back whichever host you query it through, so that LAN IP got baked into authorization_endpoint -- the URL the *browser* gets redirected to. Anyone off the LAN got sent to an address they couldn't reach. Authentik was already publicly exposed at auth.jerodrigged.com (pre-existing NPM proxy host); switched to that, which also has a real cert so OIDC_ALLOW_INSECURE_TLS could go back to false. Reported as "signed in via Authentik, redirected to the local IP, failed." fix: frontend's request() helper always sent Content-Type: application/json, even for logout's bodyless POST. Fastify's default JSON parser rejects an empty body under that content-type (400) -- sign-out silently failed to log the user out. curl-based testing missed this because curl doesn't set that header without -d. Caught immediately by the new Playwright local-login test. e2e/: Playwright suite for local auth and OIDC login. OIDC test uses a dedicated Authentik test user (blueprint-provisioned, never a real personal login) so the whole flow can run unattended and repeatedly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+5
-4
@@ -21,10 +21,11 @@ export interface HostSummary {
|
||||
}
|
||||
|
||||
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const res = await fetch(path, {
|
||||
...init,
|
||||
headers: { "Content-Type": "application/json", ...init?.headers },
|
||||
});
|
||||
// Only set Content-Type when there's actually a body -- Fastify's default
|
||||
// JSON parser rejects an empty body sent with application/json (400),
|
||||
// which broke logout (no body) once real requests, not curl, sent it.
|
||||
const headers = init?.body ? { "Content-Type": "application/json", ...init?.headers } : init?.headers;
|
||||
const res = await fetch(path, { ...init, headers });
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({}));
|
||||
throw new Error(body.error ?? `Request to ${path} failed with ${res.status}`);
|
||||
|
||||
Reference in New Issue
Block a user