diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/proxy.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/proxy.test.ts index 1537d89dbaa..99c55cc2e4f 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/proxy.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/proxy.test.ts @@ -78,7 +78,7 @@ import assert from 'assert'; } }); - test.skip('basic auth', async () => { + test('basic auth', async () => { const url = 'https://example.com'; // Need to use non-local URL because local URLs are excepted from proxying. const user = 'testuser'; const pass = 'testpassword'; @@ -106,27 +106,19 @@ import assert from 'assert'; await proxyListen; const proxyPort = (sf.server.address() as AddressInfo).port; - for (let i = 0; i < 3; i++) { - await vscode.workspace.getConfiguration().update('integration-test.http.proxy', `PROXY 127.0.0.1:${proxyPort}`, vscode.ConfigurationTarget.Global); - await delay(1000); // Wait for the configuration change to propagate. - try { - await new Promise((resolve, reject) => { - https.get(url, res => { - if (res.statusCode === 418) { - resolve(); - } else { - reject(new Error(`Unexpected status code (expected 418): ${res.statusCode}`)); - } - }) - .on('error', reject); - }); - break; // Exit the loop if the request is successful - } catch (err) { - if (i === 2) { - throw err; // Rethrow the error if it's the last attempt + const change = waitForConfigChange('http.proxy'); + await vscode.workspace.getConfiguration().update('http.proxy', `http://127.0.0.1:${proxyPort}`, vscode.ConfigurationTarget.Global); + await change; + await new Promise((resolve, reject) => { + https.get(url, res => { + if (res.statusCode === 418) { + resolve(); + } else { + reject(new Error(`Unexpected status code (expected 418): ${res.statusCode}`)); } - } - } + }) + .on('error', reject); + }); authEnabled = true; await new Promise((resolve, reject) => { @@ -163,7 +155,9 @@ import assert from 'assert'; } } finally { sf.close(); - await vscode.workspace.getConfiguration().update('integration-test.http.proxy', undefined, vscode.ConfigurationTarget.Global); + const change = waitForConfigChange('http.proxy'); + await vscode.workspace.getConfiguration().update('http.proxy', undefined, vscode.ConfigurationTarget.Global); + await change; await vscode.workspace.getConfiguration().update('integration-test.http.proxyAuth', undefined, vscode.ConfigurationTarget.Global); } }); @@ -212,16 +206,16 @@ import assert from 'assert'; assert.strictEqual(actualRemoteProxy3, ''); assert.strictEqual(actualLocalProxy3, localProxy); assert.strictEqual(actualLocalProxy4, ''); - - function waitForConfigChange(key: string) { - return new Promise(resolve => { - const s = vscode.workspace.onDidChangeConfiguration(e => { - if (e.affectsConfiguration(key)) { - s.dispose(); - resolve(); - } - }); - }); - } }); + + function waitForConfigChange(key: string) { + return new Promise(resolve => { + const s = vscode.workspace.onDidChangeConfiguration(e => { + if (e.affectsConfiguration(key)) { + s.dispose(); + resolve(); + } + }); + }); + } }); diff --git a/src/vs/platform/native/electron-main/nativeHostMainService.ts b/src/vs/platform/native/electron-main/nativeHostMainService.ts index 030b6a27506..b272b583618 100644 --- a/src/vs/platform/native/electron-main/nativeHostMainService.ts +++ b/src/vs/platform/native/electron-main/nativeHostMainService.ts @@ -870,12 +870,6 @@ export class NativeHostMainService extends Disposable implements INativeHostMain //#region Connectivity async resolveProxy(windowId: number | undefined, url: string): Promise { - if (this.environmentMainService.extensionTestsLocationURI) { - const testProxy = this.configurationService.getValue('integration-test.http.proxy'); - if (testProxy) { - return testProxy; - } - } const window = this.codeWindowById(windowId); const session = window?.win?.webContents?.session;