Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Withdraw premature E2E cookie-bootstrap integration

pulse-triage[bot]06c2fad4830f
diff --git a/tests/integration/scripts/fixture-auth.test.mjs b/tests/integration/scripts/fixture-auth.test.mjs
index 935c3d85c6..c4abb6ca7b 100644
--- a/tests/integration/scripts/fixture-auth.test.mjs
+++ b/tests/integration/scripts/fixture-auth.test.mjs
@@ -28,17 +28,6 @@ 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',
@@ -79,8 +68,6 @@ 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]; },
@@ -88,19 +75,8 @@ function fixture(t, options = {}) {
return {
context: () => context,
request: { fetch: async (target, args) => fetch(cookies, target, args) },
- 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/';
- },
+ goto: async () => { url = validSession(cookies) ? 'http://127.0.0.1:7655/proxmox' : 'http://127.0.0.1:7655/'; },
url: () => url,
- navigations,
- rememberLoginHint: () => { hasLoginHint = true; },
};
};
const api = runInNewContext(helpers, {
@@ -122,7 +98,6 @@ 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) }),
@@ -171,29 +146,6 @@ test('the existing admitted cookie session avoids another login and does not imp
assert.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.ts
index ba37166dc9..62cb76b7a1 100644
--- a/tests/integration/tests/helpers.ts
+++ b/tests/integration/tests/helpers.ts
@@ -1157,11 +1157,7 @@ async function authenticateWithSharedCookieSession(page: Page): Promise<boolean>
throw new Error(`Shared cookie session probe failed: ${status}`);
}
await page.context().addCookies(cookies);
- // 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 page.goto("/");
await waitForAppShell(page);
await expect(page).toHaveURL(AUTHENTICATED_URL);
return true;