Skip to content

Commit

Permalink
fix(discovery): add sqdiscovery URL as config (#4117)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisadubois authored Feb 27, 2025
1 parent fc8c62a commit 2048787
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ HYDRA_SERVICE_URL="https://apialpha.ciscospark.com/v1/"
IDBROKER_BASE_URL="https://idbrokerbts.webex.com"
IDENTITY_BASE_URL="https://identitybts.webex.com"
U2C_SERVICE_URL="https://u2c-intb.ciscospark.com/u2c/api/v1"
SQDISCOVERY_SERVICE_URL="https://ds.ciscospark.com/v1/region"
WDM_SERVICE_URL="https://wdm-intb.ciscospark.com/wdm/api/v1"
WHISTLER_API_SERVICE_URL="https://whistler.allnint.ciscospark.com/api/v1"
WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL="https://cig-service-intb.ciscospark.com/cig-service/api/v1"
Expand All @@ -55,6 +56,7 @@ WEBEX_CONVERSATION_DEFAULT_CLUSTER="urn:TEAM:us-east-1_int13:identityLookup"
# IDBROKER_BASE_URL="https://idbroker.webex.com"
# IDENTITY_BASE_URL="https://identity.webex.com"
# U2C_SERVICE_URL="https://u2c.wbx2.com/u2c/api/v1"
# SQDISCOVERY_SERVICE_URL="https://ds.ciscospark.com/v1/region"
# WDM_SERVICE_URL="https://wdm-a.wbx2.com/wdm/api/v1"
# WHISTLER_API_SERVICE_URL="https://whistler-prod.allnint.ciscospark.com/api/v1"
# WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL="https://cig-service-a.wbx2.com/cig-service/api/v1"
Expand Down
1 change: 1 addition & 0 deletions ENV.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This article is designed to provide additional context in regards to potentially
| `MERCURY_PONG_TIMEOUT` | Milliseconds to wait for a pong before declaring the connection dead | 14000 |
| `METRICS_SERVICE_URL` | Used to populate the metricsServiceUrl pre-discovery config | https://metrics-a.wbx2.com/metrics/api/v1 |
| `U2C_SERVICE_URL` | Stores the service catalog collecting url, typically the **U2C** service. | https://u2c.wbx2.com/u2c/api/v1 |
| `SQDISCOVERY_SERVICE_URL` | Stores the url for client region information lookups | https://ds.ciscospark.com/v1/region |
| `WEBEX_ACCESS_TOKEN` | Used to provide access token when using "webex/env" | undefined |
| `WEBEX_AUTHORIZE_URL` | Populates the Authorization URL which prompts for the user's password. | https://idbroker.webex.com/idb/oauth2/v1/authorize |
| `WEBEX_AUTHORIZATION_STRING` | This is the authorization URL for the integration from [Cisco Webex for Developers](https://developer.webex.com/my-apps) | undefined |
Expand Down
5 changes: 4 additions & 1 deletion packages/@webex/webex-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The following environment variables are used by this plugin:

- `HYDRA_SERVICE_URL` - Stores the public hydra api url for managing Webex resources.
- `U2C_SERVICE_URL` - Stores the service catalog collecting url, typically the **U2C** service.
- `SQDISCOVERY_SERVICE_URL` - Stores the URL for client region information, such as country code and timezone

### Configuration

Expand All @@ -43,7 +44,8 @@ const webex = new Webex({
services: {
// Services that are available before catalog retrieval.
discovery: {
hydra: 'https://api.ciscospark.com/v1'
hydra: 'https://api.ciscospark.com/v1',
sqdiscovery: 'https://ds.ciscospark.com/v1/region'
},

// Services that have a persistant host, typically for testing.
Expand All @@ -65,6 +67,7 @@ The default configuration includes the following service urls:

- `U2C_SERVICE_URL` [ **U2C** ] - `https://u2c.wbx2.com/u2c/api/v1`
- `HYDRA_SERVICE_URL` [ **Hydra** ] - `https://api.ciscospark.com/v1`
- `SQDISCOVERY_SERVICE_URL` [ **SQDISCOVERY** ] - `https://ds.ciscospark.com/v1/region`

## Maintainers

Expand Down
5 changes: 5 additions & 0 deletions packages/@webex/webex-core/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export default {
*/
hydra: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',

/**
* load balanced region info url
*/
sqdiscovery: process.env.SQDISCOVERY_SERVICE_URL || 'https://ds.ciscospark.com/v1/region',

/**
* The u2c discovery url
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {
hydra: 'https://api-usgov.webex.com/v1',
u2c: 'https://u2c.gov.ciscospark.com/u2c/api/v1',
sqdiscovery: 'https://ds.ciscospark.com/v1/region', // TODO: fedramp load balanced URL? this has been here for years as of now but now explicitly done
};
4 changes: 3 additions & 1 deletion packages/@webex/webex-core/src/lib/services/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,10 @@ const Services = WebexPlugin.extend({
* @returns {object} - The region info object.
*/
fetchClientRegionInfo() {
const {services} = this.webex.config;

return this.request({
uri: 'https://ds.ciscospark.com/v1/region',
uri: services.discovery.sqdiscovery,
addAuthHeader: false,
headers: {
'spark-user-agent': null,
Expand Down
24 changes: 24 additions & 0 deletions packages/@webex/webex-core/test/unit/spec/services/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,37 @@ describe('webex-core', () => {
});

describe('#fetchClientRegionInfo', () => {
beforeEach(() => {
services.webex.config = {
services: {
discovery: {
sqdiscovery: 'https://test.ciscospark.com/v1/region',
},
}
};
});

it('successfully resolves with undefined if fetch request failed', () => {
webex.request = sinon.stub().returns(Promise.reject());

return services.fetchClientRegionInfo().then((r) => {
assert.isUndefined(r);
});
});

it('successfully resolves with true if fetch request succeeds', () => {
webex.request = sinon.stub().returns(Promise.resolve({body: true}));

return services.fetchClientRegionInfo().then((r) => {
assert.equal(r, true);
assert.calledWith(webex.request, {
uri: 'https://test.ciscospark.com/v1/region',
addAuthHeader: false,
headers: { 'spark-user-agent': null },
timeout: 5000
});
});
});
});

describe('#getMeetingPreferences', () => {
Expand Down
1 change: 1 addition & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ DOCKER_ENV_KEYS+="SAUCE_IS_DOWN "
DOCKER_ENV_KEYS+="SDK_BUILD_DEBUG "
DOCKER_ENV_KEYS+="SKIP_FLAKY_TESTS "
DOCKER_ENV_KEYS+="U2C_SERVICE_URL "
DOCKER_ENV_KEYS+="SQDISCOVERY_SERVICE_URL "
DOCKER_ENV_KEYS+="WDM_SERVICE_URL "
DOCKER_ENV_KEYS+="WHISTLER_API_SERVICE_URL "
DOCKER_ENV_KEYS+="WORKSPACE "
Expand Down
2 changes: 2 additions & 0 deletions sauce.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'IDBROKER_BASE_URL': 'https://idbroker.webex.com',
'IDENTITY_BASE_URL': 'https://identity.webex.com',
'U2C_SERVICE_URL': 'https://u2c.wbx2.com/u2c/api/v1',
'SQDISCOVERY_SERVICE_URL': 'https://ds.ciscospark.com/v1/region',
'WDM_SERVICE_URL': 'https://wdm-a.wbx2.com/wdm/api/v1',
# Logging
'ENABLE_VERBOSE_NETWORK_LOGGING': 'true',
Expand All @@ -32,6 +33,7 @@
'IDBROKER_BASE_URL': 'https://idbrokerbts.webex.com',
'IDENTITY_BASE_URL': 'https://identitybts.webex.com',
'U2C_SERVICE_URL': 'https://u2c-intb.ciscospark.com/u2c/api/v1',
'SQDISCOVERY_SERVICE_URL': 'https://ds.ciscospark.com/v1/region',
'WDM_SERVICE_URL': 'https://wdm-intb.ciscospark.com/wdm/api/v1',
'WHISTLER_API_SERVICE_URL': 'https://whistler.allnint.ciscospark.com/api/v1',
# Logging
Expand Down
2 changes: 2 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'IDBROKER_BASE_URL': 'https://idbroker.webex.com',
'IDENTITY_BASE_URL': 'https://identity.webex.com',
'U2C_SERVICE_URL': 'https://u2c.wbx2.com/u2c/api/v1',
'SQDISCOVERY_SERVICE_URL': 'https://ds.ciscospark.com/v1/region',
'WDM_SERVICE_URL': 'https://wdm-a.wbx2.com/wdm/api/v1',
# Logging
'ENABLE_VERBOSE_NETWORK_LOGGING': 'true'
Expand All @@ -31,6 +32,7 @@
'IDBROKER_BASE_URL': 'https://idbrokerbts.webex.com',
'IDENTITY_BASE_URL': 'https://identitybts.webex.com',
'U2C_SERVICE_URL': 'https://u2c-intb.ciscospark.com/u2c/api/v1',
'SQDISCOVERY_SERVICE_URL': 'https://ds.ciscospark.com/v1/region',
'WDM_SERVICE_URL': 'https://wdm-intb.ciscospark.com/wdm/api/v1',
'WHISTLER_API_SERVICE_URL': 'https://whistler.allnint.ciscospark.com/api/v1',
# Logging
Expand Down
2 changes: 2 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ module.exports = (env = {NODE_ENV: process.env.NODE_ENV || 'production'}) => ({
IDBROKER_BASE_URL: 'https://idbrokerbts.webex.com',
IDENTITY_BASE_URL: 'https://identitybts.webex.com',
U2C_SERVICE_URL: 'https://u2c-intb.ciscospark.com/u2c/api/v1',
SQDISCOVERY_SERVICE_URL: 'https://ds.ciscospark.com/v1/region',
WDM_SERVICE_URL: 'https://wdm-intb.ciscospark.com/wdm/api/v1',
WHISTLER_API_SERVICE_URL: 'https://whistler.allnint.ciscospark.com/api/v1',
WEBEX_CONVERSATION_DEFAULT_CLUSTER: 'urn:TEAM:us-east-1_int13:identityLookup',
Expand Down Expand Up @@ -167,6 +168,7 @@ module.exports = (env = {NODE_ENV: process.env.NODE_ENV || 'production'}) => ({
IDBROKER_BASE_URL: JSON.stringify('https://idbroker.webex.com'),
IDENTITY_BASE_URL: JSON.stringify('https://identity.webex.com'),
U2C_SERVICE_URL: JSON.stringify('https://u2c.wbx2.com/u2c/api/v1'),
SQDISCOVERY_SERVICE_URL: JSON.stringify('https://ds.ciscospark.com/v1/region'),
WDM_SERVICE_URL: JSON.stringify('https://wdm-a.wbx2.com/wdm/api/v1'),
WHISTLER_API_SERVICE_URL: JSON.stringify(
'https://whistler-prod.allnint.ciscospark.com/api/v1'
Expand Down

0 comments on commit 2048787

Please sign in to comment.