mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 07:44:06 +02:00
test(commands): share gateway status secretref config
This commit is contained in:
@@ -5,6 +5,7 @@ import type { GatewayTlsRuntime } from "../infra/tls/gateway.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { withEnvAsync } from "../test-utils/env.js";
|
||||
import { gatewayStatusCommand } from "./gateway-status.js";
|
||||
import { createSecretRefGatewayConfig } from "./gateway-status/test-support.js";
|
||||
|
||||
const mocks = vi.hoisted(() => {
|
||||
const sshStop = vi.fn(async () => {});
|
||||
@@ -548,24 +549,7 @@ describe("gateway-status command", () => {
|
||||
exists: true,
|
||||
valid: true,
|
||||
config: {
|
||||
secrets: {
|
||||
defaults: {
|
||||
env: "default",
|
||||
},
|
||||
},
|
||||
gateway: {
|
||||
mode: "remote",
|
||||
auth: {
|
||||
mode: "token",
|
||||
token: { source: "env", provider: "default", id: "OPENCLAW_GATEWAY_TOKEN" },
|
||||
password: { source: "env", provider: "default", id: "OPENCLAW_GATEWAY_PASSWORD" },
|
||||
},
|
||||
remote: {
|
||||
url: "wss://remote.example:18789",
|
||||
token: { source: "env", provider: "default", id: "REMOTE_GATEWAY_TOKEN" },
|
||||
password: { source: "env", provider: "default", id: "REMOTE_GATEWAY_PASSWORD" },
|
||||
},
|
||||
},
|
||||
...createSecretRefGatewayConfig({ gatewayMode: "remote" }),
|
||||
discovery: {
|
||||
wideArea: { enabled: true },
|
||||
},
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
resolveProbeBudgetMs,
|
||||
resolveTargets,
|
||||
} from "./helpers.js";
|
||||
import { createSecretRefGatewayConfig } from "./test-support.js";
|
||||
|
||||
describe("extractConfigSummary", () => {
|
||||
it("marks SecretRef-backed gateway auth credentials as configured", () => {
|
||||
@@ -19,25 +20,7 @@ describe("extractConfigSummary", () => {
|
||||
valid: true,
|
||||
issues: [],
|
||||
legacyIssues: [],
|
||||
config: {
|
||||
secrets: {
|
||||
defaults: {
|
||||
env: "default",
|
||||
},
|
||||
},
|
||||
gateway: {
|
||||
auth: {
|
||||
mode: "token",
|
||||
token: { source: "env", provider: "default", id: "OPENCLAW_GATEWAY_TOKEN" },
|
||||
password: { source: "env", provider: "default", id: "OPENCLAW_GATEWAY_PASSWORD" },
|
||||
},
|
||||
remote: {
|
||||
url: "wss://remote.example:18789",
|
||||
token: { source: "env", provider: "default", id: "REMOTE_GATEWAY_TOKEN" },
|
||||
password: { source: "env", provider: "default", id: "REMOTE_GATEWAY_PASSWORD" },
|
||||
},
|
||||
},
|
||||
},
|
||||
config: createSecretRefGatewayConfig(),
|
||||
});
|
||||
|
||||
expect(summary.gateway.authTokenConfigured).toBe(true);
|
||||
|
||||
22
src/commands/gateway-status/test-support.ts
Normal file
22
src/commands/gateway-status/test-support.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export function createSecretRefGatewayConfig(params?: { gatewayMode?: "local" | "remote" }) {
|
||||
return {
|
||||
secrets: {
|
||||
defaults: {
|
||||
env: "default",
|
||||
},
|
||||
},
|
||||
gateway: {
|
||||
...(params?.gatewayMode ? { mode: params.gatewayMode } : {}),
|
||||
auth: {
|
||||
mode: "token" as const,
|
||||
token: { source: "env", provider: "default", id: "OPENCLAW_GATEWAY_TOKEN" },
|
||||
password: { source: "env", provider: "default", id: "OPENCLAW_GATEWAY_PASSWORD" },
|
||||
},
|
||||
remote: {
|
||||
url: "wss://remote.example:18789",
|
||||
token: { source: "env", provider: "default", id: "REMOTE_GATEWAY_TOKEN" },
|
||||
password: { source: "env", provider: "default", id: "REMOTE_GATEWAY_PASSWORD" },
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user