import { describe, expect, it } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; import { evaluateGatewayAuthSurfaceStates } from "./runtime-gateway-auth-surfaces.js";
const EMPTY_ENV = {} as NodeJS.ProcessEnv;
function envRef(id: string) { return { source: "env", provider: "default", id } as const;
}
it("marks gateway.auth.password inactive when env token is configured", () => { const states = evaluate(
{
gateway: {
auth: {
password: envRef("GW_AUTH_PASSWORD"),
},
},
} as OpenClawConfig,
{ OPENCLAW_GATEWAY_TOKEN: "env-token" } as NodeJS.ProcessEnv,
);
expect(states["gateway.auth.password"]).toMatchObject({
hasSecretRef: true,
active: false,
reason: "gateway token env var is configured.",
});
});
it("marks gateway.remote.token active when remote token fallback is active", () => { const states = evaluate({
gateway: {
mode: "local",
remote: {
token: envRef("GW_REMOTE_TOKEN"),
},
},
} as OpenClawConfig);
expect(states["gateway.remote.token"]).toMatchObject({
hasSecretRef: true,
active: true,
reason: "local token auth can win and no env/auth token is configured.",
});
});
it("marks gateway.remote.password active when remote url is configured", () => { const states = evaluate({
gateway: {
remote: {
url: "wss://gateway.example.com",
password: envRef("GW_REMOTE_PASSWORD"),
},
},
} as OpenClawConfig);
expect(states["gateway.remote.password"].hasSecretRef).toBe(true);
expect(states["gateway.remote.password"].active).toBe(true);
expect(states["gateway.remote.password"].reason).toContain("remote surface is active:");
expect(states["gateway.remote.password"].reason).toContain("gateway.remote.url is configured");
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.