From a879ad7547ee8e3fae82acf3f9c6984b11354e7b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 13 Mar 2026 21:05:06 +0000 Subject: [PATCH] test: share node host credential assertions --- src/node-host/runner.credentials.test.ts | 43 +++++++++++------------- 1 file changed, 20 insertions(+), 23 deletions(-) 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 () => {