Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Keep reused E2E cookie sessions on the protected workspace entry
pulse-triage[bot]d7ec05f07fff
diff --git a/tests/integration/scripts/fixture-auth.test.mjs b/tests/integration/scripts/fixture-auth.test.mjsindex c4abb6ca7b..935c3d85c6 100644--- a/tests/integration/scripts/fixture-auth.test.mjs+++ b/tests/integration/scripts/fixture-auth.test.mjs@@ -28,6 +28,17 @@ const helpers = stripTypeScriptTypes(['({ ensureAuthenticated, ensureSessionAuthenticated, apiRequest });',].join('\n'));+// Use the shipped pre-auth entrypoint policy, rather than assuming that every+// cookie-admitted navigation triggers the app's protected bootstrap.+const appRuntimeSource = fs.readFileSync(+ path.resolve(root, '../../frontend-modern/src/useAppRuntimeState.ts'), 'utf8',+);+const preAuthPolicy = appRuntimeSource.match(/const isPreAuthLoginBootstrapPath =[\s\S]*?;\n/);+assert.ok(preAuthPolicy, 'missing app pre-auth entrypoint policy');+const isPreAuthLoginBootstrapPath = runInNewContext(stripTypeScriptTypes(+ `${preAuthPolicy[0]}\nisPreAuthLoginBootstrapPath;`,+));+const cookie = (name, value) => ({name, value, domain: '127.0.0.1', path: '/', expires: -1,httpOnly: name === 'pulse_session', secure: false, sameSite: 'Lax',@@ -68,6 +79,8 @@ function fixture(t, options = {}) {const createPage = () => {let cookies = [];let url = 'about:blank';+ let hasLoginHint = false;+ const navigations = [];const context = {cookies: async () => cookies,addCookies: async values => { cookies = [...cookies, ...values]; },@@ -75,8 +88,19 @@ function fixture(t, options = {}) {return {context: () => context,request: { fetch: async (target, args) => fetch(cookies, target, args) },- goto: async () => { url = validSession(cookies) ? 'http://127.0.0.1:7655/proxmox' : 'http://127.0.0.1:7655/'; },+ goto: async target => {+ navigations.push(target);+ // The real app does not probe protected bootstrap on / or /login+ // without a per-tab login hint. A cookie-only new context has none,+ // even if its separate saved-cookie API probe succeeded.+ const preAuthEntry = isPreAuthLoginBootstrapPath(target);+ const admitted = validSession(cookies) && !options.browserRejectSession &&+ (!preAuthEntry || hasLoginHint);+ url = admitted ? 'http://127.0.0.1:7655/proxmox' : 'http://127.0.0.1:7655/';+ },url: () => url,+ navigations,+ rememberLoginHint: () => { hasLoginHint = true; },};};const api = runInNewContext(helpers, {@@ -98,6 +122,7 @@ function fixture(t, options = {}) {const value = `login-${loginCalls}`;sessions.add(value);await page.context().addCookies([cookie('pulse_session', value), cookie('pulse_csrf', 'csrf')]);+ page.rememberLoginHint();await page.goto('/');},expect: page => ({ toHaveURL: async pattern => assert.match(page.url(), pattern) }),@@ -146,6 +171,29 @@ test('the existing admitted cookie session avoids another login and does not impassert.equal(f.counts().disposed, 1);});+test('cookie-only reuse enters the existing workspace bootstrap, not the hint-dependent login entry', async t => {+ const f = fixture(t);+ f.save([cookie('pulse_session', 'saved-live'), cookie('pulse_csrf', 'csrf')]);+ const page = f.createPage();+ await f.ensureAuthenticated(page);+ assert.deepEqual(page.navigations, ['/infrastructure']);+ assert.equal(f.counts().loginCalls, 0);+ assert.equal(f.counts().probeCalls, 1);+ assert.equal(f.counts().disposed, 1);+});++test('an API-admitted cookie does not hide rejection by the actual browser bootstrap', async t => {+ const f = fixture(t, { browserRejectSession: true });+ f.save([cookie('pulse_session', 'saved-live'), cookie('pulse_csrf', 'csrf')]);+ const page = f.createPage();+ await assert.rejects(() => f.ensureAuthenticated(page), { code: 'ERR_ASSERTION' });+ assert.deepEqual(page.navigations, ['/infrastructure']);+ assert.equal(f.counts().loginCalls, 0);+ assert.equal(f.counts().probeCalls, 1);+ assert.equal(f.counts().disposed, 1);+ assert.equal(page.url(), 'http://127.0.0.1:7655/');+});+for (const scenario of ['revoked', 'expired', 'other-backend', 'missing-session', 'malformed-json']) {test(`${scenario} saved state is not accepted; ordinary login replaces it`, async t => {const f = fixture(t);diff --git a/tests/integration/tests/helpers.ts b/tests/integration/tests/helpers.tsindex 62cb76b7a1..ba37166dc9 100644--- a/tests/integration/tests/helpers.ts+++ b/tests/integration/tests/helpers.ts@@ -1157,7 +1157,11 @@ async function authenticateWithSharedCookieSession(page: Page): Promise<boolean>throw new Error(`Shared cookie session probe failed: ${status}`);}await page.context().addCookies(cookies);- await page.goto("/");+ // Root/login deliberately skip protected bootstrap without a local login+ // hint. Cookie-only reuse has no per-tab hint, so enter the existing+ // workspace route and let its normal protected bootstrap validate it.+ // Do not restore token, tenant or other origin storage to manufacture one.+ await page.goto("/infrastructure");await waitForAppShell(page);await expect(page).toHaveURL(AUTHENTICATED_URL);return true;