fix(test): require advisory cli provider skips

This commit is contained in:
Vincent Koc
2026-06-07 02:23:27 +02:00
parent e12136a7bb
commit 824d5d44cd
2 changed files with 17 additions and 3 deletions
@@ -34,6 +34,7 @@ describe("gateway cli backend live helpers", () => {
delete process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
delete process.env.OPENCLAW_TEST_MINIMAL_GATEWAY;
delete process.env.OPENCLAW_LIVE_CLI_BACKEND_ALLOW_PROVIDER_SKIP;
delete process.env.OPENCLAW_LIVE_CLI_BACKEND_ADVISORY;
delete process.env.ANTHROPIC_API_KEY;
delete process.env.ANTHROPIC_API_KEY_OLD;
});
@@ -155,6 +156,7 @@ describe("gateway cli backend live helpers", () => {
it("requires provider results by default for explicit CLI backend live probes", async () => {
const {
CLI_BACKEND_LIVE_ADVISORY_ENV,
CLI_BACKEND_LIVE_PROVIDER_SKIP_ENV,
resolveCliBackendLiveProviderSkipDecision,
shouldAllowCliBackendLiveProviderSkip,
@@ -171,11 +173,17 @@ describe("gateway cli backend live helpers", () => {
).toEqual({
action: "fail",
message:
'agent request for provider "claude-cli" was blocked by auth drift. Set OPENCLAW_LIVE_CLI_BACKEND_ALLOW_PROVIDER_SKIP=1 only for advisory live probes.',
'agent request for provider "claude-cli" was blocked by auth drift. Set OPENCLAW_LIVE_CLI_BACKEND_ADVISORY=1 and OPENCLAW_LIVE_CLI_BACKEND_ALLOW_PROVIDER_SKIP=1 only for advisory live probes.',
});
expect(
shouldAllowCliBackendLiveProviderSkip({ [CLI_BACKEND_LIVE_PROVIDER_SKIP_ENV]: "1" }),
).toBe(false);
expect(
shouldAllowCliBackendLiveProviderSkip({
[CLI_BACKEND_LIVE_ADVISORY_ENV]: "1",
[CLI_BACKEND_LIVE_PROVIDER_SKIP_ENV]: "1",
}),
).toBe(true);
expect(
resolveCliBackendLiveProviderSkipDecision({
@@ -65,6 +65,7 @@ export type CliBackendLiveEnvSnapshot = {
};
export const CLI_BACKEND_LIVE_PROVIDER_SKIP_ENV = "OPENCLAW_LIVE_CLI_BACKEND_ALLOW_PROVIDER_SKIP";
export const CLI_BACKEND_LIVE_ADVISORY_ENV = "OPENCLAW_LIVE_CLI_BACKEND_ADVISORY";
export type CliBackendLiveProviderSkipDecision = {
action: "fail" | "skip";
@@ -213,7 +214,10 @@ export function shouldRunCliModelSwitchProbe(providerId: string, modelRef: strin
export function shouldAllowCliBackendLiveProviderSkip(
env: Record<string, string | undefined> = process.env,
): boolean {
return isTruthyEnvValue(env[CLI_BACKEND_LIVE_PROVIDER_SKIP_ENV]);
return (
isTruthyEnvValue(env[CLI_BACKEND_LIVE_PROVIDER_SKIP_ENV]) &&
isTruthyEnvValue(env[CLI_BACKEND_LIVE_ADVISORY_ENV])
);
}
export function resolveCliBackendLiveProviderSkipDecision(params: {
@@ -228,7 +232,9 @@ export function resolveCliBackendLiveProviderSkipDecision(params: {
}
return {
action: "fail",
message: `${message} Set ${CLI_BACKEND_LIVE_PROVIDER_SKIP_ENV}=1 only for advisory live probes.`,
message:
`${message} Set ${CLI_BACKEND_LIVE_ADVISORY_ENV}=1 and ` +
`${CLI_BACKEND_LIVE_PROVIDER_SKIP_ENV}=1 only for advisory live probes.`,
};
}