diff --git a/src/node-host/runner.credentials.test.ts b/src/node-host/runner.credentials.test.ts index 6138a6b954e..c7a04951130 100644 --- a/src/node-host/runner.credentials.test.ts +++ b/src/node-host/runner.credentials.test.ts @@ -19,6 +19,17 @@ function createRemoteGatewayTokenRefConfig(tokenId: string): OpenClawConfig { } as OpenClawConfig; } +async function expectNoGatewayCredentials( + config: OpenClawConfig, + env: Record, +) { + await withEnvAsync(env, async () => { + const credentials = await resolveNodeHostGatewayCredentials({ config }); + expect(credentials.token).toBeUndefined(); + expect(credentials.password).toBeUndefined(); + }); +} + describe("resolveNodeHostGatewayCredentials", () => { it("does not inherit gateway.remote token in local mode", async () => { const config = { @@ -28,17 +39,10 @@ describe("resolveNodeHostGatewayCredentials", () => { }, } as OpenClawConfig; - await withEnvAsync( - { - OPENCLAW_GATEWAY_TOKEN: undefined, - OPENCLAW_GATEWAY_PASSWORD: undefined, - }, - async () => { - const credentials = await resolveNodeHostGatewayCredentials({ config }); - expect(credentials.token).toBeUndefined(); - expect(credentials.password).toBeUndefined(); - }, - ); + await expectNoGatewayCredentials(config, { + OPENCLAW_GATEWAY_TOKEN: undefined, + OPENCLAW_GATEWAY_PASSWORD: undefined, + }); }); it("ignores unresolved gateway.remote token refs in local mode", async () => { @@ -56,18 +60,11 @@ describe("resolveNodeHostGatewayCredentials", () => { }, } as OpenClawConfig; - await withEnvAsync( - { - OPENCLAW_GATEWAY_TOKEN: undefined, - OPENCLAW_GATEWAY_PASSWORD: undefined, - MISSING_REMOTE_GATEWAY_TOKEN: undefined, - }, - async () => { - const credentials = await resolveNodeHostGatewayCredentials({ config }); - expect(credentials.token).toBeUndefined(); - expect(credentials.password).toBeUndefined(); - }, - ); + await expectNoGatewayCredentials(config, { + OPENCLAW_GATEWAY_TOKEN: undefined, + OPENCLAW_GATEWAY_PASSWORD: undefined, + MISSING_REMOTE_GATEWAY_TOKEN: undefined, + }); }); it("resolves remote token SecretRef values", async () => {