diff --git a/lerna.json b/lerna.json index 9817131a3..55ce831ef 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "packages": [ "packages/*" ], diff --git a/packages/cli-app/package.json b/packages/cli-app/package.json index c9ecd0370..ef1446910 100644 --- a/packages/cli-app/package.json +++ b/packages/cli-app/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-app", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" @@ -33,7 +33,7 @@ ] }, "dependencies": { - "@percy/cli-command": "1.27.4-beta.1", - "@percy/cli-exec": "1.27.4-beta.1" + "@percy/cli-command": "1.27.5-alpha.0", + "@percy/cli-exec": "1.27.5-alpha.0" } } diff --git a/packages/cli-build/package.json b/packages/cli-build/package.json index 91e4409e8..eb890c62f 100644 --- a/packages/cli-build/package.json +++ b/packages/cli-build/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-build", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" @@ -33,6 +33,6 @@ ] }, "dependencies": { - "@percy/cli-command": "1.27.4-beta.1" + "@percy/cli-command": "1.27.5-alpha.0" } } diff --git a/packages/cli-command/package.json b/packages/cli-command/package.json index a1f918674..37b833930 100644 --- a/packages/cli-command/package.json +++ b/packages/cli-command/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-command", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "files": [ "dist", @@ -36,8 +36,8 @@ "test:coverage": "yarn test --coverage" }, "dependencies": { - "@percy/config": "1.27.4-beta.1", - "@percy/core": "1.27.4-beta.1", - "@percy/logger": "1.27.4-beta.1" + "@percy/config": "1.27.5-alpha.0", + "@percy/core": "1.27.5-alpha.0", + "@percy/logger": "1.27.5-alpha.0" } } diff --git a/packages/cli-config/package.json b/packages/cli-config/package.json index 98c3de78d..7a906b25c 100644 --- a/packages/cli-config/package.json +++ b/packages/cli-config/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-config", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" @@ -33,6 +33,6 @@ ] }, "dependencies": { - "@percy/cli-command": "1.27.4-beta.1" + "@percy/cli-command": "1.27.5-alpha.0" } } diff --git a/packages/cli-exec/package.json b/packages/cli-exec/package.json index 7c4878049..b83c38cdf 100644 --- a/packages/cli-exec/package.json +++ b/packages/cli-exec/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-exec", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" @@ -33,7 +33,7 @@ ] }, "dependencies": { - "@percy/cli-command": "1.27.4-beta.1", + "@percy/cli-command": "1.27.5-alpha.0", "cross-spawn": "^7.0.3", "which": "^2.0.2" } diff --git a/packages/cli-snapshot/package.json b/packages/cli-snapshot/package.json index 262f39d61..e7452408d 100644 --- a/packages/cli-snapshot/package.json +++ b/packages/cli-snapshot/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-snapshot", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" @@ -33,7 +33,7 @@ ] }, "dependencies": { - "@percy/cli-command": "1.27.4-beta.1", + "@percy/cli-command": "1.27.5-alpha.0", "yaml": "^2.0.0" } } diff --git a/packages/cli-upload/package.json b/packages/cli-upload/package.json index f4296b533..830a4185b 100644 --- a/packages/cli-upload/package.json +++ b/packages/cli-upload/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-upload", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" @@ -33,7 +33,7 @@ ] }, "dependencies": { - "@percy/cli-command": "1.27.4-beta.1", + "@percy/cli-command": "1.27.5-alpha.0", "fast-glob": "^3.2.11", "image-size": "^1.0.0" } diff --git a/packages/cli/package.json b/packages/cli/package.json index 4c1014e0e..f2d1b01f9 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "files": [ "bin", @@ -31,14 +31,14 @@ "test:coverage": "yarn test --coverage" }, "dependencies": { - "@percy/cli-app": "1.27.4-beta.1", - "@percy/cli-build": "1.27.4-beta.1", - "@percy/cli-command": "1.27.4-beta.1", - "@percy/cli-config": "1.27.4-beta.1", - "@percy/cli-exec": "1.27.4-beta.1", - "@percy/cli-snapshot": "1.27.4-beta.1", - "@percy/cli-upload": "1.27.4-beta.1", - "@percy/client": "1.27.4-beta.1", - "@percy/logger": "1.27.4-beta.1" + "@percy/cli-app": "1.27.5-alpha.0", + "@percy/cli-build": "1.27.5-alpha.0", + "@percy/cli-command": "1.27.5-alpha.0", + "@percy/cli-config": "1.27.5-alpha.0", + "@percy/cli-exec": "1.27.5-alpha.0", + "@percy/cli-snapshot": "1.27.5-alpha.0", + "@percy/cli-upload": "1.27.5-alpha.0", + "@percy/client": "1.27.5-alpha.0", + "@percy/logger": "1.27.5-alpha.0" } } diff --git a/packages/client/package.json b/packages/client/package.json index dfaa9b0db..e59583ae0 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@percy/client", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" @@ -32,7 +32,7 @@ "test:coverage": "yarn test --coverage" }, "dependencies": { - "@percy/env": "1.27.4-beta.1", - "@percy/logger": "1.27.4-beta.1" + "@percy/env": "1.27.5-alpha.0", + "@percy/logger": "1.27.5-alpha.0" } } diff --git a/packages/config/package.json b/packages/config/package.json index 3cb64344b..b427ae84a 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@percy/config", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" @@ -38,7 +38,7 @@ "test:types": "tsd" }, "dependencies": { - "@percy/logger": "1.27.4-beta.1", + "@percy/logger": "1.27.5-alpha.0", "ajv": "^8.6.2", "cosmiconfig": "^8.0.0", "yaml": "^2.0.0" diff --git a/packages/core/package.json b/packages/core/package.json index 1ca9c5547..a5cccc815 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@percy/core", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" @@ -43,11 +43,11 @@ "test:types": "tsd" }, "dependencies": { - "@percy/client": "1.27.4-beta.1", - "@percy/config": "1.27.4-beta.1", - "@percy/dom": "1.27.4-beta.1", - "@percy/logger": "1.27.4-beta.1", - "@percy/webdriver-utils": "1.27.4-beta.1", + "@percy/client": "1.27.5-alpha.0", + "@percy/config": "1.27.5-alpha.0", + "@percy/dom": "1.27.5-alpha.0", + "@percy/logger": "1.27.5-alpha.0", + "@percy/webdriver-utils": "1.27.5-alpha.0", "content-disposition": "^0.5.4", "cross-spawn": "^7.0.3", "extract-zip": "^2.0.1", diff --git a/packages/dom/package.json b/packages/dom/package.json index d5567bee4..1b89a7d5a 100644 --- a/packages/dom/package.json +++ b/packages/dom/package.json @@ -1,6 +1,6 @@ { "name": "@percy/dom", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "main": "dist/bundle.js", "browser": "dist/bundle.js", diff --git a/packages/env/package.json b/packages/env/package.json index 8fa54c050..2f16fe41a 100644 --- a/packages/env/package.json +++ b/packages/env/package.json @@ -1,6 +1,6 @@ { "name": "@percy/env", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" @@ -32,6 +32,6 @@ "test:coverage": "yarn test --coverage" }, "dependencies": { - "@percy/logger": "1.27.4-beta.1" + "@percy/logger": "1.27.5-alpha.0" } } diff --git a/packages/logger/package.json b/packages/logger/package.json index 58e5d4462..af06cc171 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -1,6 +1,6 @@ { "name": "@percy/logger", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" diff --git a/packages/sdk-utils/package.json b/packages/sdk-utils/package.json index 1b512a39c..d5d0097d0 100644 --- a/packages/sdk-utils/package.json +++ b/packages/sdk-utils/package.json @@ -1,6 +1,6 @@ { "name": "@percy/sdk-utils", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" diff --git a/packages/sdk-utils/src/request.js b/packages/sdk-utils/src/request.js index 19be18213..01c3f5ef7 100644 --- a/packages/sdk-utils/src/request.js +++ b/packages/sdk-utils/src/request.js @@ -1,4 +1,5 @@ import percy from './percy-info.js'; +import logger from './logger.js'; // Helper to send a request to the local CLI API export async function request(path, options = {}) { @@ -53,6 +54,9 @@ if (process.env.__PERCY_BROWSERIFIED__) { // rollup throws error for -> await import(protocol === 'https:' ? 'https' : 'http') let { default: http } = protocol === 'https:' ? await import('https') : await import('http'); + const log = logger('request'); + log.debug(`Request object for url: ${url},\nRequest object: ${JSON.stringify(options)}`); + return new Promise((resolve, reject) => { http.request(url, options) .on('response', response => { diff --git a/packages/webdriver-utils/package.json b/packages/webdriver-utils/package.json index d361ef6e1..892838b52 100644 --- a/packages/webdriver-utils/package.json +++ b/packages/webdriver-utils/package.json @@ -1,6 +1,6 @@ { "name": "@percy/webdriver-utils", - "version": "1.27.4-beta.1", + "version": "1.27.5-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -9,7 +9,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "alpha" }, "engines": { "node": ">=14" @@ -29,7 +29,7 @@ "test:coverage": "yarn test --coverage" }, "dependencies": { - "@percy/config": "1.27.4-beta.1", - "@percy/sdk-utils": "1.27.4-beta.1" + "@percy/config": "1.27.5-alpha.0", + "@percy/sdk-utils": "1.27.5-alpha.0" } } diff --git a/packages/webdriver-utils/src/driver.js b/packages/webdriver-utils/src/driver.js index 950720173..2dc0cbef4 100644 --- a/packages/webdriver-utils/src/driver.js +++ b/packages/webdriver-utils/src/driver.js @@ -1,5 +1,6 @@ import utils from '@percy/sdk-utils'; import Cache from './util/cache.js'; +import httpsAgent from './util/utils.js'; const { request } = utils; const log = utils.logger('webdriver-utils:driver'); @@ -13,8 +14,11 @@ export default class Driver { async getCapabilites() { return await Cache.withCache(Cache.caps, this.sessionId, async () => { try { + const options = { + agent: httpsAgent() + }; const baseUrl = `${this.executorUrl}/session/${this.sessionId}`; - const caps = JSON.parse((await request(baseUrl)).body); + const caps = JSON.parse((await request(baseUrl, options)).body); return caps.value; } catch (err) { log.warn(`Falling back to legacy protocol, Error: ${err.message}`); @@ -24,8 +28,11 @@ export default class Driver { } async getWindowSize() { + const options = { + agent: httpsAgent() + }; const baseUrl = `${this.executorUrl}/session/${this.sessionId}/window/current/size`; - const windowSize = JSON.parse((await request(baseUrl)).body); + const windowSize = JSON.parse((await request(baseUrl, options)).body); return windowSize; } @@ -48,6 +55,7 @@ export default class Driver { headers: { 'Content-Type': 'application/json;charset=utf-8' }, + agent: httpsAgent(), body: JSON.stringify(command) }; const baseUrl = `${this.executorUrl}/session/${this.sessionId}/execute/sync`; @@ -56,14 +64,20 @@ export default class Driver { } async takeScreenshot() { + const options = { + agent: httpsAgent() + }; const baseUrl = `${this.executorUrl}/session/${this.sessionId}/screenshot`; - const screenShot = JSON.parse((await request(baseUrl)).body); + const screenShot = JSON.parse((await request(baseUrl, options)).body); return screenShot.value; } async rect(elementId) { + const options = { + agent: httpsAgent() + }; const baseUrl = `${this.executorUrl}/session/${this.sessionId}/element/${elementId}/rect`; - const response = JSON.parse((await request(baseUrl)).body); + const response = JSON.parse((await request(baseUrl, options)).body); return response.value; } @@ -73,6 +87,7 @@ export default class Driver { headers: { 'Content-Type': 'application/json;charset=utf-8' }, + agent: httpsAgent(), body: JSON.stringify({ using, value }) }; const baseUrl = `${this.executorUrl}/session/${this.sessionId}/element`; diff --git a/packages/webdriver-utils/src/providers/genericProvider.js b/packages/webdriver-utils/src/providers/genericProvider.js index bacf51903..d4b055326 100644 --- a/packages/webdriver-utils/src/providers/genericProvider.js +++ b/packages/webdriver-utils/src/providers/genericProvider.js @@ -4,6 +4,7 @@ import MetaDataResolver from '../metadata/metaDataResolver.js'; import Tile from '../util/tile.js'; import Driver from '../driver.js'; import Cache from '../util/cache.js'; +import httpsAgent from '../util/utils.js'; const { request } = utils; const DEVICES_CONFIG_URL = 'https://storage.googleapis.com/percy-utils/devices.json'; @@ -272,7 +273,7 @@ export default class GenericProvider { async getHeaderFooter(deviceName, osVersion, browserName) { // passing 0 as key, since across different pages and tests, this config will remain same const devicesConfig = await Cache.withCache(Cache.devicesConfig, 0, async () => { - return (await request(DEVICES_CONFIG_URL)).body; + return (await request(DEVICES_CONFIG_URL, httpsAgent())).body; }); let deviceKey = `${deviceName}-${osVersion}`; return devicesConfig[deviceKey] diff --git a/packages/webdriver-utils/src/util/utils.js b/packages/webdriver-utils/src/util/utils.js new file mode 100644 index 000000000..9cbeca94b --- /dev/null +++ b/packages/webdriver-utils/src/util/utils.js @@ -0,0 +1,10 @@ +import https from 'https'; + +export function httpsAgent() { + return new https.Agent({ + minVersion: 'TLSv1.2', + maxVersion: 'TLSv1.2' + }); +} + +export default httpsAgent; diff --git a/packages/webdriver-utils/test/driver.test.js b/packages/webdriver-utils/test/driver.test.js index 6f513e2b6..e25c3d5bf 100644 --- a/packages/webdriver-utils/test/driver.test.js +++ b/packages/webdriver-utils/test/driver.test.js @@ -33,7 +33,10 @@ describe('Driver', () => { describe('getCapabilities', () => { it('calls requests', async () => { let res = await driver.getCapabilites(); - expect(requestSpy).toHaveBeenCalledOnceWith(`${executorUrl}/session/${sessionId}`, Object({})); + expect(requestSpy).toHaveBeenCalledWith( + `${executorUrl}/session/${sessionId}`, + { agent: jasmine.any(Object) } + ); expect(res).toBe('mockVal'); }); }); @@ -56,7 +59,9 @@ describe('Driver', () => { it('falls back to passed capabilites', async () => { let res = await newDriver.getCapabilites(); - expect(requestFailedSpy).toHaveBeenCalledOnceWith(`${executorUrl}/session/${sessionId}`, Object({})); + expect(requestFailedSpy).toHaveBeenCalledOnceWith(`${executorUrl}/session/${sessionId}`, + { agent: jasmine.any(Object) } + ); expect(res).toBe(passedCapabilities); }); }); @@ -66,7 +71,7 @@ describe('Driver', () => { let res = await driver.getWindowSize(); expect(requestSpy).toHaveBeenCalledOnceWith( `${executorUrl}/session/${sessionId}/window/current/size`, - Object({})); + { agent: jasmine.any(Object) }); expect(res).toEqual({ value: 'mockVal' }); }); }); @@ -83,7 +88,8 @@ describe('Driver', () => { headers: { 'Content-Type': 'application/json;charset=utf-8' }, - body: JSON.stringify(command) + body: JSON.stringify(command), + agent: jasmine.any(Object) } ); expect(res).toEqual({ value: 'mockVal' }); @@ -100,7 +106,8 @@ describe('Driver', () => { headers: { 'Content-Type': 'application/json;charset=utf-8' }, - body: JSON.stringify(command) + body: JSON.stringify(command), + agent: jasmine.any(Object) } ); expect(res).toEqual({ value: 'mockVal' }); @@ -119,7 +126,7 @@ describe('Driver', () => { let res = await driver.takeScreenshot(); expect(requestSpy).toHaveBeenCalledOnceWith( `${executorUrl}/session/${sessionId}/screenshot`, - Object({})); + { agent: jasmine.any(Object) }); expect(res).toEqual('mockVal'); }); }); @@ -136,7 +143,8 @@ describe('Driver', () => { headers: { 'Content-Type': 'application/json;charset=utf-8' }, - body: JSON.stringify({ using, value: value }) + body: JSON.stringify({ using, value: value }), + agent: jasmine.any(Object) } ); expect(res).toEqual('mockVal'); @@ -157,7 +165,7 @@ describe('Driver', () => { let res = await driver.rect(elementId); expect(requestSpy).toHaveBeenCalledOnceWith( `${executorUrl}/session/${sessionId}/element/${elementId}/rect`, - Object({})); + { agent: jasmine.any(Object) }); expect(res).toEqual('mockVal'); }); });