From 610e4d39f0afd77dced7004e4b60b21577bd9893 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 9 Jun 2026 18:33:00 -0700 Subject: [PATCH] test(brainstorm-server): thread session key through tests after auth merge Integrating the per-session-key auth onto the same branch as the dotfile and lifecycle work: two tests added after the auth commit opened WebSockets without a key (server.test.js dotfile-reload, lifecycle.test.js idle-shutdown), which the auth gate now resets. Pass ?key=/BRAINSTORM_TOKEN in both. Full suite green: ws-protocol 32, helper 12, auth 13, server 28, lifecycle 7, stop-server 4. --- tests/brainstorm-server/lifecycle.test.js | 4 ++-- tests/brainstorm-server/server.test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/brainstorm-server/lifecycle.test.js b/tests/brainstorm-server/lifecycle.test.js index 972d2e5f..9203322f 100644 --- a/tests/brainstorm-server/lifecycle.test.js +++ b/tests/brainstorm-server/lifecycle.test.js @@ -46,12 +46,12 @@ async function runTests() { await test('idle shutdown closes an open WebSocket and the process exits', async () => { const dir = fs.mkdtempSync('/tmp/bs-life-'); - const srv = spawn('node', [SERVER], { env: { ...process.env, BRAINSTORM_PORT: 3402, BRAINSTORM_DIR: dir, BRAINSTORM_IDLE_TIMEOUT_MS: 200, BRAINSTORM_LIFECYCLE_CHECK_MS: 100 } }); + const srv = spawn('node', [SERVER], { env: { ...process.env, BRAINSTORM_PORT: 3402, BRAINSTORM_DIR: dir, BRAINSTORM_TOKEN: 'lifetoken', BRAINSTORM_IDLE_TIMEOUT_MS: 200, BRAINSTORM_LIFECYCLE_CHECK_MS: 100 } }); let out = ''; srv.stdout.on('data', d => out += d.toString()); let exited = false, code = null; srv.on('exit', c => { exited = true; code = c; }); for (let i = 0; i < 60 && !out.includes('server-started'); i++) await sleep(50); - const ws = new WebSocket('ws://localhost:3402'); + const ws = new WebSocket('ws://localhost:3402/?key=lifetoken'); await new Promise((res, rej) => { ws.on('open', res); ws.on('error', rej); }); // 200ms idle, checked every 100ms — should shut down and exit well within 4s, diff --git a/tests/brainstorm-server/server.test.js b/tests/brainstorm-server/server.test.js index 632710fa..9455ba16 100644 --- a/tests/brainstorm-server/server.test.js +++ b/tests/brainstorm-server/server.test.js @@ -374,7 +374,7 @@ async function runTests() { }); await test('does NOT send reload for ._*.html resource-fork dotfiles', async () => { - const ws = new WebSocket(`ws://localhost:${TEST_PORT}`); + const ws = new WebSocket(`ws://localhost:${TEST_PORT}/?key=${TOKEN}`); await new Promise(resolve => ws.on('open', resolve)); let gotReload = false;