mirror of https://github.com/openclaw/openclaw.git
test: share node host credential assertions
This commit is contained in:
parent
4ec0a120df
commit
a879ad7547
|
|
@ -19,6 +19,17 @@ function createRemoteGatewayTokenRefConfig(tokenId: string): OpenClawConfig {
|
|||
} as OpenClawConfig;
|
||||
}
|
||||
|
||||
async function expectNoGatewayCredentials(
|
||||
config: OpenClawConfig,
|
||||
env: Record<string, string | undefined>,
|
||||
) {
|
||||
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(
|
||||
{
|
||||
await expectNoGatewayCredentials(config, {
|
||||
OPENCLAW_GATEWAY_TOKEN: undefined,
|
||||
OPENCLAW_GATEWAY_PASSWORD: undefined,
|
||||
},
|
||||
async () => {
|
||||
const credentials = await resolveNodeHostGatewayCredentials({ config });
|
||||
expect(credentials.token).toBeUndefined();
|
||||
expect(credentials.password).toBeUndefined();
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("ignores unresolved gateway.remote token refs in local mode", async () => {
|
||||
|
|
@ -56,18 +60,11 @@ describe("resolveNodeHostGatewayCredentials", () => {
|
|||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
await withEnvAsync(
|
||||
{
|
||||
await expectNoGatewayCredentials(config, {
|
||||
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();
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("resolves remote token SecretRef values", async () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue