From e0c3cc4981d6cd9829d1877d2e1341791abbdfd4 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 19 Feb 2026 08:18:32 +0000 Subject: [PATCH] test(browser): dedupe auth mode no-token assertions --- src/browser/control-auth.test.ts | 40 +++++++++++--------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/src/browser/control-auth.test.ts b/src/browser/control-auth.test.ts index b88816adb5..f80740d01f 100644 --- a/src/browser/control-auth.test.ts +++ b/src/browser/control-auth.test.ts @@ -3,6 +3,16 @@ import type { OpenClawConfig } from "../config/types.js"; import { ensureBrowserControlAuth } from "./control-auth.js"; describe("ensureBrowserControlAuth", () => { + async function expectNoAutoGeneratedAuth(cfg: OpenClawConfig): Promise { + const result = await ensureBrowserControlAuth({ + cfg, + env: { OPENCLAW_BROWSER_AUTO_AUTH: "1" }, + }); + expect(result.generatedToken).toBeUndefined(); + expect(result.auth.token).toBeUndefined(); + expect(result.auth.password).toBeUndefined(); + } + describe("trusted-proxy mode", () => { it("should not auto-generate token when auth mode is trusted-proxy", async () => { const cfg: OpenClawConfig = { @@ -16,15 +26,7 @@ describe("ensureBrowserControlAuth", () => { trustedProxies: ["192.168.1.1"], }, }; - - const result = await ensureBrowserControlAuth({ - cfg, - env: { OPENCLAW_BROWSER_AUTO_AUTH: "1" }, - }); - - expect(result.generatedToken).toBeUndefined(); - expect(result.auth.token).toBeUndefined(); - expect(result.auth.password).toBeUndefined(); + await expectNoAutoGeneratedAuth(cfg); }); }); @@ -37,15 +39,7 @@ describe("ensureBrowserControlAuth", () => { }, }, }; - - const result = await ensureBrowserControlAuth({ - cfg, - env: { OPENCLAW_BROWSER_AUTO_AUTH: "1" }, - }); - - expect(result.generatedToken).toBeUndefined(); - expect(result.auth.token).toBeUndefined(); - expect(result.auth.password).toBeUndefined(); + await expectNoAutoGeneratedAuth(cfg); }); }); @@ -58,15 +52,7 @@ describe("ensureBrowserControlAuth", () => { }, }, }; - - const result = await ensureBrowserControlAuth({ - cfg, - env: { OPENCLAW_BROWSER_AUTO_AUTH: "1" }, - }); - - expect(result.generatedToken).toBeUndefined(); - expect(result.auth.token).toBeUndefined(); - expect(result.auth.password).toBeUndefined(); + await expectNoAutoGeneratedAuth(cfg); }); });