@webex/webex-core 3.3.0 → 3.3.1-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/lib/batcher.js +1 -1
- package/dist/lib/credentials/credentials.js +1 -1
- package/dist/lib/credentials/token.js +1 -1
- package/dist/lib/services/constants.js +4 -1
- package/dist/lib/services/constants.js.map +1 -1
- package/dist/lib/services/service-catalog.js +30 -6
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/services.js +62 -48
- package/dist/lib/services/services.js.map +1 -1
- package/dist/plugins/logger.js +1 -1
- package/dist/webex-core.js +2 -2
- package/dist/webex-core.js.map +1 -1
- package/package.json +13 -13
- package/src/config.js +1 -10
- package/src/lib/services/constants.js +13 -1
- package/src/lib/services/service-catalog.js +22 -4
- package/src/lib/services/services.js +65 -45
- package/test/integration/spec/services/services.js +13 -6
- package/test/unit/spec/interceptors/auth.js +16 -7
- package/test/unit/spec/services/service-catalog.js +78 -16
- package/test/unit/spec/services/services.js +190 -10
package/package.json
CHANGED
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"@webex/eslint-config-legacy": "0.0.0",
|
|
36
36
|
"@webex/jest-config-legacy": "0.0.0",
|
|
37
37
|
"@webex/legacy-tools": "0.0.0",
|
|
38
|
-
"@webex/test-helper-chai": "3.3.
|
|
39
|
-
"@webex/test-helper-make-local-url": "3.3.
|
|
40
|
-
"@webex/test-helper-mocha": "3.3.
|
|
41
|
-
"@webex/test-helper-mock-webex": "3.3.
|
|
42
|
-
"@webex/test-helper-refresh-callback": "3.3.
|
|
43
|
-
"@webex/test-helper-test-users": "3.3.
|
|
38
|
+
"@webex/test-helper-chai": "3.3.1-next.10",
|
|
39
|
+
"@webex/test-helper-make-local-url": "3.3.1-next.10",
|
|
40
|
+
"@webex/test-helper-mocha": "3.3.1-next.10",
|
|
41
|
+
"@webex/test-helper-mock-webex": "3.3.1-next.10",
|
|
42
|
+
"@webex/test-helper-refresh-callback": "3.3.1-next.10",
|
|
43
|
+
"@webex/test-helper-test-users": "3.3.1-next.10",
|
|
44
44
|
"chai": "^4.3.4",
|
|
45
45
|
"chai-as-promised": "^7.1.1",
|
|
46
46
|
"eslint": "^8.24.0",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"sinon": "^9.2.4"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@webex/common": "3.3.
|
|
52
|
-
"@webex/common-timers": "3.3.
|
|
53
|
-
"@webex/http-core": "3.3.
|
|
54
|
-
"@webex/internal-plugin-device": "3.3.
|
|
55
|
-
"@webex/plugin-logger": "3.3.
|
|
56
|
-
"@webex/storage-adapter-spec": "3.3.
|
|
51
|
+
"@webex/common": "3.3.1-next.10",
|
|
52
|
+
"@webex/common-timers": "3.3.1-next.10",
|
|
53
|
+
"@webex/http-core": "3.3.1-next.10",
|
|
54
|
+
"@webex/internal-plugin-device": "3.3.1-next.10",
|
|
55
|
+
"@webex/plugin-logger": "3.3.1-next.10",
|
|
56
|
+
"@webex/storage-adapter-spec": "3.3.1-next.10",
|
|
57
57
|
"ampersand-collection": "^2.0.2",
|
|
58
58
|
"ampersand-events": "^2.0.2",
|
|
59
59
|
"ampersand-state": "^5.0.3",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"test:style": "eslint ./src/**/*.*",
|
|
74
74
|
"test:unit": "webex-legacy-tools test --unit --runner jest"
|
|
75
75
|
},
|
|
76
|
-
"version": "3.3.
|
|
76
|
+
"version": "3.3.1-next.10"
|
|
77
77
|
}
|
package/src/config.js
CHANGED
|
@@ -58,16 +58,7 @@ export default {
|
|
|
58
58
|
*
|
|
59
59
|
* @type {Array<string>}
|
|
60
60
|
*/
|
|
61
|
-
allowedDomains: [
|
|
62
|
-
'wbx2.com',
|
|
63
|
-
'ciscospark.com',
|
|
64
|
-
'webex.com',
|
|
65
|
-
'webexapis.com',
|
|
66
|
-
'broadcloudpbx.com',
|
|
67
|
-
'broadcloud.eu',
|
|
68
|
-
'broadcloud.com.au',
|
|
69
|
-
'broadcloudpbx.net',
|
|
70
|
-
],
|
|
61
|
+
allowedDomains: [],
|
|
71
62
|
},
|
|
72
63
|
device: {
|
|
73
64
|
preDiscoveryServices: {
|
|
@@ -6,4 +6,16 @@ const SERVICE_CATALOGS_ENUM_TYPES = {
|
|
|
6
6
|
NUMBER: 'SERVICE_CATALOGS_ENUM_TYPES_NUMBER',
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// The default allowed domains that SDK can make requests to outside of service catalog
|
|
10
|
+
const COMMERCIAL_ALLOWED_DOMAINS = [
|
|
11
|
+
'wbx2.com',
|
|
12
|
+
'ciscospark.com',
|
|
13
|
+
'webex.com',
|
|
14
|
+
'webexapis.com',
|
|
15
|
+
'broadcloudpbx.com',
|
|
16
|
+
'broadcloud.eu',
|
|
17
|
+
'broadcloud.com.au',
|
|
18
|
+
'broadcloudpbx.net',
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
export {SERVICE_CATALOGS_ENUM_TYPES, NAMESPACE, SERVICE_CATALOGS, COMMERCIAL_ALLOWED_DOMAINS};
|
|
@@ -2,6 +2,7 @@ import Url from 'url';
|
|
|
2
2
|
|
|
3
3
|
import AmpState from 'ampersand-state';
|
|
4
4
|
|
|
5
|
+
import {union} from 'lodash';
|
|
5
6
|
import ServiceUrl from './service-url';
|
|
6
7
|
|
|
7
8
|
/* eslint-disable no-underscore-dangle */
|
|
@@ -236,7 +237,6 @@ const ServiceCatalog = AmpState.extend({
|
|
|
236
237
|
* @returns {serviceUrl} - ServiceUrl assocated with provided url
|
|
237
238
|
*/
|
|
238
239
|
findServiceUrlFromUrl(url) {
|
|
239
|
-
const incomingUrlObj = Url.parse(url);
|
|
240
240
|
const serviceUrls = [
|
|
241
241
|
...this.serviceGroups.discovery,
|
|
242
242
|
...this.serviceGroups.preauth,
|
|
@@ -246,12 +246,21 @@ const ServiceCatalog = AmpState.extend({
|
|
|
246
246
|
];
|
|
247
247
|
|
|
248
248
|
return serviceUrls.find((serviceUrl) => {
|
|
249
|
-
if
|
|
249
|
+
// Check to see if the URL we are checking starts with the default URL
|
|
250
|
+
if (url.startsWith(serviceUrl.defaultUrl)) {
|
|
250
251
|
return true;
|
|
251
252
|
}
|
|
252
253
|
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
// If not, we check to see if the alternate URLs match
|
|
255
|
+
// These are made by swapping the host of the default URL
|
|
256
|
+
// with that of an alternate host
|
|
257
|
+
for (const host of serviceUrl.hosts) {
|
|
258
|
+
const alternateUrl = new URL(serviceUrl.defaultUrl);
|
|
259
|
+
alternateUrl.host = host.host;
|
|
260
|
+
|
|
261
|
+
if (url.startsWith(alternateUrl.toString())) {
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
255
264
|
}
|
|
256
265
|
|
|
257
266
|
return false;
|
|
@@ -361,6 +370,15 @@ const ServiceCatalog = AmpState.extend({
|
|
|
361
370
|
this.allowedDomains = [...allowedDomains];
|
|
362
371
|
},
|
|
363
372
|
|
|
373
|
+
/**
|
|
374
|
+
*
|
|
375
|
+
* @param {Array<string>} newAllowedDomains - new allowed domains to add to existing set of allowed domains
|
|
376
|
+
* @returns {void}
|
|
377
|
+
*/
|
|
378
|
+
addAllowedDomains(newAllowedDomains) {
|
|
379
|
+
this.allowedDomains = union(this.allowedDomains, newAllowedDomains);
|
|
380
|
+
},
|
|
381
|
+
|
|
364
382
|
/**
|
|
365
383
|
* Update the current list of `ServiceUrl`s against a provided
|
|
366
384
|
* service hostmap.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import Url from 'url';
|
|
2
|
-
|
|
3
1
|
import sha256 from 'crypto-js/sha256';
|
|
4
2
|
|
|
3
|
+
import {union, forEach} from 'lodash';
|
|
5
4
|
import WebexPlugin from '../webex-plugin';
|
|
6
5
|
|
|
7
6
|
import METRICS from './metrics';
|
|
@@ -9,6 +8,7 @@ import ServiceCatalog from './service-catalog';
|
|
|
9
8
|
import ServiceRegistry from './service-registry';
|
|
10
9
|
import ServiceState from './service-state';
|
|
11
10
|
import fedRampServices from './service-fed-ramp';
|
|
11
|
+
import {COMMERCIAL_ALLOWED_DOMAINS} from './constants';
|
|
12
12
|
|
|
13
13
|
const trailingSlashes = /(?:^\/)|(?:\/$)/;
|
|
14
14
|
|
|
@@ -684,59 +684,74 @@ const Services = WebexPlugin.extend({
|
|
|
684
684
|
*/
|
|
685
685
|
_formatReceivedHostmap(serviceHostmap) {
|
|
686
686
|
this._updateHostCatalog(serviceHostmap.hostCatalog);
|
|
687
|
-
// map the host catalog items to a formatted hostmap
|
|
688
|
-
const formattedHostmap = Object.keys(serviceHostmap.hostCatalog).reduce((accumulator, key) => {
|
|
689
|
-
if (serviceHostmap.hostCatalog[key].length === 0) {
|
|
690
|
-
return accumulator;
|
|
691
|
-
}
|
|
692
687
|
|
|
693
|
-
|
|
694
|
-
const defaultUrl = serviceHostmap.serviceLinks[serviceName];
|
|
688
|
+
const extractId = (entry) => entry.id.split(':')[3];
|
|
695
689
|
|
|
696
|
-
|
|
690
|
+
const formattedHostmap = [];
|
|
697
691
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
defaultUrl,
|
|
702
|
-
defaultHost: Url.parse(defaultUrl).hostname,
|
|
703
|
-
hosts: [],
|
|
704
|
-
};
|
|
692
|
+
// for each of the services in the serviceLinks, find the matching host in the catalog
|
|
693
|
+
Object.keys(serviceHostmap.serviceLinks).forEach((serviceName) => {
|
|
694
|
+
const serviceUrl = serviceHostmap.serviceLinks[serviceName];
|
|
705
695
|
|
|
706
|
-
|
|
696
|
+
let host;
|
|
697
|
+
try {
|
|
698
|
+
host = new URL(serviceUrl).host;
|
|
699
|
+
} catch (e) {
|
|
700
|
+
return;
|
|
707
701
|
}
|
|
708
702
|
|
|
709
|
-
|
|
710
|
-
// map the default key as a low priority default for cluster matching
|
|
711
|
-
{
|
|
712
|
-
host: key,
|
|
713
|
-
ttl: -1,
|
|
714
|
-
priority: 10,
|
|
715
|
-
id: serviceHostmap.hostCatalog[key][0].id,
|
|
716
|
-
homeCluster: serviceItem.defaultHost === key,
|
|
717
|
-
},
|
|
718
|
-
// map the rest of the hosts in their proper locations
|
|
719
|
-
...serviceHostmap.hostCatalog[key].map((host) => ({
|
|
720
|
-
...host,
|
|
721
|
-
homeCluster: serviceItem.defaultHost === key,
|
|
722
|
-
}))
|
|
723
|
-
);
|
|
703
|
+
const matchingCatalogEntry = serviceHostmap.hostCatalog[host];
|
|
724
704
|
|
|
725
|
-
|
|
726
|
-
|
|
705
|
+
const formattedHost = {
|
|
706
|
+
name: serviceName,
|
|
707
|
+
defaultUrl: serviceUrl,
|
|
708
|
+
defaultHost: host,
|
|
709
|
+
hosts: [],
|
|
710
|
+
};
|
|
727
711
|
|
|
728
|
-
|
|
729
|
-
Object.keys(serviceHostmap.serviceLinks).forEach((key) => {
|
|
730
|
-
const service = formattedHostmap.find((item) => item.name === key);
|
|
712
|
+
formattedHostmap.push(formattedHost);
|
|
731
713
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
defaultHost: Url.parse(serviceHostmap.serviceLinks[key]).hostname,
|
|
737
|
-
hosts: [],
|
|
738
|
-
});
|
|
714
|
+
// If the catalog does not have any hosts we will be unable to find the service ID
|
|
715
|
+
// so can't search for other hosts
|
|
716
|
+
if (!matchingCatalogEntry || !matchingCatalogEntry[0]) {
|
|
717
|
+
return;
|
|
739
718
|
}
|
|
719
|
+
|
|
720
|
+
const serviceId = extractId(matchingCatalogEntry[0]);
|
|
721
|
+
|
|
722
|
+
forEach(matchingCatalogEntry, (entry) => {
|
|
723
|
+
// The ids for all hosts within a hostCatalog entry should be the same
|
|
724
|
+
// but for safety, only add host entries that have the same id as the first one
|
|
725
|
+
if (extractId(entry) === serviceId) {
|
|
726
|
+
formattedHost.hosts.push({
|
|
727
|
+
...entry,
|
|
728
|
+
homeCluster: true,
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
const otherHosts = [];
|
|
734
|
+
|
|
735
|
+
// find the services in the host catalog that have the same id
|
|
736
|
+
// and add them to the otherHosts
|
|
737
|
+
forEach(serviceHostmap.hostCatalog, (entry) => {
|
|
738
|
+
// exclude the matching catalog entry as we have already added that
|
|
739
|
+
if (entry === matchingCatalogEntry) {
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
forEach(entry, (entryHost) => {
|
|
744
|
+
// only add hosts that have the correct id
|
|
745
|
+
if (extractId(entryHost) === serviceId) {
|
|
746
|
+
otherHosts.push({
|
|
747
|
+
...entryHost,
|
|
748
|
+
homeCluster: false,
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
formattedHost.hosts.push(...otherHosts);
|
|
740
755
|
});
|
|
741
756
|
|
|
742
757
|
// update all the service urls in the host catalog
|
|
@@ -941,6 +956,11 @@ const Services = WebexPlugin.extend({
|
|
|
941
956
|
catalog.updateServiceUrls('override', formattedOverrideServices);
|
|
942
957
|
}
|
|
943
958
|
|
|
959
|
+
// if not fedramp, append on the commercialAllowedDomains
|
|
960
|
+
if (!fedramp) {
|
|
961
|
+
services.allowedDomains = union(services.allowedDomains, COMMERCIAL_ALLOWED_DOMAINS);
|
|
962
|
+
}
|
|
963
|
+
|
|
944
964
|
// Check for allowed host domains.
|
|
945
965
|
if (services.allowedDomains) {
|
|
946
966
|
// Store the allowed domains as a property of the catalog.
|
|
@@ -11,6 +11,7 @@ import WebexCore, {
|
|
|
11
11
|
ServiceRegistry,
|
|
12
12
|
ServiceState,
|
|
13
13
|
ServiceUrl,
|
|
14
|
+
serviceConstants,
|
|
14
15
|
} from '@webex/webex-core';
|
|
15
16
|
import testUsers from '@webex/test-helper-test-users';
|
|
16
17
|
import uuid from 'uuid';
|
|
@@ -36,11 +37,15 @@ describe('webex-core', () => {
|
|
|
36
37
|
orgId: process.env.EU_PRIMARY_ORG_ID,
|
|
37
38
|
},
|
|
38
39
|
}),
|
|
39
|
-
]).then(([[user], [userEU]]) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
]).then(([[user], [userEU]]) =>
|
|
41
|
+
new Promise((resolve) => {
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
webexUser = user;
|
|
44
|
+
webexUserEU = userEU;
|
|
45
|
+
resolve();
|
|
46
|
+
}, 1000)
|
|
47
|
+
})
|
|
48
|
+
));
|
|
44
49
|
|
|
45
50
|
beforeEach('create webex instance', () => {
|
|
46
51
|
webex = new WebexCore({credentials: {supertoken: webexUser.token}});
|
|
@@ -363,7 +368,9 @@ describe('webex-core', () => {
|
|
|
363
368
|
|
|
364
369
|
services.initConfig();
|
|
365
370
|
|
|
366
|
-
|
|
371
|
+
const expectedResult = [...allowedDomains, ...serviceConstants.COMMERCIAL_ALLOWED_DOMAINS];
|
|
372
|
+
|
|
373
|
+
assert.deepEqual(expectedResult, services._getCatalog().allowedDomains);
|
|
367
374
|
});
|
|
368
375
|
});
|
|
369
376
|
|
|
@@ -10,7 +10,14 @@ import sinon from 'sinon';
|
|
|
10
10
|
import {browserOnly, nodeOnly} from '@webex/test-helper-mocha';
|
|
11
11
|
import Logger from '@webex/plugin-logger';
|
|
12
12
|
import MockWebex from '@webex/test-helper-mock-webex';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
AuthInterceptor,
|
|
15
|
+
config,
|
|
16
|
+
Credentials,
|
|
17
|
+
WebexHttpError,
|
|
18
|
+
Token,
|
|
19
|
+
serviceConstants,
|
|
20
|
+
} from '@webex/webex-core';
|
|
14
21
|
import {cloneDeep, merge} from 'lodash';
|
|
15
22
|
import Metrics from '@webex/internal-plugin-metrics';
|
|
16
23
|
|
|
@@ -122,7 +129,7 @@ describe('webex-core', () => {
|
|
|
122
129
|
hasService: (service) => Object.keys(services).includes(service),
|
|
123
130
|
hasAllowedDomains: () => true,
|
|
124
131
|
isAllowedDomainUrl: (uri) =>
|
|
125
|
-
!!
|
|
132
|
+
!!serviceConstants.COMMERCIAL_ALLOWED_DOMAINS.find((host) => uri.includes(host)),
|
|
126
133
|
getServiceFromUrl: (uri) => {
|
|
127
134
|
let targetKey;
|
|
128
135
|
|
|
@@ -249,7 +256,7 @@ describe('webex-core', () => {
|
|
|
249
256
|
hasService: (service) => Object.keys(services).includes(service),
|
|
250
257
|
hasAllowedDomains: () => true,
|
|
251
258
|
isAllowedDomainUrl: (uri) =>
|
|
252
|
-
!!
|
|
259
|
+
!!serviceConstants.COMMERCIAL_ALLOWED_DOMAINS.find((host) => uri.includes(host)),
|
|
253
260
|
validateDomains: true,
|
|
254
261
|
};
|
|
255
262
|
|
|
@@ -323,7 +330,7 @@ describe('webex-core', () => {
|
|
|
323
330
|
it('resolves to true with an allowed domain uri', () =>
|
|
324
331
|
interceptor
|
|
325
332
|
.requiresCredentials({
|
|
326
|
-
uri: `https://${
|
|
333
|
+
uri: `https://${serviceConstants.COMMERCIAL_ALLOWED_DOMAINS[0]}/resource`,
|
|
327
334
|
})
|
|
328
335
|
.then((response) => assert.isTrue(response)));
|
|
329
336
|
|
|
@@ -339,7 +346,7 @@ describe('webex-core', () => {
|
|
|
339
346
|
const {isAllowedDomainUrl} = webex.internal.services;
|
|
340
347
|
|
|
341
348
|
const result = isAllowedDomainUrl(
|
|
342
|
-
`https://${
|
|
349
|
+
`https://${serviceConstants.COMMERCIAL_ALLOWED_DOMAINS[0]}/resource`
|
|
343
350
|
);
|
|
344
351
|
|
|
345
352
|
assert.equal(result, true);
|
|
@@ -350,7 +357,7 @@ describe('webex-core', () => {
|
|
|
350
357
|
|
|
351
358
|
return interceptor
|
|
352
359
|
.requiresCredentials({
|
|
353
|
-
uri: `https://${
|
|
360
|
+
uri: `https://${serviceConstants.COMMERCIAL_ALLOWED_DOMAINS[0]}/resource`,
|
|
354
361
|
})
|
|
355
362
|
.then((res) => {
|
|
356
363
|
assert.equal(res, true);
|
|
@@ -361,7 +368,9 @@ describe('webex-core', () => {
|
|
|
361
368
|
webex.internal.services.waitForService = sinon.stub();
|
|
362
369
|
const {waitForService} = webex.internal.services;
|
|
363
370
|
|
|
364
|
-
waitForService.resolves(
|
|
371
|
+
waitForService.resolves(
|
|
372
|
+
`https://${serviceConstants.COMMERCIAL_ALLOWED_DOMAINS[0]}/resource`
|
|
373
|
+
);
|
|
365
374
|
|
|
366
375
|
return interceptor
|
|
367
376
|
.requiresCredentials({
|
|
@@ -13,7 +13,7 @@ describe('webex-core', () => {
|
|
|
13
13
|
let services;
|
|
14
14
|
let catalog;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
beforeEach(() => {
|
|
17
17
|
webex = new MockWebex();
|
|
18
18
|
services = new Services(undefined, {parent: webex});
|
|
19
19
|
catalog = services._getCatalog();
|
|
@@ -101,11 +101,7 @@ describe('webex-core', () => {
|
|
|
101
101
|
const domains = [];
|
|
102
102
|
|
|
103
103
|
beforeEach(() => {
|
|
104
|
-
domains.push(
|
|
105
|
-
'example-a',
|
|
106
|
-
'example-b',
|
|
107
|
-
'example-c'
|
|
108
|
-
);
|
|
104
|
+
domains.push('example-a', 'example-b', 'example-c');
|
|
109
105
|
|
|
110
106
|
catalog.setAllowedDomains(domains);
|
|
111
107
|
});
|
|
@@ -125,11 +121,7 @@ describe('webex-core', () => {
|
|
|
125
121
|
const domains = [];
|
|
126
122
|
|
|
127
123
|
beforeEach(() => {
|
|
128
|
-
domains.push(
|
|
129
|
-
'example-a',
|
|
130
|
-
'example-b',
|
|
131
|
-
'example-c'
|
|
132
|
-
);
|
|
124
|
+
domains.push('example-a', 'example-b', 'example-c');
|
|
133
125
|
|
|
134
126
|
catalog.setAllowedDomains(domains);
|
|
135
127
|
});
|
|
@@ -168,11 +160,7 @@ describe('webex-core', () => {
|
|
|
168
160
|
const domains = [];
|
|
169
161
|
|
|
170
162
|
beforeEach(() => {
|
|
171
|
-
domains.push(
|
|
172
|
-
'example-a',
|
|
173
|
-
'example-b',
|
|
174
|
-
'example-c'
|
|
175
|
-
);
|
|
163
|
+
domains.push('example-a', 'example-b', 'example-c');
|
|
176
164
|
|
|
177
165
|
catalog.setAllowedDomains(domains);
|
|
178
166
|
});
|
|
@@ -189,6 +177,80 @@ describe('webex-core', () => {
|
|
|
189
177
|
assert.notDeepInclude(domains, newValues);
|
|
190
178
|
});
|
|
191
179
|
});
|
|
180
|
+
|
|
181
|
+
describe('#addAllowedDomains()', () => {
|
|
182
|
+
const domains = [];
|
|
183
|
+
|
|
184
|
+
beforeEach(() => {
|
|
185
|
+
domains.push('example-a', 'example-b', 'example-c');
|
|
186
|
+
|
|
187
|
+
catalog.setAllowedDomains(domains);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
afterEach(() => {
|
|
191
|
+
domains.length = 0;
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('merge the allowed domain entries with new values', () => {
|
|
195
|
+
const newValues = ['example-c', 'example-e', 'example-f'];
|
|
196
|
+
|
|
197
|
+
catalog.addAllowedDomains(newValues);
|
|
198
|
+
|
|
199
|
+
const list = catalog.getAllowedDomains();
|
|
200
|
+
|
|
201
|
+
assert.match(['example-a', 'example-b', 'example-c', 'example-e', 'example-f'], list);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
describe('findServiceUrlFromUrl()', () => {
|
|
206
|
+
const otherService = {
|
|
207
|
+
defaultUrl: 'https://example.com/differentresource',
|
|
208
|
+
hosts: [{host: 'example1.com'}, {host: 'example2.com'}],
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
it.each([
|
|
212
|
+
'discovery',
|
|
213
|
+
'preauth',
|
|
214
|
+
'signin',
|
|
215
|
+
'postauth',
|
|
216
|
+
'override'
|
|
217
|
+
])('matches a default url correctly', (serviceGroup) => {
|
|
218
|
+
const url = 'https://example.com/resource/id';
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
const exampleService = {
|
|
222
|
+
defaultUrl: 'https://example.com/resource',
|
|
223
|
+
hosts: [{host: 'example1.com'}, {host: 'example2.com'}],
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
catalog.serviceGroups[serviceGroup].push(otherService, exampleService);
|
|
227
|
+
|
|
228
|
+
const service = catalog.findServiceUrlFromUrl(url);
|
|
229
|
+
|
|
230
|
+
assert.equal(service, exampleService);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it.each([
|
|
234
|
+
'discovery',
|
|
235
|
+
'preauth',
|
|
236
|
+
'signin',
|
|
237
|
+
'postauth',
|
|
238
|
+
'override'
|
|
239
|
+
])('matches an alternate host url', (serviceGroup) => {
|
|
240
|
+
const url = 'https://example2.com/resource/id';
|
|
241
|
+
|
|
242
|
+
const exampleService = {
|
|
243
|
+
defaultUrl: 'https://example.com/resource',
|
|
244
|
+
hosts: [{host: 'example1.com'}, {host: 'example2.com'}],
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
catalog.serviceGroups[serviceGroup].push(otherService, exampleService);
|
|
248
|
+
|
|
249
|
+
const service = catalog.findServiceUrlFromUrl(url);
|
|
250
|
+
|
|
251
|
+
assert.equal(service, exampleService);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
192
254
|
});
|
|
193
255
|
});
|
|
194
256
|
/* eslint-enable no-underscore-dangle */
|