From e436faaa3e4fcbe1626635b11e3ba00f417cc1df Mon Sep 17 00:00:00 2001 From: Dan Slov Date: Thu, 8 Aug 2024 12:00:42 -0700 Subject: [PATCH 1/2] us-east-1 is not supported (#243) --- apis/builds.json | 2 +- apis/sauce.json | 2 +- apis/teamManagement.json | 2 +- scripts/constants.js | 2 +- src/constants.js | 2 +- src/utils.js | 9 ++------- tests/index.test.js | 10 ---------- tests/utils.test.js | 17 ++++------------- 8 files changed, 11 insertions(+), 35 deletions(-) diff --git a/apis/builds.json b/apis/builds.json index 1af35767..7b3eec52 100644 --- a/apis/builds.json +++ b/apis/builds.json @@ -13,7 +13,7 @@ "region": { "default": "us-west-1", "description": "region of datacenter", - "enum": ["us-west-1", "us-east-1", "eu-central-1", "staging"] + "enum": ["us-west-1", "us-east-4", "eu-central-1", "staging"] }, "tld": { "default": "com", diff --git a/apis/sauce.json b/apis/sauce.json index 8c9d1490..063129c1 100644 --- a/apis/sauce.json +++ b/apis/sauce.json @@ -24,7 +24,7 @@ "region": { "default": "us-west-1", "description": "region of datacenter", - "enum": ["us-west-1", "us-east-1", "eu-central-1", "staging"] + "enum": ["us-west-1", "us-east-4", "eu-central-1", "staging"] }, "tld": { "default": "com", diff --git a/apis/teamManagement.json b/apis/teamManagement.json index 27e5eab8..0a1f97fd 100644 --- a/apis/teamManagement.json +++ b/apis/teamManagement.json @@ -13,7 +13,7 @@ "region": { "default": "us-west-1", "description": "region of datacenter", - "enum": ["us-west-1", "us-east-1", "eu-central-1", "staging"] + "enum": ["us-west-1", "us-east-4", "eu-central-1", "staging"] }, "tld": { "default": "com", diff --git a/scripts/constants.js b/scripts/constants.js index 449f15c6..9a94366e 100644 --- a/scripts/constants.js +++ b/scripts/constants.js @@ -25,7 +25,7 @@ export interface SauceLabsOptions { * * - us-west-1 (short 'us') * - eu-central-1 (short 'eu') - * - us-east-1 (headless) + * - us-east-4 */ region?: ${regions}; /** diff --git a/src/constants.js b/src/constants.js index c74e5235..de7a8c4f 100644 --- a/src/constants.js +++ b/src/constants.js @@ -97,7 +97,7 @@ export const ASSET_REGION_MAPPING = { us: '', eu: 'eu-central-1.', 'us-west-1': '', - 'us-east-1': 'us-east-1.', + 'us-east-4': 'us-east-4.', 'eu-central-1': 'eu-central-1.', staging: 'staging.', }; diff --git a/src/utils.js b/src/utils.js index 711fc159..c69babd4 100644 --- a/src/utils.js +++ b/src/utils.js @@ -37,7 +37,6 @@ export function getRegionSubDomain(options = {}) { if (options.region === 'us') region = 'us-west-1'; if (options.region === 'eu') region = 'eu-central-1'; - if (options.headless) region = 'us-east-1'; return region; } @@ -46,7 +45,7 @@ export function getRegionSubDomain(options = {}) { * @param {string} servers OpenAPI spec servers property * @param {string} basePath OpenAPI spec base path * @param {object} options client options - * @return {string} endpoint base url (e.g. `https://us-east1.headless.saucelabs.com`) + * @return {string} endpoint base url (e.g. `https://api.us-east-4.saucelabs.com`) */ export function getAPIHost(servers, basePath, options) { /** @@ -86,14 +85,10 @@ export function getAPIHost(servers, basePath, options) { * helper to generate host for assets, like: * https://assets.saucelabs.com/jobs//selenium-server.log * https://assets.eu-central-1.saucelabs.com/jobs//log.json - * https://assets.us-east-1.saucelabs.com/jobs//log.json + * https://assets.us-east-4.saucelabs.com/jobs//log.json * https://assets.staging.saucelabs.net/jobs//log.json */ export function getAssetHost(options) { - if (options.headless) { - options.region = 'us-east-1'; - } - if (options.region === 'staging') { options.tld = options.tld || 'net'; } diff --git a/tests/index.test.js b/tests/index.test.js index afc0ff00..98cea9ba 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -79,16 +79,6 @@ test('should expose a webdriverEndpoint', () => { 'https://ondemand.eu-central-1.saucelabs.com/' ); - const api3 = new SauceLabs({ - user: 'foo', - key: 'bar', - region: 'eu', - headless: true, - }); - expect(api3.webdriverEndpoint).toBe( - 'https://ondemand.us-east-1.saucelabs.com/' - ); - const api4 = new SauceLabs({user: 'foo', key: 'bar', region: 'us-central-3'}); expect(api4.webdriverEndpoint).toBe( 'https://ondemand.us-central-3.saucelabs.com/' diff --git a/tests/utils.test.js b/tests/utils.test.js index 4296d8f4..65344172 100644 --- a/tests/utils.test.js +++ b/tests/utils.test.js @@ -40,14 +40,8 @@ test('getAPIHost', () => { getAPIHost(sauceAPI.servers, sauceAPI.basePath, {region: 'us-west-1'}) ).toBe('https://api.us-west-1.saucelabs.com/rest'); expect( - getAPIHost(sauceAPI.servers, sauceAPI.basePath, {region: 'us-east-1'}) - ).toBe('https://api.us-east-1.saucelabs.com/rest'); - expect( - getAPIHost(sauceAPI.servers, sauceAPI.basePath, { - region: 'us-west-1', - headless: true, - }) - ).toBe('https://api.us-east-1.saucelabs.com/rest'); + getAPIHost(sauceAPI.servers, sauceAPI.basePath, {region: 'us-east-4'}) + ).toBe('https://api.us-east-4.saucelabs.com/rest'); expect( getAPIHost(sauceAPI.servers, sauceAPI.basePath, {host: 'http://foobar.com'}) ).toBe('http://foobar.com/rest'); @@ -91,11 +85,8 @@ test('getAssetHost', () => { expect(getAssetHost({region: 'eu-central-1'})).toBe( 'https://assets.eu-central-1.saucelabs.com' ); - expect(getAssetHost({headless: true})).toBe( - 'https://assets.us-east-1.saucelabs.com' - ); - expect(getAssetHost({headless: true, region: 'eu'})).toBe( - 'https://assets.us-east-1.saucelabs.com' + expect(getAssetHost({region: 'us-east-4'})).toBe( + 'https://assets.us-east-4.saucelabs.com' ); expect(getAssetHost({region: 'staging'})).toBe( 'https://assets.staging.saucelabs.net' From f2d65fa7f3831e196aba172291b7cc31d3a5ee16 Mon Sep 17 00:00:00 2001 From: Dan Slov Date: Thu, 8 Aug 2024 12:09:40 -0700 Subject: [PATCH 2/2] Revert "us-east-1 is not supported (#243)" (#247) This reverts commit e436faaa3e4fcbe1626635b11e3ba00f417cc1df. --- apis/builds.json | 2 +- apis/sauce.json | 2 +- apis/teamManagement.json | 2 +- scripts/constants.js | 2 +- src/constants.js | 2 +- src/utils.js | 9 +++++++-- tests/index.test.js | 10 ++++++++++ tests/utils.test.js | 17 +++++++++++++---- 8 files changed, 35 insertions(+), 11 deletions(-) diff --git a/apis/builds.json b/apis/builds.json index 7b3eec52..1af35767 100644 --- a/apis/builds.json +++ b/apis/builds.json @@ -13,7 +13,7 @@ "region": { "default": "us-west-1", "description": "region of datacenter", - "enum": ["us-west-1", "us-east-4", "eu-central-1", "staging"] + "enum": ["us-west-1", "us-east-1", "eu-central-1", "staging"] }, "tld": { "default": "com", diff --git a/apis/sauce.json b/apis/sauce.json index 063129c1..8c9d1490 100644 --- a/apis/sauce.json +++ b/apis/sauce.json @@ -24,7 +24,7 @@ "region": { "default": "us-west-1", "description": "region of datacenter", - "enum": ["us-west-1", "us-east-4", "eu-central-1", "staging"] + "enum": ["us-west-1", "us-east-1", "eu-central-1", "staging"] }, "tld": { "default": "com", diff --git a/apis/teamManagement.json b/apis/teamManagement.json index 0a1f97fd..27e5eab8 100644 --- a/apis/teamManagement.json +++ b/apis/teamManagement.json @@ -13,7 +13,7 @@ "region": { "default": "us-west-1", "description": "region of datacenter", - "enum": ["us-west-1", "us-east-4", "eu-central-1", "staging"] + "enum": ["us-west-1", "us-east-1", "eu-central-1", "staging"] }, "tld": { "default": "com", diff --git a/scripts/constants.js b/scripts/constants.js index 9a94366e..449f15c6 100644 --- a/scripts/constants.js +++ b/scripts/constants.js @@ -25,7 +25,7 @@ export interface SauceLabsOptions { * * - us-west-1 (short 'us') * - eu-central-1 (short 'eu') - * - us-east-4 + * - us-east-1 (headless) */ region?: ${regions}; /** diff --git a/src/constants.js b/src/constants.js index de7a8c4f..c74e5235 100644 --- a/src/constants.js +++ b/src/constants.js @@ -97,7 +97,7 @@ export const ASSET_REGION_MAPPING = { us: '', eu: 'eu-central-1.', 'us-west-1': '', - 'us-east-4': 'us-east-4.', + 'us-east-1': 'us-east-1.', 'eu-central-1': 'eu-central-1.', staging: 'staging.', }; diff --git a/src/utils.js b/src/utils.js index c69babd4..711fc159 100644 --- a/src/utils.js +++ b/src/utils.js @@ -37,6 +37,7 @@ export function getRegionSubDomain(options = {}) { if (options.region === 'us') region = 'us-west-1'; if (options.region === 'eu') region = 'eu-central-1'; + if (options.headless) region = 'us-east-1'; return region; } @@ -45,7 +46,7 @@ export function getRegionSubDomain(options = {}) { * @param {string} servers OpenAPI spec servers property * @param {string} basePath OpenAPI spec base path * @param {object} options client options - * @return {string} endpoint base url (e.g. `https://api.us-east-4.saucelabs.com`) + * @return {string} endpoint base url (e.g. `https://us-east1.headless.saucelabs.com`) */ export function getAPIHost(servers, basePath, options) { /** @@ -85,10 +86,14 @@ export function getAPIHost(servers, basePath, options) { * helper to generate host for assets, like: * https://assets.saucelabs.com/jobs//selenium-server.log * https://assets.eu-central-1.saucelabs.com/jobs//log.json - * https://assets.us-east-4.saucelabs.com/jobs//log.json + * https://assets.us-east-1.saucelabs.com/jobs//log.json * https://assets.staging.saucelabs.net/jobs//log.json */ export function getAssetHost(options) { + if (options.headless) { + options.region = 'us-east-1'; + } + if (options.region === 'staging') { options.tld = options.tld || 'net'; } diff --git a/tests/index.test.js b/tests/index.test.js index 98cea9ba..afc0ff00 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -79,6 +79,16 @@ test('should expose a webdriverEndpoint', () => { 'https://ondemand.eu-central-1.saucelabs.com/' ); + const api3 = new SauceLabs({ + user: 'foo', + key: 'bar', + region: 'eu', + headless: true, + }); + expect(api3.webdriverEndpoint).toBe( + 'https://ondemand.us-east-1.saucelabs.com/' + ); + const api4 = new SauceLabs({user: 'foo', key: 'bar', region: 'us-central-3'}); expect(api4.webdriverEndpoint).toBe( 'https://ondemand.us-central-3.saucelabs.com/' diff --git a/tests/utils.test.js b/tests/utils.test.js index 65344172..4296d8f4 100644 --- a/tests/utils.test.js +++ b/tests/utils.test.js @@ -40,8 +40,14 @@ test('getAPIHost', () => { getAPIHost(sauceAPI.servers, sauceAPI.basePath, {region: 'us-west-1'}) ).toBe('https://api.us-west-1.saucelabs.com/rest'); expect( - getAPIHost(sauceAPI.servers, sauceAPI.basePath, {region: 'us-east-4'}) - ).toBe('https://api.us-east-4.saucelabs.com/rest'); + getAPIHost(sauceAPI.servers, sauceAPI.basePath, {region: 'us-east-1'}) + ).toBe('https://api.us-east-1.saucelabs.com/rest'); + expect( + getAPIHost(sauceAPI.servers, sauceAPI.basePath, { + region: 'us-west-1', + headless: true, + }) + ).toBe('https://api.us-east-1.saucelabs.com/rest'); expect( getAPIHost(sauceAPI.servers, sauceAPI.basePath, {host: 'http://foobar.com'}) ).toBe('http://foobar.com/rest'); @@ -85,8 +91,11 @@ test('getAssetHost', () => { expect(getAssetHost({region: 'eu-central-1'})).toBe( 'https://assets.eu-central-1.saucelabs.com' ); - expect(getAssetHost({region: 'us-east-4'})).toBe( - 'https://assets.us-east-4.saucelabs.com' + expect(getAssetHost({headless: true})).toBe( + 'https://assets.us-east-1.saucelabs.com' + ); + expect(getAssetHost({headless: true, region: 'eu'})).toBe( + 'https://assets.us-east-1.saucelabs.com' ); expect(getAssetHost({region: 'staging'})).toBe( 'https://assets.staging.saucelabs.net'