@webex/webex-core 3.3.0 → 3.3.1-next.2
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 +9 -0
- 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 +10 -0
- 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 +27 -15
- 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.2",
|
|
39
|
+
"@webex/test-helper-make-local-url": "3.3.1-next.2",
|
|
40
|
+
"@webex/test-helper-mocha": "3.3.1-next.2",
|
|
41
|
+
"@webex/test-helper-mock-webex": "3.3.1-next.2",
|
|
42
|
+
"@webex/test-helper-refresh-callback": "3.3.1-next.2",
|
|
43
|
+
"@webex/test-helper-test-users": "3.3.1-next.2",
|
|
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.2",
|
|
52
|
+
"@webex/common-timers": "3.3.1-next.2",
|
|
53
|
+
"@webex/http-core": "3.3.1-next.2",
|
|
54
|
+
"@webex/internal-plugin-device": "3.3.1-next.2",
|
|
55
|
+
"@webex/plugin-logger": "3.3.1-next.2",
|
|
56
|
+
"@webex/storage-adapter-spec": "3.3.1-next.2",
|
|
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.2"
|
|
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 */
|
|
@@ -361,6 +362,15 @@ const ServiceCatalog = AmpState.extend({
|
|
|
361
362
|
this.allowedDomains = [...allowedDomains];
|
|
362
363
|
},
|
|
363
364
|
|
|
365
|
+
/**
|
|
366
|
+
*
|
|
367
|
+
* @param {Array<string>} newAllowedDomains - new allowed domains to add to existing set of allowed domains
|
|
368
|
+
* @returns {void}
|
|
369
|
+
*/
|
|
370
|
+
addAllowedDomains(newAllowedDomains) {
|
|
371
|
+
this.allowedDomains = union(this.allowedDomains, newAllowedDomains);
|
|
372
|
+
},
|
|
373
|
+
|
|
364
374
|
/**
|
|
365
375
|
* Update the current list of `ServiceUrl`s against a provided
|
|
366
376
|
* 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({
|
|
@@ -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,30 @@ 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
|
+
});
|
|
192
204
|
});
|
|
193
205
|
});
|
|
194
206
|
/* eslint-enable no-underscore-dangle */
|
|
@@ -301,6 +301,9 @@ describe('webex-core', () => {
|
|
|
301
301
|
'example-b': 'https://example-b.com/api/v1',
|
|
302
302
|
'example-c': 'https://example-c.com/api/v1',
|
|
303
303
|
'example-d': 'https://example-d.com/api/v1',
|
|
304
|
+
'example-e': 'https://example-e.com/api/v1',
|
|
305
|
+
'example-f': 'https://example-f.com/api/v1',
|
|
306
|
+
'example-g': 'https://example-g.com/api/v1',
|
|
304
307
|
},
|
|
305
308
|
hostCatalog: {
|
|
306
309
|
'example-a.com': [
|
|
@@ -383,6 +386,48 @@ describe('webex-core', () => {
|
|
|
383
386
|
id: '0:0:0:example-d-x',
|
|
384
387
|
},
|
|
385
388
|
],
|
|
389
|
+
'example-e.com': [
|
|
390
|
+
{
|
|
391
|
+
host: 'example-e-1.com',
|
|
392
|
+
ttl: -1,
|
|
393
|
+
priority: 5,
|
|
394
|
+
id: '0:0:0:different-e',
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
host: 'example-e-2.com',
|
|
398
|
+
ttl: -1,
|
|
399
|
+
priority: 3,
|
|
400
|
+
id: '0:0:0:different-e',
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
host: 'example-e-3.com',
|
|
404
|
+
ttl: -1,
|
|
405
|
+
priority: 1,
|
|
406
|
+
id: '0:0:0:different-e',
|
|
407
|
+
},
|
|
408
|
+
],
|
|
409
|
+
'example-e-1.com': [
|
|
410
|
+
{
|
|
411
|
+
host: 'example-e-4.com',
|
|
412
|
+
ttl: -1,
|
|
413
|
+
priority: 5,
|
|
414
|
+
id: '0:0:0:different-e',
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
host: 'example-e-5.com',
|
|
418
|
+
ttl: -1,
|
|
419
|
+
priority: 3,
|
|
420
|
+
id: '0:0:0:different-e',
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
host: 'example-e-3.com',
|
|
424
|
+
ttl: -1,
|
|
425
|
+
priority: 1,
|
|
426
|
+
id: '0:0:0:different-e-x',
|
|
427
|
+
},
|
|
428
|
+
],
|
|
429
|
+
'example-f.com': [
|
|
430
|
+
],
|
|
386
431
|
},
|
|
387
432
|
format: 'hostmap',
|
|
388
433
|
};
|
|
@@ -440,16 +485,6 @@ describe('webex-core', () => {
|
|
|
440
485
|
});
|
|
441
486
|
});
|
|
442
487
|
|
|
443
|
-
it('creates a formmated host map containing all received host map host entries', () => {
|
|
444
|
-
formattedHM = services._formatReceivedHostmap(serviceHostmap);
|
|
445
|
-
|
|
446
|
-
formattedHM.forEach((service) => {
|
|
447
|
-
const foundHosts = serviceHostmap.hostCatalog[service.defaultHost];
|
|
448
|
-
|
|
449
|
-
assert.isDefined(foundHosts);
|
|
450
|
-
});
|
|
451
|
-
});
|
|
452
|
-
|
|
453
488
|
it('creates an array with matching names', () => {
|
|
454
489
|
formattedHM = services._formatReceivedHostmap(serviceHostmap);
|
|
455
490
|
|
|
@@ -459,6 +494,151 @@ describe('webex-core', () => {
|
|
|
459
494
|
);
|
|
460
495
|
});
|
|
461
496
|
|
|
497
|
+
it('creates the expected formatted host map', () => {
|
|
498
|
+
formattedHM = services._formatReceivedHostmap(serviceHostmap);
|
|
499
|
+
|
|
500
|
+
assert.deepEqual(formattedHM, [
|
|
501
|
+
{
|
|
502
|
+
defaultHost: 'example-a.com',
|
|
503
|
+
defaultUrl: 'https://example-a.com/api/v1',
|
|
504
|
+
hosts: [
|
|
505
|
+
{
|
|
506
|
+
homeCluster: true,
|
|
507
|
+
host: 'example-a-1.com',
|
|
508
|
+
id: '0:0:0:example-a',
|
|
509
|
+
priority: 5,
|
|
510
|
+
ttl: -1,
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
homeCluster: true,
|
|
514
|
+
host: 'example-a-2.com',
|
|
515
|
+
id: '0:0:0:example-a',
|
|
516
|
+
priority: 3,
|
|
517
|
+
ttl: -1,
|
|
518
|
+
},
|
|
519
|
+
],
|
|
520
|
+
name: 'example-a',
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
defaultHost: 'example-b.com',
|
|
524
|
+
defaultUrl: 'https://example-b.com/api/v1',
|
|
525
|
+
hosts: [
|
|
526
|
+
{
|
|
527
|
+
homeCluster: true,
|
|
528
|
+
host: 'example-b-1.com',
|
|
529
|
+
id: '0:0:0:example-b',
|
|
530
|
+
priority: 5,
|
|
531
|
+
ttl: -1,
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
homeCluster: true,
|
|
535
|
+
host: 'example-b-2.com',
|
|
536
|
+
id: '0:0:0:example-b',
|
|
537
|
+
priority: 3,
|
|
538
|
+
ttl: -1,
|
|
539
|
+
},
|
|
540
|
+
],
|
|
541
|
+
name: 'example-b',
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
defaultHost: 'example-c.com',
|
|
545
|
+
defaultUrl: 'https://example-c.com/api/v1',
|
|
546
|
+
hosts: [
|
|
547
|
+
{
|
|
548
|
+
homeCluster: true,
|
|
549
|
+
host: 'example-c-1.com',
|
|
550
|
+
id: '0:0:0:example-c',
|
|
551
|
+
priority: 5,
|
|
552
|
+
ttl: -1,
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
homeCluster: true,
|
|
556
|
+
host: 'example-c-2.com',
|
|
557
|
+
id: '0:0:0:example-c',
|
|
558
|
+
priority: 3,
|
|
559
|
+
ttl: -1,
|
|
560
|
+
},
|
|
561
|
+
],
|
|
562
|
+
name: 'example-c',
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
defaultHost: 'example-d.com',
|
|
566
|
+
defaultUrl: 'https://example-d.com/api/v1',
|
|
567
|
+
hosts: [
|
|
568
|
+
{
|
|
569
|
+
homeCluster: true,
|
|
570
|
+
host: 'example-c-1.com',
|
|
571
|
+
id: '0:0:0:example-d',
|
|
572
|
+
priority: 5,
|
|
573
|
+
ttl: -1,
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
homeCluster: true,
|
|
577
|
+
host: 'example-c-2.com',
|
|
578
|
+
id: '0:0:0:example-d',
|
|
579
|
+
priority: 3,
|
|
580
|
+
ttl: -1,
|
|
581
|
+
},
|
|
582
|
+
],
|
|
583
|
+
name: 'example-d',
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
defaultHost: 'example-e.com',
|
|
587
|
+
defaultUrl: 'https://example-e.com/api/v1',
|
|
588
|
+
hosts: [
|
|
589
|
+
{
|
|
590
|
+
homeCluster: true,
|
|
591
|
+
host: 'example-e-1.com',
|
|
592
|
+
id: '0:0:0:different-e',
|
|
593
|
+
priority: 5,
|
|
594
|
+
ttl: -1,
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
homeCluster: true,
|
|
598
|
+
host: 'example-e-2.com',
|
|
599
|
+
id: '0:0:0:different-e',
|
|
600
|
+
priority: 3,
|
|
601
|
+
ttl: -1,
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
homeCluster: true,
|
|
605
|
+
host: 'example-e-3.com',
|
|
606
|
+
id: '0:0:0:different-e',
|
|
607
|
+
priority: 1,
|
|
608
|
+
ttl: -1,
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
homeCluster: false,
|
|
612
|
+
host: 'example-e-4.com',
|
|
613
|
+
id: '0:0:0:different-e',
|
|
614
|
+
priority: 5,
|
|
615
|
+
ttl: -1,
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
homeCluster: false,
|
|
619
|
+
host: 'example-e-5.com',
|
|
620
|
+
id: '0:0:0:different-e',
|
|
621
|
+
priority: 3,
|
|
622
|
+
ttl: -1,
|
|
623
|
+
},
|
|
624
|
+
],
|
|
625
|
+
name: 'example-e',
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
defaultHost: 'example-f.com',
|
|
629
|
+
defaultUrl: 'https://example-f.com/api/v1',
|
|
630
|
+
hosts: [],
|
|
631
|
+
name: 'example-f',
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
defaultHost: 'example-g.com',
|
|
635
|
+
defaultUrl: 'https://example-g.com/api/v1',
|
|
636
|
+
hosts: [],
|
|
637
|
+
name: 'example-g',
|
|
638
|
+
}
|
|
639
|
+
]);
|
|
640
|
+
});
|
|
641
|
+
|
|
462
642
|
it('has hostCatalog updated', () => {
|
|
463
643
|
services._formatReceivedHostmap(serviceHostmap);
|
|
464
644
|
|