Local and remote proxy settings (microsoft/vscode-copilot-release#3821)

This commit is contained in:
Christof Marti
2025-01-15 19:18:34 +01:00
parent 4d44668917
commit 118e6f5373
15 changed files with 237 additions and 124 deletions

View File

@@ -11,6 +11,7 @@ import { AddressInfo } from 'net';
import { resetCaches } from '@vscode/proxy-agent';
import * as vscode from 'vscode';
import { middleware, Straightforward } from 'straightforward';
import assert from 'assert';
(vscode.env.uiKind === vscode.UIKind.Web ? suite.skip : suite)('vscode API - network proxy support', () => {
@@ -166,4 +167,61 @@ import { middleware, Straightforward } from 'straightforward';
await vscode.workspace.getConfiguration().update('integration-test.http.proxyAuth', undefined, vscode.ConfigurationTarget.Global);
}
});
(vscode.env.remoteName ? test : test.skip)('separate local / remote proxy settings', async () => {
// Assumes test resolver runs with `--use-host-proxy`.
const localProxy = 'http://localhost:1234';
const remoteProxy = 'http://localhost:4321';
const actualLocalProxy1 = vscode.workspace.getConfiguration().get('http.proxy');
const p1 = waitForConfigChange('http.proxy');
await vscode.workspace.getConfiguration().update('http.proxy', localProxy, vscode.ConfigurationTarget.Global);
await p1;
const actualLocalProxy2 = vscode.workspace.getConfiguration().get('http.proxy');
const p2 = waitForConfigChange('http.useLocalProxyConfiguration');
await vscode.workspace.getConfiguration().update('http.useLocalProxyConfiguration', false, vscode.ConfigurationTarget.Global);
await p2;
const actualRemoteProxy1 = vscode.workspace.getConfiguration().get('http.proxy');
const p3 = waitForConfigChange('http.proxy');
await vscode.workspace.getConfiguration().update('http.proxy', remoteProxy, vscode.ConfigurationTarget.Global);
await p3;
const actualRemoteProxy2 = vscode.workspace.getConfiguration().get('http.proxy');
const p4 = waitForConfigChange('http.proxy');
await vscode.workspace.getConfiguration().update('http.proxy', undefined, vscode.ConfigurationTarget.Global);
await p4;
const actualRemoteProxy3 = vscode.workspace.getConfiguration().get('http.proxy');
const p5 = waitForConfigChange('http.proxy');
await vscode.workspace.getConfiguration().update('http.useLocalProxyConfiguration', true, vscode.ConfigurationTarget.Global);
await p5;
const actualLocalProxy3 = vscode.workspace.getConfiguration().get('http.proxy');
const p6 = waitForConfigChange('http.proxy');
await vscode.workspace.getConfiguration().update('http.proxy', undefined, vscode.ConfigurationTarget.Global);
await p6;
const actualLocalProxy4 = vscode.workspace.getConfiguration().get('http.proxy');
assert.strictEqual(actualLocalProxy1, '');
assert.strictEqual(actualLocalProxy2, localProxy);
assert.strictEqual(actualRemoteProxy1, '');
assert.strictEqual(actualRemoteProxy2, remoteProxy);
assert.strictEqual(actualRemoteProxy3, '');
assert.strictEqual(actualLocalProxy3, localProxy);
assert.strictEqual(actualLocalProxy4, '');
function waitForConfigChange(key: string) {
return new Promise<void>(resolve => {
const s = vscode.workspace.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(key)) {
s.dispose();
resolve();
}
});
});
}
});
});