mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
test: isolate browser server auth env (evaluate gating)
This commit is contained in:
@@ -4,6 +4,8 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
let testPort = 0;
|
||||
let prevGatewayPort: string | undefined;
|
||||
let prevGatewayToken: string | undefined;
|
||||
let prevGatewayPassword: string | undefined;
|
||||
|
||||
const pwMocks = vi.hoisted(() => ({
|
||||
cookiesGetViaPlaywright: vi.fn(async () => ({
|
||||
@@ -82,6 +84,10 @@ describe("browser control evaluate gating", () => {
|
||||
testPort = await getFreePort();
|
||||
prevGatewayPort = process.env.OPENCLAW_GATEWAY_PORT;
|
||||
process.env.OPENCLAW_GATEWAY_PORT = String(testPort - 2);
|
||||
prevGatewayToken = process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||
prevGatewayPassword = process.env.OPENCLAW_GATEWAY_PASSWORD;
|
||||
delete process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||
delete process.env.OPENCLAW_GATEWAY_PASSWORD;
|
||||
|
||||
pwMocks.cookiesGetViaPlaywright.mockClear();
|
||||
pwMocks.storageGetViaPlaywright.mockClear();
|
||||
@@ -97,6 +103,16 @@ describe("browser control evaluate gating", () => {
|
||||
} else {
|
||||
process.env.OPENCLAW_GATEWAY_PORT = prevGatewayPort;
|
||||
}
|
||||
if (prevGatewayToken === undefined) {
|
||||
delete process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||
} else {
|
||||
process.env.OPENCLAW_GATEWAY_TOKEN = prevGatewayToken;
|
||||
}
|
||||
if (prevGatewayPassword === undefined) {
|
||||
delete process.env.OPENCLAW_GATEWAY_PASSWORD;
|
||||
} else {
|
||||
process.env.OPENCLAW_GATEWAY_PASSWORD = prevGatewayPassword;
|
||||
}
|
||||
|
||||
await stopBrowserControlServer();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user