test(browser): dedupe auth mode no-token assertions

This commit is contained in:
Peter Steinberger
2026-02-19 08:18:32 +00:00
parent edce5a505a
commit e0c3cc4981

View File

@@ -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<void> {
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);
});
});