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/src/driver.js b/packages/webdriver-utils/src/driver.js index 1a7877fee..2dc0cbef4 100644 --- a/packages/webdriver-utils/src/driver.js +++ b/packages/webdriver-utils/src/driver.js @@ -1,6 +1,6 @@ import utils from '@percy/sdk-utils'; import Cache from './util/cache.js'; -import { httpsAgent } from './util/utils.js'; +import httpsAgent from './util/utils.js'; const { request } = utils; const log = utils.logger('webdriver-utils:driver'); @@ -15,7 +15,7 @@ export default class Driver { return await Cache.withCache(Cache.caps, this.sessionId, async () => { try { const options = { - // agent: httpsAgent() + agent: httpsAgent() }; const baseUrl = `${this.executorUrl}/session/${this.sessionId}`; const caps = JSON.parse((await request(baseUrl, options)).body); @@ -29,9 +29,9 @@ export default class Driver { async getWindowSize() { const options = { - // agent: httpsAgent() + agent: httpsAgent() }; - const baseUrl = `${this.executForUrl}/session/${this.sessionId}/window/current/size`; + const baseUrl = `${this.executorUrl}/session/${this.sessionId}/window/current/size`; const windowSize = JSON.parse((await request(baseUrl, options)).body); return windowSize; } @@ -55,7 +55,7 @@ export default class Driver { headers: { 'Content-Type': 'application/json;charset=utf-8' }, - // agent: httpsAgent(), + agent: httpsAgent(), body: JSON.stringify(command) }; const baseUrl = `${this.executorUrl}/session/${this.sessionId}/execute/sync`; @@ -65,7 +65,7 @@ export default class Driver { async takeScreenshot() { const options = { - // agent: httpsAgent() + agent: httpsAgent() }; const baseUrl = `${this.executorUrl}/session/${this.sessionId}/screenshot`; const screenShot = JSON.parse((await request(baseUrl, options)).body); @@ -74,7 +74,7 @@ export default class Driver { async rect(elementId) { const options = { - // agent: httpsAgent() + agent: httpsAgent() }; const baseUrl = `${this.executorUrl}/session/${this.sessionId}/element/${elementId}/rect`; const response = JSON.parse((await request(baseUrl, options)).body); @@ -87,7 +87,7 @@ export default class Driver { headers: { 'Content-Type': 'application/json;charset=utf-8' }, - // agent: httpsAgent(), + 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 790b2ea72..d4b055326 100644 --- a/packages/webdriver-utils/src/providers/genericProvider.js +++ b/packages/webdriver-utils/src/providers/genericProvider.js @@ -273,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 index 52b68afb7..d3377c0ca 100644 --- a/packages/webdriver-utils/src/util/utils.js +++ b/packages/webdriver-utils/src/util/utils.js @@ -3,7 +3,7 @@ import https from 'https'; export function httpsAgent() { // return {}; return new https.Agent({ - minVersion: 'TLSv1.1', + minVersion: 'TLSv1.2', maxVersion: 'TLSv1.2' }); }