
























@@ -15,6 +15,15 @@ function evaluate(config: OpenClawConfig, env: NodeJS.ProcessEnv = EMPTY_ENV) {
1515});
1616}
171718+function expectGatewayState(
19+state: { active: boolean; hasSecretRef: boolean; reason: string },
20+expected: { active: boolean; hasSecretRef: boolean; reason: string },
21+) {
22+expect(state.hasSecretRef).toBe(expected.hasSecretRef);
23+expect(state.active).toBe(expected.active);
24+expect(state.reason).toBe(expected.reason);
25+}
26+1827describe("evaluateGatewayAuthSurfaceStates", () => {
1928it("marks gateway.auth.token active when token mode is explicit", () => {
2029const states = evaluate({
@@ -26,7 +35,7 @@ describe("evaluateGatewayAuthSurfaceStates", () => {
2635},
2736} as OpenClawConfig);
283729-expect(states["gateway.auth.token"]).toMatchObject({
38+expectGatewayState(states["gateway.auth.token"], {
3039hasSecretRef: true,
3140active: true,
3241reason: 'gateway.auth.mode is "token".',
@@ -46,7 +55,7 @@ describe("evaluateGatewayAuthSurfaceStates", () => {
4655{ OPENCLAW_GATEWAY_TOKEN: "env-token" } as NodeJS.ProcessEnv,
4756);
485749-expect(states["gateway.auth.token"]).toMatchObject({
58+expectGatewayState(states["gateway.auth.token"], {
5059hasSecretRef: true,
5160active: false,
5261reason: "gateway token env var is configured.",
@@ -63,7 +72,7 @@ describe("evaluateGatewayAuthSurfaceStates", () => {
6372},
6473} as OpenClawConfig);
657466-expect(states["gateway.auth.token"]).toMatchObject({
75+expectGatewayState(states["gateway.auth.token"], {
6776hasSecretRef: true,
6877active: false,
6978reason: 'gateway.auth.mode is "password".',
@@ -80,7 +89,7 @@ describe("evaluateGatewayAuthSurfaceStates", () => {
8089},
8190} as OpenClawConfig);
829183-expect(states["gateway.auth.password"]).toMatchObject({
92+expectGatewayState(states["gateway.auth.password"], {
8493hasSecretRef: true,
8594active: true,
8695reason: 'gateway.auth.mode is "password".',
@@ -97,7 +106,7 @@ describe("evaluateGatewayAuthSurfaceStates", () => {
97106},
98107} as OpenClawConfig);
99108100-expect(states["gateway.auth.password"]).toMatchObject({
109+expectGatewayState(states["gateway.auth.password"], {
101110hasSecretRef: true,
102111active: true,
103112reason: "no token source can win, so password auth can win.",
@@ -116,7 +125,7 @@ describe("evaluateGatewayAuthSurfaceStates", () => {
116125{ OPENCLAW_GATEWAY_TOKEN: "env-token" } as NodeJS.ProcessEnv,
117126);
118127119-expect(states["gateway.auth.password"]).toMatchObject({
128+expectGatewayState(states["gateway.auth.password"], {
120129hasSecretRef: true,
121130active: false,
122131reason: "gateway token env var is configured.",
@@ -133,7 +142,7 @@ describe("evaluateGatewayAuthSurfaceStates", () => {
133142},
134143} as OpenClawConfig);
135144136-expect(states["gateway.remote.token"]).toMatchObject({
145+expectGatewayState(states["gateway.remote.token"], {
137146hasSecretRef: true,
138147active: true,
139148reason: "local token auth can win and no env/auth token is configured.",
@@ -152,7 +161,7 @@ describe("evaluateGatewayAuthSurfaceStates", () => {
152161},
153162} as OpenClawConfig);
154163155-expect(states["gateway.remote.token"]).toMatchObject({
164+expectGatewayState(states["gateway.remote.token"], {
156165hasSecretRef: true,
157166active: false,
158167reason: 'token auth cannot win with gateway.auth.mode="password".',
@@ -173,7 +182,7 @@ describe("evaluateGatewayAuthSurfaceStates", () => {
173182},
174183} as OpenClawConfig);
175184176-expect(states["gateway.remote.token"]).toMatchObject({
185+expectGatewayState(states["gateway.remote.token"], {
177186hasSecretRef: true,
178187active: false,
179188reason: "gateway.auth.token is configured.",
@@ -208,7 +217,7 @@ describe("evaluateGatewayAuthSurfaceStates", () => {
208217},
209218} as OpenClawConfig);
210219211-expect(states["gateway.remote.password"]).toMatchObject({
220+expectGatewayState(states["gateway.remote.password"], {
212221hasSecretRef: true,
213222active: false,
214223reason: 'password auth cannot win with gateway.auth.mode="token".',
@@ -228,7 +237,7 @@ describe("evaluateGatewayAuthSurfaceStates", () => {
228237},
229238} as OpenClawConfig);
230239231-expect(states["gateway.remote.password"]).toMatchObject({
240+expectGatewayState(states["gateway.remote.password"], {
232241hasSecretRef: true,
233242active: false,
234243reason: "remote password fallback is not active.",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。