mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
New lint test_no_raw_goto.py forbids raw `page.goto(...)` in role playwright specs + persona flows (the gotoOnion wrapper in personas/utils is exempt) so navigation retries transient Tor-transport errors over onion. Migrates every raw call across ~75 roles (343 sites) to `gotoOnion(page, ...)` and teaches gotoOnion to detect relative onion URLs (`isOnionCanonical`). gotoOnion is a behaviour-identical drop-in on clearnet (single attempt, same return). Verified: no-raw-goto lint green, eslint 0 errors, make test green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
// @ts-check
|
|
// Scenario: Unauthenticated guest is redirected to SSO login
|
|
const { test, expect } = require("@playwright/test");
|
|
const { resolveTimeout } = require("./timeouts");
|
|
const { gotoOnion } = require("./personas");
|
|
|
|
test.use({ ignoreHTTPSErrors: true });
|
|
|
|
function decodeDotenvQuotedValue(value) {
|
|
if (typeof value !== "string" || value.length < 2) return value;
|
|
if (!(value.startsWith('"') && value.endsWith('"'))) return value;
|
|
const encoded = value.slice(1, -1);
|
|
try { return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); }
|
|
catch { return encoded.replace(/\$\$/g, "$"); }
|
|
}
|
|
|
|
const oidcIssuerUrl = decodeDotenvQuotedValue(process.env.OIDC_ISSUER_URL);
|
|
const piholeBaseUrl = decodeDotenvQuotedValue(process.env.PIHOLE_BASE_URL);
|
|
|
|
test.beforeEach(() => {
|
|
test.skip(!oidcIssuerUrl, "SSO not enabled — skipping guest redirect test");
|
|
expect(piholeBaseUrl, "PIHOLE_BASE_URL must be set").toBeTruthy();
|
|
});
|
|
|
|
test("guest: is redirected to SSO login", async ({ page }) => {
|
|
const expectedOidcAuthUrl = `${oidcIssuerUrl.replace(/\/$/, "")}/protocol/openid-connect/auth`;
|
|
await gotoOnion(page, `${piholeBaseUrl.replace(/\/$/, "")}/`);
|
|
await expect
|
|
.poll(() => page.url(), { timeout: resolveTimeout(30_000), message: "Expected redirect to Keycloak OIDC auth" })
|
|
.toContain(expectedOidcAuthUrl);
|
|
});
|