mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-12 15:10:59 -07:00
Add Folder Trust Support To Hooks (#15325)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import {
|
||||
ApprovalMode,
|
||||
PolicyDecision,
|
||||
@@ -13,6 +13,21 @@ import {
|
||||
import { createPolicyEngineConfig } from './policy.js';
|
||||
import type { Settings } from './settings.js';
|
||||
|
||||
// Mock Storage to ensure tests are hermetic and don't read from user's home directory
|
||||
vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
const actual =
|
||||
await importOriginal<typeof import('@google/gemini-cli-core')>();
|
||||
const Storage = actual.Storage;
|
||||
// Monkey-patch static methods
|
||||
Storage.getUserPoliciesDir = () => '/non-existent/user/policies';
|
||||
Storage.getSystemPoliciesDir = () => '/non-existent/system/policies';
|
||||
|
||||
return {
|
||||
...actual,
|
||||
Storage,
|
||||
};
|
||||
});
|
||||
|
||||
describe('Policy Engine Integration Tests', () => {
|
||||
describe('Policy configuration produces valid PolicyEngine config', () => {
|
||||
it('should create a working PolicyEngine from basic settings', async () => {
|
||||
|
||||
@@ -161,7 +161,6 @@ export function loadTrustedFolders(): LoadedTrustedFolders {
|
||||
const userConfig: Record<string, TrustLevel> = {};
|
||||
|
||||
const userPath = getTrustedFoldersPath();
|
||||
|
||||
// Load user trusted folders
|
||||
try {
|
||||
if (fs.existsSync(userPath)) {
|
||||
|
||||
Reference in New Issue
Block a user