summaryrefslogtreecommitdiff
path: root/integration-tests
diff options
context:
space:
mode:
authorBlackoutta <[email protected]>2025-08-20 08:32:08 +0800
committerGitHub <[email protected]>2025-08-20 00:32:08 +0000
commitd587c6f1042824de7a1ae94eb1ea9c049cfc34c9 (patch)
treef1e42eba699ef032153875dbb0d7ef9bd982fb9b /integration-tests
parent6732665a080a5635368f37da532106edf83b8907 (diff)
Fix IDE Companion Connection in Proxy Environments (#6308)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'integration-tests')
-rw-r--r--integration-tests/ide-client.test.ts47
1 files changed, 44 insertions, 3 deletions
diff --git a/integration-tests/ide-client.test.ts b/integration-tests/ide-client.test.ts
index 310f94f4..630589e4 100644
--- a/integration-tests/ide-client.test.ts
+++ b/integration-tests/ide-client.test.ts
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { describe, it, expect, beforeEach, afterEach } from 'vitest';
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
@@ -35,8 +35,6 @@ describe.skip('IdeClient', () => {
fs.unlinkSync(portFile);
await server.stop();
delete process.env['GEMINI_CLI_IDE_WORKSPACE_PATH'];
- // Reset instance
- IdeClient.instance = undefined;
});
});
@@ -156,3 +154,46 @@ describe.skip('getIdeProcessId', () => {
expect(parseInt(output, 10)).toBe(parentPid);
}, 10000);
});
+
+describe('IdeClient with proxy', () => {
+ let mcpServer: TestMcpServer;
+ let proxyServer: net.Server;
+ let mcpServerPort: number;
+ let proxyServerPort: number;
+
+ beforeEach(async () => {
+ mcpServer = new TestMcpServer();
+ mcpServerPort = await mcpServer.start();
+
+ proxyServer = net.createServer().listen();
+ proxyServerPort = (proxyServer.address() as net.AddressInfo).port;
+
+ vi.stubEnv('GEMINI_CLI_IDE_SERVER_PORT', String(mcpServerPort));
+ vi.stubEnv('TERM_PROGRAM', 'vscode');
+ vi.stubEnv('GEMINI_CLI_IDE_WORKSPACE_PATH', process.cwd());
+
+ // Reset instance
+ IdeClient.instance = undefined;
+ });
+
+ afterEach(async () => {
+ IdeClient.getInstance().disconnect();
+ await mcpServer.stop();
+ proxyServer.close();
+ vi.unstubAllEnvs();
+ });
+
+ it('should connect to IDE server when HTTP_PROXY, HTTPS_PROXY and NO_PROXY are set', async () => {
+ vi.stubEnv('HTTP_PROXY', `http://localhost:${proxyServerPort}`);
+ vi.stubEnv('HTTPS_PROXY', `http://localhost:${proxyServerPort}`);
+ vi.stubEnv('NO_PROXY', 'example.com,127.0.0.1,::1');
+
+ const ideClient = IdeClient.getInstance();
+ await ideClient.connect();
+
+ expect(ideClient.getConnectionStatus()).toEqual({
+ status: 'connected',
+ details: undefined,
+ });
+ });
+});