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.

Prove demo auto sign-in in the public browser smoke

rcourtmandf79b7716a0b
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index fcc862962b..79265a6cda 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -5682,6 +5682,14 @@ demo login reaches the connected workspace instead of failing open on API-only
reachability or remaining on the authenticated loading shell. The proof must
use visible UI state rather than Playwright `networkidle`, because the public
demo can keep background activity alive after the page is already usable.
+Since v6.5.0 demo mode signs a fresh visitor in with the published demo
+credentials, so the login form never stays on screen for a first visit. The
+smoke therefore proves that a fresh visitor reaches the connected workspace
+when the server reports demo mode, then sets the frontend's tab-scoped
+`pulse-demo-auto-login` marker in a separate context to keep proving the login
+form and a manual demo sign-in. The policy test pins that marker to
+`frontend-modern/src/utils/localStorage.ts`, so a rename fails source checks
+instead of the live demo step.
That same demo-update verification boundary also owns the canonical v6 mock
runtime state contract. `.github/workflows/update-demo-server.yml` must verify
mock-mode readiness through the unified `/api/state` `resources[]` collection,
diff --git a/scripts/demo_public_browser_smoke.cjs b/scripts/demo_public_browser_smoke.cjs
index 0d58f900bb..447d2fcd5a 100644
--- a/scripts/demo_public_browser_smoke.cjs
+++ b/scripts/demo_public_browser_smoke.cjs
@@ -4,6 +4,11 @@ const siteUrl = String(process.env.PULSE_PUBLIC_SITE_URL || '').trim();
const authUser = String(process.env.PULSE_DEMO_AUTH_USER || '').trim();
const authPass = String(process.env.PULSE_DEMO_AUTH_PASS || '');
+// Demo mode signs a fresh visitor straight in (Login.tsx). The tab-scoped
+// marker it writes after that attempt is what keeps the form on screen, so
+// the login-form proof sets it before the app loads.
+const DEMO_AUTO_LOGIN_KEY = 'pulse-demo-auto-login';
+
function assert(condition, message) {
if (!condition) {
throw new Error(message);
@@ -16,23 +21,63 @@ function normalizeText(value) {
.trim();
}
+async function openDemo(browser, { suppressAutoLogin }) {
+ const context = await browser.newContext({ viewport: { width: 1280, height: 900 } });
+ if (suppressAutoLogin) {
+ await context.addInitScript((key) => {
+ window.sessionStorage.setItem(key, 'suppressed');
+ }, DEMO_AUTO_LOGIN_KEY);
+ }
+ const page = await context.newPage();
+ const response = await page.goto(siteUrl, {
+ // Public demo shells can keep background activity alive long after the
+ // page is usable, so wait for the first document and then assert the
+ // actual UI instead of blocking on network quiescence.
+ waitUntil: 'domcontentloaded',
+ timeout: 120000,
+ });
+ assert(response, `No response received for ${siteUrl}`);
+ assert(response.ok(), `Unexpected status ${response.status()} loading ${siteUrl}`);
+ return page;
+}
+
+async function waitForConnectedWorkspace(page, startedAt, label) {
+ await page.locator('main').waitFor({ state: 'visible', timeout: 60000 });
+ await page
+ .getByRole('status', { name: 'Backend and live data stream are connected.' })
+ .waitFor({ state: 'visible', timeout: 60000 });
+
+ const authenticatedBody = normalizeText(await page.locator('body').innerText());
+ assert(authenticatedBody !== 'Loading...', 'Public demo remained on the authenticated loading shell');
+ assert(authenticatedBody.includes('Pulse'), 'Authenticated public demo body is missing the Pulse workspace');
+ console.log(`${label} workspace became connected in ${Date.now() - startedAt}ms`);
+}
+
+async function demoModeEnabled(page) {
+ const response = await page.request.get(new URL('api/security/status', siteUrl).toString(), {
+ timeout: 30000,
+ });
+ assert(response.ok(), `Unexpected status ${response.status()} reading demo security status`);
+ const status = await response.json();
+ return status?.presentationPolicy?.demoMode === true;
+}
+
async function main() {
assert(siteUrl, 'PULSE_PUBLIC_SITE_URL is required');
assert(Boolean(authUser) === Boolean(authPass), 'PULSE_DEMO_AUTH_USER and PULSE_DEMO_AUTH_PASS must be provided together');
const browser = await chromium.launch({ headless: true });
try {
- const page = await browser.newPage({ viewport: { width: 1280, height: 900 } });
- const response = await page.goto(siteUrl, {
- // Public demo shells can keep background activity alive long after the
- // page is usable, so wait for the first document and then assert the
- // actual login UI instead of blocking on network quiescence.
- waitUntil: 'domcontentloaded',
- timeout: 120000,
- });
- assert(response, `No response received for ${siteUrl}`);
- assert(response.ok(), `Unexpected status ${response.status()} loading ${siteUrl}`);
+ // A first-time visitor must land on the connected workspace without typing
+ // the published demo credentials.
+ const visitorStartedAt = Date.now();
+ const visitor = await openDemo(browser, { suppressAutoLogin: false });
+ if (await demoModeEnabled(visitor)) {
+ await waitForConnectedWorkspace(visitor, visitorStartedAt, 'auto-signed-in visitor');
+ }
+ await visitor.context().close();
+ const page = await openDemo(browser, { suppressAutoLogin: true });
await page.getByLabel('Username').waitFor({ state: 'visible', timeout: 120000 });
await page.getByLabel('Password').waitFor({ state: 'visible', timeout: 120000 });
await page.getByRole('button', { name: 'Sign in to Pulse' }).waitFor({ state: 'visible', timeout: 120000 });
@@ -50,16 +95,7 @@ async function main() {
await page.getByLabel('Username').fill(authUser);
await page.getByLabel('Password').fill(authPass);
await page.getByRole('button', { name: 'Sign in to Pulse' }).click();
-
- await page.locator('main').waitFor({ state: 'visible', timeout: 60000 });
- await page
- .getByRole('status', { name: 'Backend and live data stream are connected.' })
- .waitFor({ state: 'visible', timeout: 60000 });
-
- const authenticatedBody = normalizeText(await page.locator('body').innerText());
- assert(authenticatedBody !== 'Loading...', 'Public demo remained on the authenticated loading shell');
- assert(authenticatedBody.includes('Pulse'), 'Authenticated public demo body is missing the Pulse workspace');
- console.log(`authenticated workspace became connected in ${Date.now() - loginStartedAt}ms`);
+ await waitForConnectedWorkspace(page, loginStartedAt, 'authenticated');
}
console.log(`public demo browser smoke passed for ${siteUrl}`);
diff --git a/scripts/installtests/build_release_assets_test.go b/scripts/installtests/build_release_assets_test.go
index 795980c922..62ef245cf2 100644
--- a/scripts/installtests/build_release_assets_test.go
+++ b/scripts/installtests/build_release_assets_test.go
@@ -2735,6 +2735,10 @@ func TestDemoPublicBrowserSmokeWaitsForVisibleLoginUI(t *testing.T) {
`getByLabel('Password').waitFor({ state: 'visible', timeout: 120000 })`,
`getByRole('button', { name: 'Sign in to Pulse' }).waitFor({ state: 'visible', timeout: 120000 })`,
`getByRole('status', { name: 'Backend and live data stream are connected.' })`,
+ `const DEMO_AUTO_LOGIN_KEY = 'pulse-demo-auto-login';`,
+ `await openDemo(browser, { suppressAutoLogin: false })`,
+ `await waitForConnectedWorkspace(visitor, visitorStartedAt, 'auto-signed-in visitor')`,
+ `await openDemo(browser, { suppressAutoLogin: true })`,
}
for _, needle := range required {
if !strings.Contains(script, needle) {
diff --git a/scripts/release_control/release_promotion_policy_test.py b/scripts/release_control/release_promotion_policy_test.py
index 208f5f2a43..0576d92a8d 100644
--- a/scripts/release_control/release_promotion_policy_test.py
+++ b/scripts/release_control/release_promotion_policy_test.py
@@ -3367,6 +3367,13 @@ else:
self.assertNotIn("getByText('Connected', { exact: true })", demo_smoke)
self.assertIn("Public demo remained on the authenticated loading shell", demo_smoke)
self.assertNotIn("waitUntil: 'networkidle'", demo_smoke)
+ # v6.5.0 demo mode signs a fresh visitor in, so the smoke proves that
+ # arrival and suppresses it for the tab that proves the login form.
+ self.assertIn("const DEMO_AUTO_LOGIN_KEY = 'pulse-demo-auto-login';", demo_smoke)
+ self.assertIn("await waitForConnectedWorkspace(visitor, visitorStartedAt, 'auto-signed-in visitor')", demo_smoke)
+ self.assertIn("await openDemo(browser, { suppressAutoLogin: true })", demo_smoke)
+ login = read("frontend-modern/src/utils/localStorage.ts")
+ self.assertIn("DEMO_AUTO_LOGIN: 'pulse-demo-auto-login'", login)
def test_stable_demo_recovery_is_fixed_current_bits_only(self) -> None:
workflow = read(".github/workflows/recover-demo-server.yml")