mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-11 03:46:49 -07:00
69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2026 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
import { WindowsSandboxManager } from './windowsSandboxManager.js';
|
|
import type { SandboxRequest } from './sandboxManager.js';
|
|
|
|
describe('WindowsSandboxManager', () => {
|
|
const manager = new WindowsSandboxManager('win32');
|
|
|
|
it('should prepare a GeminiSandbox.exe command', async () => {
|
|
const req: SandboxRequest = {
|
|
command: 'whoami',
|
|
args: ['/groups'],
|
|
cwd: '/test/cwd',
|
|
env: { TEST_VAR: 'test_value' },
|
|
config: {
|
|
networkAccess: false,
|
|
},
|
|
};
|
|
|
|
const result = await manager.prepareCommand(req);
|
|
|
|
expect(result.program).toContain('GeminiSandbox.exe');
|
|
expect(result.args).toEqual(['0', '/test/cwd', 'whoami', '/groups']);
|
|
});
|
|
|
|
it('should handle networkAccess from config', async () => {
|
|
const req: SandboxRequest = {
|
|
command: 'whoami',
|
|
args: [],
|
|
cwd: '/test/cwd',
|
|
env: {},
|
|
config: {
|
|
networkAccess: true,
|
|
},
|
|
};
|
|
|
|
const result = await manager.prepareCommand(req);
|
|
expect(result.args[0]).toBe('1');
|
|
});
|
|
|
|
it('should sanitize environment variables', async () => {
|
|
const req: SandboxRequest = {
|
|
command: 'test',
|
|
args: [],
|
|
cwd: '/test/cwd',
|
|
env: {
|
|
API_KEY: 'secret',
|
|
PATH: '/usr/bin',
|
|
},
|
|
config: {
|
|
sanitizationConfig: {
|
|
allowedEnvironmentVariables: ['PATH'],
|
|
blockedEnvironmentVariables: ['API_KEY'],
|
|
enableEnvironmentVariableRedaction: true,
|
|
},
|
|
},
|
|
};
|
|
|
|
const result = await manager.prepareCommand(req);
|
|
expect(result.env['PATH']).toBe('/usr/bin');
|
|
expect(result.env['API_KEY']).toBeUndefined();
|
|
});
|
|
});
|