mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 11:07:27 +00:00
refactor(commands): dedupe gateway status token secret fixtures
This commit is contained in:
@@ -149,6 +149,23 @@ function makeRemoteGatewayConfig(url: string, token = "rtok", localToken = "ltok
|
||||
};
|
||||
}
|
||||
|
||||
function mockLocalTokenSecretRefConfig(secretId = "MISSING_GATEWAY_TOKEN") {
|
||||
loadConfig.mockReturnValueOnce({
|
||||
secrets: {
|
||||
providers: {
|
||||
default: { source: "env" },
|
||||
},
|
||||
},
|
||||
gateway: {
|
||||
mode: "local",
|
||||
auth: {
|
||||
mode: "token",
|
||||
token: { source: "env", provider: "default", id: secretId },
|
||||
},
|
||||
},
|
||||
} as unknown as ReturnType<typeof loadConfig>);
|
||||
}
|
||||
|
||||
async function runGatewayStatus(
|
||||
runtime: ReturnType<typeof createRuntimeCapture>["runtime"],
|
||||
opts: { timeout: string; json?: boolean; ssh?: string; sshAuto?: boolean; sshIdentity?: string },
|
||||
@@ -187,20 +204,7 @@ describe("gateway-status command", () => {
|
||||
it("surfaces unresolved SecretRef auth diagnostics in warnings", async () => {
|
||||
const { runtime, runtimeLogs, runtimeErrors } = createRuntimeCapture();
|
||||
await withEnvAsync({ MISSING_GATEWAY_TOKEN: undefined }, async () => {
|
||||
loadConfig.mockReturnValueOnce({
|
||||
secrets: {
|
||||
providers: {
|
||||
default: { source: "env" },
|
||||
},
|
||||
},
|
||||
gateway: {
|
||||
mode: "local",
|
||||
auth: {
|
||||
mode: "token",
|
||||
token: { source: "env", provider: "default", id: "MISSING_GATEWAY_TOKEN" },
|
||||
},
|
||||
},
|
||||
} as unknown as ReturnType<typeof loadConfig>);
|
||||
mockLocalTokenSecretRefConfig();
|
||||
|
||||
await runGatewayStatus(runtime, { timeout: "1000", json: true });
|
||||
});
|
||||
@@ -228,20 +232,7 @@ describe("gateway-status command", () => {
|
||||
MISSING_GATEWAY_TOKEN: undefined,
|
||||
},
|
||||
async () => {
|
||||
loadConfig.mockReturnValueOnce({
|
||||
secrets: {
|
||||
providers: {
|
||||
default: { source: "env" },
|
||||
},
|
||||
},
|
||||
gateway: {
|
||||
mode: "local",
|
||||
auth: {
|
||||
mode: "token",
|
||||
token: { source: "env", provider: "default", id: "MISSING_GATEWAY_TOKEN" },
|
||||
},
|
||||
},
|
||||
} as unknown as ReturnType<typeof loadConfig>);
|
||||
mockLocalTokenSecretRefConfig();
|
||||
|
||||
await runGatewayStatus(runtime, { timeout: "1000", json: true });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user