@@ -6,7 +6,7 @@ import { afterEach, describe, expect, it } from "vitest";
|
6 | 6 | import { clearConfigCache, clearRuntimeConfigSnapshot } from "../config/config.js"; |
7 | 7 | import { clearSessionStoreCacheForTest } from "../config/sessions/store.js"; |
8 | 8 | import type { OpenClawConfig } from "../config/types.openclaw.js"; |
9 | | -import { captureEnv } from "../test-utils/env.js"; |
| 9 | +import { captureEnv, deleteTestEnvValue, setTestEnvValue } from "../test-utils/env.js"; |
10 | 10 | import { ADMIN_SCOPE, APPROVALS_SCOPE } from "./method-scopes.js"; |
11 | 11 | import { withOperatorApprovalsGatewayClient } from "./operator-approvals-client.js"; |
12 | 12 | import { startGatewayServer } from "./server.js"; |
@@ -63,23 +63,23 @@ describe("operator approval gateway client runtime token source", () => {
|
63 | 63 | it("uses runtime authority only for generated local gateway URLs", async () => { |
64 | 64 | const envSnapshot = captureEnv(TEST_ENV_KEYS); |
65 | 65 | cleanup.push(() => envSnapshot.restore()); |
66 | | -delete process.env.OPENCLAW_CONFIG_PATH; |
67 | | -delete process.env.OPENCLAW_GATEWAY_URL; |
68 | | -delete process.env.OPENCLAW_GATEWAY_TOKEN; |
69 | | -delete process.env.OPENCLAW_GATEWAY_PASSWORD; |
| 66 | +deleteTestEnvValue("OPENCLAW_CONFIG_PATH"); |
| 67 | +deleteTestEnvValue("OPENCLAW_GATEWAY_URL"); |
| 68 | +deleteTestEnvValue("OPENCLAW_GATEWAY_TOKEN"); |
| 69 | +deleteTestEnvValue("OPENCLAW_GATEWAY_PASSWORD"); |
70 | 70 | |
71 | 71 | const tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-approval-client-e2e-")); |
72 | 72 | cleanup.push(() => fs.rm(tempHome, { recursive: true, force: true, maxRetries: 5 })); |
73 | 73 | |
74 | 74 | const stateDir = path.join(tempHome, ".openclaw"); |
75 | 75 | await fs.mkdir(stateDir, { recursive: true }); |
76 | | -process.env.HOME = tempHome; |
77 | | -process.env.OPENCLAW_STATE_DIR = stateDir; |
| 76 | +setTestEnvValue("HOME", tempHome); |
| 77 | +setTestEnvValue("OPENCLAW_STATE_DIR", stateDir); |
78 | 78 | |
79 | 79 | const port = await getFreeGatewayPort(); |
80 | 80 | const token = "approval-client-e2e-token"; |
81 | 81 | const url = `ws://127.0.0.1:${port}`; |
82 | | -process.env.OPENCLAW_GATEWAY_PORT = String(port); |
| 82 | +setTestEnvValue("OPENCLAW_GATEWAY_PORT", String(port)); |
83 | 83 | |
84 | 84 | const server = await startGatewayServer(port, { |
85 | 85 | bind: "loopback", |
|