fix(core): replace hardcoded non-interactive ASK_USER denial with explicit policy rules (#23668)

This commit is contained in:
ruomeng
2026-03-26 14:35:12 -04:00
committed by GitHub
parent aa4d9316a9
commit c888da5f73
13 changed files with 207 additions and 66 deletions
+17 -6
View File
@@ -143,12 +143,17 @@ vi.mock('@google/gemini-cli-core', async () => {
respectGeminiIgnore: true,
customIgnoreFilePaths: [],
},
createPolicyEngineConfig: vi.fn(async () => ({
rules: [],
checkers: [],
defaultDecision: ServerConfig.PolicyDecision.ASK_USER,
approvalMode: ServerConfig.ApprovalMode.DEFAULT,
})),
createPolicyEngineConfig: vi.fn(
async (_settings, approvalMode, _workspacePoliciesDir, interactive) => ({
rules: [],
checkers: [],
defaultDecision: interactive
? ServerConfig.PolicyDecision.ASK_USER
: ServerConfig.PolicyDecision.DENY,
approvalMode: approvalMode ?? ServerConfig.ApprovalMode.DEFAULT,
nonInteractive: !interactive,
}),
),
getAdminErrorMessage: vi.fn(
(_feature) =>
`YOLO mode is disabled by your administrator. To enable it, please request an update to the settings at: https://goo.gle/manage-gemini-cli`,
@@ -3460,6 +3465,8 @@ describe('Policy Engine Integration in loadCliConfig', () => {
}),
}),
expect.anything(),
undefined,
expect.anything(),
);
});
@@ -3481,6 +3488,8 @@ describe('Policy Engine Integration in loadCliConfig', () => {
}),
}),
expect.anything(),
undefined,
expect.anything(),
);
});
@@ -3504,6 +3513,8 @@ describe('Policy Engine Integration in loadCliConfig', () => {
],
}),
expect.anything(),
undefined,
expect.anything(),
);
});
});