diff --git a/azure-pipelines/publish.yml b/azure-pipelines/publish.yml index 26a3e70..bed23e9 100644 --- a/azure-pipelines/publish.yml +++ b/azure-pipelines/publish.yml @@ -4,7 +4,10 @@ trigger: branches: include: - main -pr: none + +pr: +- main +- release/* resources: repositories: @@ -31,6 +34,25 @@ extends: displayName: Install dependencies - script: npm run compile displayName: Compile - - testPlatforms: {} + + testPlatforms: + - name: Linux + nodeVersions: + - 20.x + + testSteps: + - script: npm ci + displayName: Install dependencies + - script: npm run compile + displayName: Compile + - script: docker run --rm -v `pwd`/..:/repo -w /repo/tests/test-client node:20 npm i + workingDirectory: tests + displayName: Install test dependencies + - script: docker ps -a -q | xargs docker rm -f && docker compose run test-direct-client + workingDirectory: tests + displayName: Test direct client + - script: docker ps -a -q | xargs docker rm -f && docker compose run test-proxy-client + workingDirectory: tests + displayName: Test proxy client + publishPackage: ${{ parameters.publishPackage }} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4d7aaa5..5aae90b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@vscode/proxy-agent", - "version": "0.26.0", + "version": "0.27.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@vscode/proxy-agent", - "version": "0.26.0", + "version": "0.27.0", "license": "MIT", "dependencies": { "@tootallnate/once": "^3.0.0", diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 65459d5..9dfb273 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -8,14 +8,11 @@ services: networks: - test-servers working_dir: /repo/tests/test-client - environment: - - MOCHA_TESTS=src/direct.test.ts src/tls.test.ts src/socket.test.ts - command: /bin/sh -c 'rm -rf /root/.npm && npm run test:watch' + command: /bin/sh -c 'rm -rf /root/.npm && npm run test src/direct.test.ts src/tls.test.ts src/socket.test.ts' depends_on: test-https-server: condition: service_healthy test-proxy-client: - image: test-proxy-client:latest build: test-proxy-client volumes: - ..:/repo @@ -23,15 +20,13 @@ services: networks: - test-proxies working_dir: /repo/tests/test-client - environment: - - MOCHA_TESTS=src/proxy.test.ts command: /bin/sh -c ' while [ ! -f /root/.mitmproxy/mitmproxy-ca-cert.pem ]; do sleep 1; done && cp /root/.mitmproxy/mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/mitmproxy.crt && update-ca-certificates && /usr/local/bin/configure-kerberos-client.sh && rm -rf /root/.npm && - npm run test:watch' + npm run test src/proxy.test.ts' depends_on: test-http-proxy: condition: service_started @@ -52,7 +47,6 @@ services: test-https-server: condition: service_healthy test-http-auth-proxy: - image: test-http-auth-proxy:latest build: test-http-auth-proxy networks: - test-proxies @@ -63,7 +57,6 @@ services: test-https-server: condition: service_healthy test-http-kerberos-proxy: - image: test-http-kerberos-proxy:latest build: test-http-kerberos-proxy container_name: test-http-kerberos-proxy # needs to be configured to have a static name for the kerberos server hostname networks: @@ -90,7 +83,6 @@ services: test-https-server: condition: service_healthy test-https-server: - image: test-https-server:latest build: test-https-server volumes: - ./test-https-server:/etc/nginx diff --git a/tests/test-client/package.json b/tests/test-client/package.json index 83aa345..43997e9 100644 --- a/tests/test-client/package.json +++ b/tests/test-client/package.json @@ -4,8 +4,7 @@ "description": "", "main": "test.js", "scripts": { - "test": "mocha -r ts-node/register $MOCHA_TESTS", - "test:watch": "npm test -- -w --watch-extensions ts" + "test": "mocha -r ts-node/register --exit" }, "keywords": [], "author": "", diff --git a/tests/test-client/src/proxy.test.ts b/tests/test-client/src/proxy.test.ts index a928b19..dc0073d 100644 --- a/tests/test-client/src/proxy.test.ts +++ b/tests/test-client/src/proxy.test.ts @@ -5,7 +5,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as vpa from '../../..'; import { createPacProxyAgent } from '../../../src/agent'; -import { testRequest, ca, unusedCa, proxiedProxyAgentParamsV1, tlsProxiedProxyAgentParamsV1 } from './utils'; +import { testRequest, ca, unusedCa, proxiedProxyAgentParamsV1, tlsProxiedProxyAgentParamsV1, log } from './utils'; describe('Proxied client', function () { it('should use HTTP proxy for HTTPS connection', function () { @@ -126,7 +126,6 @@ describe('Proxied client', function () { if (proxyAuthenticate) { assert.strictEqual(proxyAuthenticate, 'Negotiate'); } - const log = { ...console, trace: console.log }; return lookupProxyAuthorization(log, log, proxyAuthenticateCache, true, proxyURL, proxyAuthenticate, state); }, }), @@ -188,7 +187,7 @@ describe('Proxied client', function () { const params = { ...proxiedProxyAgentParamsV1, loadAdditionalCertificates: async () => [ - ...await vpa.loadSystemCertificates({ log: console }), + ...await vpa.loadSystemCertificates({ log }), ], }; const { resolveProxyWithRequest: resolveProxy } = vpa.createProxyResolver(params); @@ -279,7 +278,7 @@ function sendTelemetry(mainThreadTelemetry: Console, authenticate: string[], isR } telemetrySent = true; - mainThreadTelemetry.log('proxyAuthenticationRequest', { + mainThreadTelemetry.debug('proxyAuthenticationRequest', { authenticationType: authenticate.map(a => a.split(' ')[0]).join(','), extensionHostType: isRemote ? 'remote' : 'local', }); diff --git a/tests/test-client/src/utils.ts b/tests/test-client/src/utils.ts index bd4036e..2621099 100644 --- a/tests/test-client/src/utils.ts +++ b/tests/test-client/src/utils.ts @@ -7,6 +7,8 @@ import * as assert from 'assert'; import * as vpa from '../../..'; import { loadSystemCertificates } from '../../../src'; +export const log = { ...console, debug: () => {}, trace: () => {} }; + export const ca = [ fs.readFileSync(path.join(__dirname, '../../test-https-server/ssl_cert.pem')).toString(), fs.readFileSync(path.join(__dirname, '../../test-https-server/ssl_teapot_cert.pem')).toString(), @@ -21,12 +23,12 @@ export const directProxyAgentParams: vpa.ProxyAgentParams = { isAdditionalFetchSupportEnabled: () => true, addCertificatesV1: () => false, addCertificatesV2: () => true, - log: console, + log, getLogLevel: () => vpa.LogLevel.Trace, proxyResolveTelemetry: () => undefined, useHostProxy: true, loadAdditionalCertificates: async () => [ - ...await loadSystemCertificates({ log: console }), + ...await loadSystemCertificates({ log }), ...ca, ], env: {}, @@ -80,6 +82,9 @@ export async function testRequest(client: reject(err); } }); + res.on('error', err => { + reject(err); + }); }); req.on('error', err => { reject(err);