@webex/webex-core 3.0.0-beta.2 → 3.0.0-beta.21
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 -11
- package/dist/config.js.map +1 -1
- package/dist/credentials-config.js +44 -64
- package/dist/credentials-config.js.map +1 -1
- package/dist/index.js +0 -76
- package/dist/index.js.map +1 -1
- package/dist/interceptors/auth.js +22 -55
- package/dist/interceptors/auth.js.map +1 -1
- package/dist/interceptors/default-options.js +0 -20
- package/dist/interceptors/default-options.js.map +1 -1
- package/dist/interceptors/embargo.js +0 -21
- package/dist/interceptors/embargo.js.map +1 -1
- package/dist/interceptors/network-timing.js +2 -21
- package/dist/interceptors/network-timing.js.map +1 -1
- package/dist/interceptors/payload-transformer.js +2 -22
- package/dist/interceptors/payload-transformer.js.map +1 -1
- package/dist/interceptors/rate-limit.js +25 -57
- package/dist/interceptors/rate-limit.js.map +1 -1
- package/dist/interceptors/redirect.js +4 -33
- package/dist/interceptors/redirect.js.map +1 -1
- package/dist/interceptors/request-event.js +3 -30
- package/dist/interceptors/request-event.js.map +1 -1
- package/dist/interceptors/request-logger.js +1 -30
- package/dist/interceptors/request-logger.js.map +1 -1
- package/dist/interceptors/request-timing.js +3 -22
- package/dist/interceptors/request-timing.js.map +1 -1
- package/dist/interceptors/response-logger.js +2 -31
- package/dist/interceptors/response-logger.js.map +1 -1
- package/dist/interceptors/user-agent.js +2 -29
- package/dist/interceptors/user-agent.js.map +1 -1
- package/dist/interceptors/webex-tracking-id.js +5 -28
- package/dist/interceptors/webex-tracking-id.js.map +1 -1
- package/dist/interceptors/webex-user-agent.js +5 -38
- package/dist/interceptors/webex-user-agent.js.map +1 -1
- package/dist/lib/batcher.js +3 -51
- package/dist/lib/batcher.js.map +1 -1
- package/dist/lib/credentials/credentials.js +39 -119
- package/dist/lib/credentials/credentials.js.map +1 -1
- package/dist/lib/credentials/grant-errors.js +0 -49
- package/dist/lib/credentials/grant-errors.js.map +1 -1
- package/dist/lib/credentials/index.js +1 -13
- package/dist/lib/credentials/index.js.map +1 -1
- package/dist/lib/credentials/scope.js +1 -7
- package/dist/lib/credentials/scope.js.map +1 -1
- package/dist/lib/credentials/token-collection.js +1 -7
- package/dist/lib/credentials/token-collection.js.map +1 -1
- package/dist/lib/credentials/token.js +39 -118
- package/dist/lib/credentials/token.js.map +1 -1
- package/dist/lib/page.js +13 -26
- package/dist/lib/page.js.map +1 -1
- package/dist/lib/services/constants.js +0 -2
- package/dist/lib/services/constants.js.map +1 -1
- package/dist/lib/services/index.js +1 -28
- package/dist/lib/services/index.js.map +1 -1
- package/dist/lib/services/interceptors/server-error.js +2 -23
- package/dist/lib/services/interceptors/server-error.js.map +1 -1
- package/dist/lib/services/interceptors/service.js +12 -34
- package/dist/lib/services/interceptors/service.js.map +1 -1
- package/dist/lib/services/metrics.js +0 -2
- package/dist/lib/services/metrics.js.map +1 -1
- package/dist/lib/services/service-catalog.js +10 -90
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/service-fed-ramp.js +0 -2
- package/dist/lib/services/service-fed-ramp.js.map +1 -1
- package/dist/lib/services/service-host.js +47 -62
- package/dist/lib/services/service-host.js.map +1 -1
- package/dist/lib/services/service-registry.js +78 -90
- package/dist/lib/services/service-registry.js.map +1 -1
- package/dist/lib/services/service-state.js +3 -15
- package/dist/lib/services/service-state.js.map +1 -1
- package/dist/lib/services/service-url.js +4 -25
- package/dist/lib/services/service-url.js.map +1 -1
- package/dist/lib/services/services.js +122 -238
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/stateless-webex-plugin.js +5 -28
- package/dist/lib/stateless-webex-plugin.js.map +1 -1
- package/dist/lib/storage/decorators.js +19 -62
- package/dist/lib/storage/decorators.js.map +1 -1
- package/dist/lib/storage/errors.js +0 -23
- package/dist/lib/storage/errors.js.map +1 -1
- package/dist/lib/storage/index.js +2 -16
- package/dist/lib/storage/index.js.map +1 -1
- package/dist/lib/storage/make-webex-plugin-store.js +11 -41
- package/dist/lib/storage/make-webex-plugin-store.js.map +1 -1
- package/dist/lib/storage/make-webex-store.js +8 -30
- package/dist/lib/storage/make-webex-store.js.map +1 -1
- package/dist/lib/storage/memory-store-adapter.js +1 -19
- package/dist/lib/storage/memory-store-adapter.js.map +1 -1
- package/dist/lib/webex-core-plugin-mixin.js +9 -29
- package/dist/lib/webex-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-http-error.js +1 -31
- package/dist/lib/webex-http-error.js.map +1 -1
- package/dist/lib/webex-internal-core-plugin-mixin.js +9 -29
- package/dist/lib/webex-internal-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-plugin.js +6 -40
- package/dist/lib/webex-plugin.js.map +1 -1
- package/dist/plugins/logger.js +3 -17
- package/dist/plugins/logger.js.map +1 -1
- package/dist/webex-core.js +79 -203
- package/dist/webex-core.js.map +1 -1
- package/dist/webex-internal-core.js +0 -10
- package/dist/webex-internal-core.js.map +1 -1
- package/package.json +14 -14
- package/src/config.js +9 -11
- package/src/credentials-config.js +110 -72
- package/src/index.js +4 -14
- package/src/interceptors/auth.js +36 -37
- package/src/interceptors/default-options.js +0 -1
- package/src/interceptors/embargo.js +1 -1
- package/src/interceptors/payload-transformer.js +1 -2
- package/src/interceptors/rate-limit.js +8 -5
- package/src/interceptors/redirect.js +14 -8
- package/src/interceptors/request-event.js +4 -8
- package/src/interceptors/request-logger.js +8 -5
- package/src/interceptors/response-logger.js +11 -8
- package/src/interceptors/user-agent.js +1 -2
- package/src/interceptors/webex-user-agent.js +3 -9
- package/src/lib/batcher.js +70 -69
- package/src/lib/credentials/credentials.js +112 -122
- package/src/lib/credentials/grant-errors.js +6 -7
- package/src/lib/credentials/index.js +1 -4
- package/src/lib/credentials/scope.js +1 -4
- package/src/lib/credentials/token-collection.js +1 -1
- package/src/lib/credentials/token.js +86 -80
- package/src/lib/page.js +10 -11
- package/src/lib/services/constants.js +3 -13
- package/src/lib/services/index.js +2 -2
- package/src/lib/services/interceptors/server-error.js +12 -7
- package/src/lib/services/interceptors/service.js +6 -5
- package/src/lib/services/metrics.js +1 -1
- package/src/lib/services/service-catalog.js +110 -100
- package/src/lib/services/service-fed-ramp.js +1 -2
- package/src/lib/services/service-host.js +10 -17
- package/src/lib/services/service-registry.js +69 -96
- package/src/lib/services/service-state.js +4 -6
- package/src/lib/services/service-url.js +24 -23
- package/src/lib/services/services.js +260 -251
- package/src/lib/stateless-webex-plugin.js +4 -2
- package/src/lib/storage/decorators.js +68 -66
- package/src/lib/storage/index.js +4 -6
- package/src/lib/storage/make-webex-plugin-store.js +34 -21
- package/src/lib/storage/make-webex-store.js +6 -7
- package/src/lib/storage/memory-store-adapter.js +3 -3
- package/src/lib/webex-core-plugin-mixin.js +10 -7
- package/src/lib/webex-http-error.js +7 -8
- package/src/lib/webex-internal-core-plugin-mixin.js +9 -6
- package/src/lib/webex-plugin.js +41 -34
- package/src/plugins/logger.js +8 -3
- package/src/webex-core.js +185 -116
- package/src/webex-internal-core.js +15 -9
- package/test/integration/spec/credentials/credentials.js +26 -30
- package/test/integration/spec/credentials/token.js +36 -33
- package/test/integration/spec/services/service-catalog.js +177 -156
- package/test/integration/spec/services/services.js +313 -304
- package/test/integration/spec/webex-core.js +98 -86
- package/test/unit/spec/_setup.js +26 -18
- package/test/unit/spec/credentials/credentials.js +189 -154
- package/test/unit/spec/credentials/token.js +94 -76
- package/test/unit/spec/interceptors/auth.js +291 -243
- package/test/unit/spec/interceptors/default-options.js +36 -24
- package/test/unit/spec/interceptors/embargo.js +32 -27
- package/test/unit/spec/interceptors/network-timing.js +2 -2
- package/test/unit/spec/interceptors/payload-transformer.js +61 -52
- package/test/unit/spec/interceptors/rate-limit.js +104 -75
- package/test/unit/spec/interceptors/redirect.js +22 -20
- package/test/unit/spec/interceptors/request-timing.js +18 -22
- package/test/unit/spec/interceptors/user-agent.js +28 -16
- package/test/unit/spec/interceptors/webex-tracking-id.js +14 -8
- package/test/unit/spec/interceptors/webex-user-agent.js +83 -37
- package/test/unit/spec/lib/batcher.js +36 -32
- package/test/unit/spec/lib/page.js +36 -32
- package/test/unit/spec/lib/webex-plugin.js +1 -1
- package/test/unit/spec/services/interceptors/server-error.js +67 -90
- package/test/unit/spec/services/interceptors/service.js +17 -28
- package/test/unit/spec/services/service-catalog.js +19 -27
- package/test/unit/spec/services/service-host.js +29 -26
- package/test/unit/spec/services/service-registry.js +128 -170
- package/test/unit/spec/services/service-state.js +13 -22
- package/test/unit/spec/services/service-url.js +24 -43
- package/test/unit/spec/services/services.js +85 -41
- package/test/unit/spec/storage/persist.js +6 -9
- package/test/unit/spec/storage/wait-for-value.js +22 -21
- package/test/unit/spec/webex-core.js +78 -57
- package/test/unit/spec/webex-internal-core.js +56 -31
|
@@ -17,22 +17,30 @@ describe('webex-core', () => {
|
|
|
17
17
|
let services;
|
|
18
18
|
let catalog;
|
|
19
19
|
|
|
20
|
-
before('create users', () =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
before('create users', () =>
|
|
21
|
+
testUsers
|
|
22
|
+
.create({count: 1})
|
|
23
|
+
.then(
|
|
24
|
+
([user]) =>
|
|
25
|
+
new Promise((resolve) => {
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
webexUser = user;
|
|
28
|
+
webex = new WebexCore({credentials: user.token});
|
|
29
|
+
services = webex.internal.services;
|
|
30
|
+
catalog = services._getCatalog();
|
|
31
|
+
resolve();
|
|
32
|
+
}, 1000);
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
.then(() => webex.internal.device.register())
|
|
36
|
+
.then(() => services.waitForCatalog('postauth', 10))
|
|
37
|
+
.then(() =>
|
|
38
|
+
services.updateServices({
|
|
39
|
+
from: 'limited',
|
|
40
|
+
query: {userId: webexUser.id},
|
|
41
|
+
})
|
|
42
|
+
)
|
|
43
|
+
);
|
|
36
44
|
|
|
37
45
|
describe('#status()', () => {
|
|
38
46
|
it('updates ready when services ready', () => {
|
|
@@ -48,7 +56,7 @@ describe('webex-core', () => {
|
|
|
48
56
|
testUrlTemplate = {
|
|
49
57
|
defaultUrl: 'https://www.example.com/api/v1',
|
|
50
58
|
hosts: [],
|
|
51
|
-
name: 'exampleValid'
|
|
59
|
+
name: 'exampleValid',
|
|
52
60
|
};
|
|
53
61
|
testUrl = new ServiceUrl({...testUrlTemplate});
|
|
54
62
|
catalog._loadServiceUrls('preauth', [testUrl]);
|
|
@@ -66,13 +74,13 @@ describe('webex-core', () => {
|
|
|
66
74
|
assert.equal(serviceUrl.name, testUrlTemplate.name);
|
|
67
75
|
});
|
|
68
76
|
|
|
69
|
-
it(
|
|
77
|
+
it("returns undefined if url doesn't exist", () => {
|
|
70
78
|
const serviceUrl = catalog._getUrl('invalidUrl');
|
|
71
79
|
|
|
72
80
|
assert.typeOf(serviceUrl, 'undefined');
|
|
73
81
|
});
|
|
74
82
|
|
|
75
|
-
it(
|
|
83
|
+
it("returns undefined if url doesn't exist in serviceGroup", () => {
|
|
76
84
|
const serviceUrl = catalog._getUrl(testUrlTemplate.name, 'Discovery');
|
|
77
85
|
|
|
78
86
|
assert.typeOf(serviceUrl, 'undefined');
|
|
@@ -92,24 +100,24 @@ describe('webex-core', () => {
|
|
|
92
100
|
ttl: -1,
|
|
93
101
|
priority: 5,
|
|
94
102
|
homeCluster: false,
|
|
95
|
-
id: '0:0:0:exampleClusterIdFind'
|
|
103
|
+
id: '0:0:0:exampleClusterIdFind',
|
|
96
104
|
},
|
|
97
105
|
{
|
|
98
106
|
host: 'www.example-p3.com',
|
|
99
107
|
ttl: -1,
|
|
100
108
|
priority: 3,
|
|
101
109
|
homeCluster: true,
|
|
102
|
-
id: '0:0:0:exampleClusterIdFind'
|
|
110
|
+
id: '0:0:0:exampleClusterIdFind',
|
|
103
111
|
},
|
|
104
112
|
{
|
|
105
113
|
host: 'www.example-p6.com',
|
|
106
114
|
ttl: -1,
|
|
107
115
|
priority: 6,
|
|
108
116
|
homeCluster: true,
|
|
109
|
-
id: '0:0:2:exampleClusterIdFind'
|
|
110
|
-
}
|
|
117
|
+
id: '0:0:2:exampleClusterIdFind',
|
|
118
|
+
},
|
|
111
119
|
],
|
|
112
|
-
name: 'exampleClusterIdFind'
|
|
120
|
+
name: 'exampleClusterIdFind',
|
|
113
121
|
};
|
|
114
122
|
testUrl = new ServiceUrl({...testUrlTemplate});
|
|
115
123
|
catalog._loadServiceUrls('preauth', [testUrl]);
|
|
@@ -120,25 +128,28 @@ describe('webex-core', () => {
|
|
|
120
128
|
});
|
|
121
129
|
|
|
122
130
|
it('returns a home cluster clusterId when found with default url', () => {
|
|
123
|
-
assert.equal(
|
|
124
|
-
testUrlTemplate.
|
|
131
|
+
assert.equal(
|
|
132
|
+
catalog.findClusterId(testUrlTemplate.defaultUrl),
|
|
133
|
+
testUrlTemplate.hosts[1].id
|
|
134
|
+
);
|
|
125
135
|
});
|
|
126
136
|
|
|
127
137
|
it('returns a clusterId when found with priority host url', () => {
|
|
128
|
-
assert.equal(catalog.findClusterId(testUrl.get(true)),
|
|
129
|
-
testUrlTemplate.hosts[0].id);
|
|
138
|
+
assert.equal(catalog.findClusterId(testUrl.get(true)), testUrlTemplate.hosts[0].id);
|
|
130
139
|
});
|
|
131
140
|
|
|
132
141
|
it('returns a clusterId when found with resource-appended url', () => {
|
|
133
|
-
assert.equal(
|
|
134
|
-
|
|
142
|
+
assert.equal(
|
|
143
|
+
catalog.findClusterId(`${testUrl.get()}example/resource/value`),
|
|
144
|
+
testUrlTemplate.hosts[0].id
|
|
145
|
+
);
|
|
135
146
|
});
|
|
136
147
|
|
|
137
|
-
it(
|
|
148
|
+
it("returns undefined when the url doesn't exist in catalog", () => {
|
|
138
149
|
assert.isUndefined(catalog.findClusterId('http://not-a-known-url.com/'));
|
|
139
150
|
});
|
|
140
151
|
|
|
141
|
-
it(
|
|
152
|
+
it("returns undefined when the string isn't a url", () => {
|
|
142
153
|
assert.isUndefined(catalog.findClusterId('not a url'));
|
|
143
154
|
});
|
|
144
155
|
});
|
|
@@ -156,16 +167,16 @@ describe('webex-core', () => {
|
|
|
156
167
|
host: 'www.example-p5.com',
|
|
157
168
|
ttl: -1,
|
|
158
169
|
priority: 5,
|
|
159
|
-
id: '0:0:clusterA:example-test'
|
|
170
|
+
id: '0:0:clusterA:example-test',
|
|
160
171
|
},
|
|
161
172
|
{
|
|
162
173
|
host: 'www.example-p3.com',
|
|
163
174
|
ttl: -1,
|
|
164
175
|
priority: 3,
|
|
165
|
-
id: '0:0:clusterB:example-test'
|
|
166
|
-
}
|
|
176
|
+
id: '0:0:clusterB:example-test',
|
|
177
|
+
},
|
|
167
178
|
],
|
|
168
|
-
name: 'example-test'
|
|
179
|
+
name: 'example-test',
|
|
169
180
|
};
|
|
170
181
|
testUrl = new ServiceUrl({...testUrlTemplate});
|
|
171
182
|
catalog._loadServiceUrls('preauth', [testUrl]);
|
|
@@ -178,7 +189,7 @@ describe('webex-core', () => {
|
|
|
178
189
|
it('finds a valid service url from only a clusterId', () => {
|
|
179
190
|
const serviceFound = catalog.findServiceFromClusterId({
|
|
180
191
|
clusterId: testUrlTemplate.hosts[0].id,
|
|
181
|
-
priorityHost: false
|
|
192
|
+
priorityHost: false,
|
|
182
193
|
});
|
|
183
194
|
|
|
184
195
|
assert.equal(serviceFound.name, testUrl.name);
|
|
@@ -188,7 +199,7 @@ describe('webex-core', () => {
|
|
|
188
199
|
it('finds a valid priority service url', () => {
|
|
189
200
|
const serviceFound = catalog.findServiceFromClusterId({
|
|
190
201
|
clusterId: testUrlTemplate.hosts[0].id,
|
|
191
|
-
priorityHost: true
|
|
202
|
+
priorityHost: true,
|
|
192
203
|
});
|
|
193
204
|
|
|
194
205
|
assert.equal(serviceFound.name, testUrl.name);
|
|
@@ -199,31 +210,29 @@ describe('webex-core', () => {
|
|
|
199
210
|
const serviceFound = catalog.findServiceFromClusterId({
|
|
200
211
|
clusterId: testUrlTemplate.hosts[0].id,
|
|
201
212
|
priorityHost: false,
|
|
202
|
-
serviceGroup: 'preauth'
|
|
213
|
+
serviceGroup: 'preauth',
|
|
203
214
|
});
|
|
204
215
|
|
|
205
216
|
assert.equal(serviceFound.name, testUrl.name);
|
|
206
217
|
assert.equal(serviceFound.url, testUrl.defaultUrl);
|
|
207
218
|
});
|
|
208
219
|
|
|
209
|
-
it(
|
|
220
|
+
it("fails to find a valid service when it's not in a group", () => {
|
|
210
221
|
assert.isUndefined(
|
|
211
222
|
catalog.findServiceFromClusterId({
|
|
212
223
|
clusterId: testUrlTemplate.hosts[0].id,
|
|
213
|
-
serviceGroup: 'signin'
|
|
224
|
+
serviceGroup: 'signin',
|
|
214
225
|
})
|
|
215
226
|
);
|
|
216
227
|
});
|
|
217
228
|
|
|
218
|
-
it(
|
|
219
|
-
assert.isUndefined(
|
|
220
|
-
catalog.findServiceFromClusterId({clusterId: 'not a clusterId'})
|
|
221
|
-
);
|
|
229
|
+
it("returns undefined when service doesn't exist", () => {
|
|
230
|
+
assert.isUndefined(catalog.findServiceFromClusterId({clusterId: 'not a clusterId'}));
|
|
222
231
|
});
|
|
223
232
|
|
|
224
233
|
it('should return a remote cluster url with a remote clusterId', () => {
|
|
225
234
|
const serviceFound = catalog.findServiceFromClusterId({
|
|
226
|
-
clusterId: testUrlTemplate.hosts[1].id
|
|
235
|
+
clusterId: testUrlTemplate.hosts[1].id,
|
|
227
236
|
});
|
|
228
237
|
|
|
229
238
|
assert.equal(serviceFound.name, testUrl.name);
|
|
@@ -244,16 +253,16 @@ describe('webex-core', () => {
|
|
|
244
253
|
host: 'www.example-p5.com',
|
|
245
254
|
ttl: -1,
|
|
246
255
|
priority: 5,
|
|
247
|
-
id: 'exampleClusterId'
|
|
256
|
+
id: 'exampleClusterId',
|
|
248
257
|
},
|
|
249
258
|
{
|
|
250
259
|
host: 'www.example-p3.com',
|
|
251
260
|
ttl: -1,
|
|
252
261
|
priority: 3,
|
|
253
|
-
id: 'exampleClusterId'
|
|
254
|
-
}
|
|
262
|
+
id: 'exampleClusterId',
|
|
263
|
+
},
|
|
255
264
|
],
|
|
256
|
-
name: 'exampleValid'
|
|
265
|
+
name: 'exampleValid',
|
|
257
266
|
};
|
|
258
267
|
testUrl = new ServiceUrl({...testUrlTemplate});
|
|
259
268
|
catalog._loadServiceUrls('preauth', [testUrl]);
|
|
@@ -264,20 +273,14 @@ describe('webex-core', () => {
|
|
|
264
273
|
});
|
|
265
274
|
|
|
266
275
|
it('finds a service if it exists', () => {
|
|
267
|
-
assert.equal(
|
|
268
|
-
catalog.findServiceUrlFromUrl(testUrlTemplate.defaultUrl),
|
|
269
|
-
testUrl
|
|
270
|
-
);
|
|
276
|
+
assert.equal(catalog.findServiceUrlFromUrl(testUrlTemplate.defaultUrl), testUrl);
|
|
271
277
|
});
|
|
272
278
|
|
|
273
279
|
it('finds a service if its a priority host url', () => {
|
|
274
|
-
assert.equal(
|
|
275
|
-
catalog.findServiceUrlFromUrl(testUrl.get(true)).name,
|
|
276
|
-
testUrl.name
|
|
277
|
-
);
|
|
280
|
+
assert.equal(catalog.findServiceUrlFromUrl(testUrl.get(true)).name, testUrl.name);
|
|
278
281
|
});
|
|
279
282
|
|
|
280
|
-
it(
|
|
283
|
+
it("returns undefined if the url doesn't exist", () => {
|
|
281
284
|
assert.isUndefined(catalog.findServiceUrlFromUrl('https://na.com/'));
|
|
282
285
|
});
|
|
283
286
|
|
|
@@ -290,11 +293,9 @@ describe('webex-core', () => {
|
|
|
290
293
|
it('retreives priority host urls base on priorityHost parameter', () => {
|
|
291
294
|
const serviceList = catalog.list(true);
|
|
292
295
|
|
|
293
|
-
const foundPriorityValues = catalog.serviceGroups.postauth.some(
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
(key) => serviceList[key].includes(host)
|
|
297
|
-
)
|
|
296
|
+
const foundPriorityValues = catalog.serviceGroups.postauth.some((serviceUrl) =>
|
|
297
|
+
serviceUrl.hosts.some(({host}) =>
|
|
298
|
+
Object.keys(serviceList).some((key) => serviceList[key].includes(host))
|
|
298
299
|
)
|
|
299
300
|
);
|
|
300
301
|
|
|
@@ -304,18 +305,15 @@ describe('webex-core', () => {
|
|
|
304
305
|
it('returns an object of based on serviceGroup parameter', () => {
|
|
305
306
|
let serviceList = catalog.list(true, 'discovery');
|
|
306
307
|
|
|
307
|
-
assert.equal(Object.keys(serviceList).length,
|
|
308
|
-
catalog.serviceGroups.discovery.length);
|
|
308
|
+
assert.equal(Object.keys(serviceList).length, catalog.serviceGroups.discovery.length);
|
|
309
309
|
|
|
310
310
|
serviceList = catalog.list(true, 'preauth');
|
|
311
311
|
|
|
312
|
-
assert.equal(Object.keys(serviceList).length,
|
|
313
|
-
catalog.serviceGroups.preauth.length);
|
|
312
|
+
assert.equal(Object.keys(serviceList).length, catalog.serviceGroups.preauth.length);
|
|
314
313
|
|
|
315
314
|
serviceList = catalog.list(true, 'postauth');
|
|
316
315
|
|
|
317
|
-
assert.isAtLeast(Object.keys(serviceList).length,
|
|
318
|
-
catalog.serviceGroups.postauth.length);
|
|
316
|
+
assert.isAtLeast(Object.keys(serviceList).length, catalog.serviceGroups.postauth.length);
|
|
319
317
|
});
|
|
320
318
|
|
|
321
319
|
it('matches the values in serviceUrl', () => {
|
|
@@ -328,13 +326,11 @@ describe('webex-core', () => {
|
|
|
328
326
|
serviceList = catalog.list(true, 'postauth');
|
|
329
327
|
|
|
330
328
|
Object.keys(serviceList).forEach((key) => {
|
|
331
|
-
assert.equal(serviceList[key],
|
|
332
|
-
catalog._getUrl(key, 'postauth').get(true));
|
|
329
|
+
assert.equal(serviceList[key], catalog._getUrl(key, 'postauth').get(true));
|
|
333
330
|
});
|
|
334
331
|
});
|
|
335
332
|
});
|
|
336
333
|
|
|
337
|
-
|
|
338
334
|
describe('#get()', () => {
|
|
339
335
|
let testUrlTemplate;
|
|
340
336
|
let testUrl;
|
|
@@ -343,7 +339,7 @@ describe('webex-core', () => {
|
|
|
343
339
|
testUrlTemplate = {
|
|
344
340
|
defaultUrl: 'https://www.example.com/api/v1',
|
|
345
341
|
hosts: [],
|
|
346
|
-
name: 'exampleValid'
|
|
342
|
+
name: 'exampleValid',
|
|
347
343
|
};
|
|
348
344
|
testUrl = new ServiceUrl({...testUrlTemplate});
|
|
349
345
|
catalog._loadServiceUrls('preauth', [testUrl]);
|
|
@@ -360,7 +356,7 @@ describe('webex-core', () => {
|
|
|
360
356
|
assert.equal(url, testUrlTemplate.defaultUrl);
|
|
361
357
|
});
|
|
362
358
|
|
|
363
|
-
it(
|
|
359
|
+
it("returns undefined if url doesn't exist", () => {
|
|
364
360
|
const s = catalog.get('invalidUrl');
|
|
365
361
|
|
|
366
362
|
assert.typeOf(s, 'undefined');
|
|
@@ -378,9 +374,8 @@ describe('webex-core', () => {
|
|
|
378
374
|
assert.isDefined(catalog.get(testUrlTemplate.name, false, 'preauth'));
|
|
379
375
|
});
|
|
380
376
|
|
|
381
|
-
it(
|
|
382
|
-
assert.isUndefined(catalog.get(testUrlTemplate.name,
|
|
383
|
-
false, 'discovery'));
|
|
377
|
+
it("fails to get a service if serviceGroup isn't accurate", () => {
|
|
378
|
+
assert.isUndefined(catalog.get(testUrlTemplate.name, false, 'discovery'));
|
|
384
379
|
});
|
|
385
380
|
});
|
|
386
381
|
|
|
@@ -397,17 +392,17 @@ describe('webex-core', () => {
|
|
|
397
392
|
ttl: -1,
|
|
398
393
|
priority: 5,
|
|
399
394
|
id: '0:0:0:exampleValid',
|
|
400
|
-
homeCluster: true
|
|
395
|
+
homeCluster: true,
|
|
401
396
|
},
|
|
402
397
|
{
|
|
403
398
|
host: 'www.example-p3.com',
|
|
404
399
|
ttl: -1,
|
|
405
400
|
priority: 3,
|
|
406
401
|
id: '0:0:0:exampleValid',
|
|
407
|
-
homeCluster: true
|
|
408
|
-
}
|
|
402
|
+
homeCluster: true,
|
|
403
|
+
},
|
|
409
404
|
],
|
|
410
|
-
name: 'exampleValid'
|
|
405
|
+
name: 'exampleValid',
|
|
411
406
|
};
|
|
412
407
|
testUrl = new ServiceUrl({...testUrlTemplate});
|
|
413
408
|
catalog._loadServiceUrls('preauth', [testUrl]);
|
|
@@ -422,9 +417,7 @@ describe('webex-core', () => {
|
|
|
422
417
|
|
|
423
418
|
catalog.markFailedUrl(priorityUrl);
|
|
424
419
|
|
|
425
|
-
const failedHost = testUrl.hosts.find(
|
|
426
|
-
(host) => host.failed
|
|
427
|
-
);
|
|
420
|
+
const failedHost = testUrl.hosts.find((host) => host.failed);
|
|
428
421
|
|
|
429
422
|
assert.isDefined(failedHost);
|
|
430
423
|
});
|
|
@@ -445,7 +438,7 @@ describe('webex-core', () => {
|
|
|
445
438
|
testUrlTemplate = {
|
|
446
439
|
defaultUrl: 'https://www.example.com/api/v1',
|
|
447
440
|
hosts: [],
|
|
448
|
-
name: 'exampleValid'
|
|
441
|
+
name: 'exampleValid',
|
|
449
442
|
};
|
|
450
443
|
testUrl = new ServiceUrl({...testUrlTemplate});
|
|
451
444
|
});
|
|
@@ -473,7 +466,7 @@ describe('webex-core', () => {
|
|
|
473
466
|
testUrlTemplate = {
|
|
474
467
|
defaultUrl: 'https://www.example.com/api/v1',
|
|
475
468
|
hosts: [],
|
|
476
|
-
name: 'exampleValid'
|
|
469
|
+
name: 'exampleValid',
|
|
477
470
|
};
|
|
478
471
|
testUrl = new ServiceUrl({...testUrlTemplate});
|
|
479
472
|
});
|
|
@@ -493,8 +486,7 @@ describe('webex-core', () => {
|
|
|
493
486
|
|
|
494
487
|
assert.isAbove(oBaseLength, catalog.serviceGroups.postauth.length);
|
|
495
488
|
assert.isAbove(oLimitedLength, catalog.serviceGroups.preauth.length);
|
|
496
|
-
assert.isAbove(oDiscoveryLength,
|
|
497
|
-
catalog.serviceGroups.discovery.length);
|
|
489
|
+
assert.isAbove(oDiscoveryLength, catalog.serviceGroups.discovery.length);
|
|
498
490
|
});
|
|
499
491
|
});
|
|
500
492
|
|
|
@@ -502,19 +494,20 @@ describe('webex-core', () => {
|
|
|
502
494
|
let fullRemoteHM;
|
|
503
495
|
let limitedRemoteHM;
|
|
504
496
|
|
|
505
|
-
beforeEach(() =>
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
.then(([fRHM, lRHM]) => {
|
|
497
|
+
beforeEach(() =>
|
|
498
|
+
Promise.all([
|
|
499
|
+
services._fetchNewServiceHostmap(),
|
|
500
|
+
services._fetchNewServiceHostmap({
|
|
501
|
+
from: 'limited',
|
|
502
|
+
query: {userId: webexUser.id},
|
|
503
|
+
}),
|
|
504
|
+
]).then(([fRHM, lRHM]) => {
|
|
513
505
|
fullRemoteHM = fRHM;
|
|
514
506
|
limitedRemoteHM = lRHM;
|
|
515
507
|
|
|
516
508
|
return Promise.resolve();
|
|
517
|
-
})
|
|
509
|
+
})
|
|
510
|
+
);
|
|
518
511
|
|
|
519
512
|
it('resolves to an authed u2c hostmap when no params specified', () => {
|
|
520
513
|
assert.typeOf(fullRemoteHM, 'array');
|
|
@@ -526,11 +519,12 @@ describe('webex-core', () => {
|
|
|
526
519
|
assert.isAbove(limitedRemoteHM.length, 0);
|
|
527
520
|
});
|
|
528
521
|
|
|
529
|
-
it('rejects if the params provided are invalid', () =>
|
|
530
|
-
services
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
522
|
+
it('rejects if the params provided are invalid', () =>
|
|
523
|
+
services
|
|
524
|
+
._fetchNewServiceHostmap({
|
|
525
|
+
from: 'limited',
|
|
526
|
+
query: {userId: 'notValid'},
|
|
527
|
+
})
|
|
534
528
|
.then(() => {
|
|
535
529
|
assert.isTrue(false, 'should have rejected');
|
|
536
530
|
|
|
@@ -540,8 +534,7 @@ describe('webex-core', () => {
|
|
|
540
534
|
assert.typeOf(e, 'Error');
|
|
541
535
|
|
|
542
536
|
return Promise.resolve();
|
|
543
|
-
})
|
|
544
|
-
));
|
|
537
|
+
}));
|
|
545
538
|
});
|
|
546
539
|
|
|
547
540
|
describe('#waitForCatalog()', () => {
|
|
@@ -554,7 +547,7 @@ describe('webex-core', () => {
|
|
|
554
547
|
serviceLinks: {
|
|
555
548
|
'example-a': 'https://example-a.com/api/v1',
|
|
556
549
|
'example-b': 'https://example-b.com/api/v1',
|
|
557
|
-
'example-c': 'https://example-c.com/api/v1'
|
|
550
|
+
'example-c': 'https://example-c.com/api/v1',
|
|
558
551
|
},
|
|
559
552
|
hostCatalog: {
|
|
560
553
|
'example-a.com': [
|
|
@@ -562,63 +555,63 @@ describe('webex-core', () => {
|
|
|
562
555
|
host: 'example-a-1.com',
|
|
563
556
|
ttl: -1,
|
|
564
557
|
priority: 5,
|
|
565
|
-
id: '0:0:0:example-a'
|
|
558
|
+
id: '0:0:0:example-a',
|
|
566
559
|
},
|
|
567
560
|
{
|
|
568
561
|
host: 'example-a-2.com',
|
|
569
562
|
ttl: -1,
|
|
570
563
|
priority: 3,
|
|
571
|
-
id: '0:0:0:example-a'
|
|
564
|
+
id: '0:0:0:example-a',
|
|
572
565
|
},
|
|
573
566
|
{
|
|
574
567
|
host: 'example-a-3.com',
|
|
575
568
|
ttl: -1,
|
|
576
569
|
priority: 1,
|
|
577
|
-
id: '0:0:0:example-a'
|
|
578
|
-
}
|
|
570
|
+
id: '0:0:0:example-a',
|
|
571
|
+
},
|
|
579
572
|
],
|
|
580
573
|
'example-b.com': [
|
|
581
574
|
{
|
|
582
575
|
host: 'example-b-1.com',
|
|
583
576
|
ttl: -1,
|
|
584
577
|
priority: 5,
|
|
585
|
-
id: '0:0:0:example-b'
|
|
578
|
+
id: '0:0:0:example-b',
|
|
586
579
|
},
|
|
587
580
|
{
|
|
588
581
|
host: 'example-b-2.com',
|
|
589
582
|
ttl: -1,
|
|
590
583
|
priority: 3,
|
|
591
|
-
id: '0:0:0:example-b'
|
|
584
|
+
id: '0:0:0:example-b',
|
|
592
585
|
},
|
|
593
586
|
{
|
|
594
587
|
host: 'example-b-3.com',
|
|
595
588
|
ttl: -1,
|
|
596
589
|
priority: 1,
|
|
597
|
-
id: '0:0:0:example-b'
|
|
598
|
-
}
|
|
590
|
+
id: '0:0:0:example-b',
|
|
591
|
+
},
|
|
599
592
|
],
|
|
600
593
|
'example-c.com': [
|
|
601
594
|
{
|
|
602
595
|
host: 'example-c-1.com',
|
|
603
596
|
ttl: -1,
|
|
604
597
|
priority: 5,
|
|
605
|
-
id: '0:0:0:example-c'
|
|
598
|
+
id: '0:0:0:example-c',
|
|
606
599
|
},
|
|
607
600
|
{
|
|
608
601
|
host: 'example-c-2.com',
|
|
609
602
|
ttl: -1,
|
|
610
603
|
priority: 3,
|
|
611
|
-
id: '0:0:0:example-c'
|
|
604
|
+
id: '0:0:0:example-c',
|
|
612
605
|
},
|
|
613
606
|
{
|
|
614
607
|
host: 'example-c-3.com',
|
|
615
608
|
ttl: -1,
|
|
616
609
|
priority: 1,
|
|
617
|
-
id: '0:0:0:example-c'
|
|
618
|
-
}
|
|
619
|
-
]
|
|
610
|
+
id: '0:0:0:example-c',
|
|
611
|
+
},
|
|
612
|
+
],
|
|
620
613
|
},
|
|
621
|
-
format: 'hostmap'
|
|
614
|
+
format: 'hostmap',
|
|
622
615
|
};
|
|
623
616
|
formattedHM = services._formatReceivedHostmap(serviceHostmap);
|
|
624
617
|
|
|
@@ -629,18 +622,17 @@ describe('webex-core', () => {
|
|
|
629
622
|
assert.typeOf(promise, 'promise');
|
|
630
623
|
});
|
|
631
624
|
|
|
632
|
-
it('returns a rejected promise if timeout is reached',
|
|
633
|
-
|
|
625
|
+
it('returns a rejected promise if timeout is reached', () =>
|
|
626
|
+
promise.catch(() => {
|
|
634
627
|
assert(true, 'promise rejected');
|
|
635
628
|
|
|
636
629
|
return Promise.resolve();
|
|
637
630
|
}));
|
|
638
631
|
|
|
639
632
|
it('returns a resolved promise once ready', () => {
|
|
640
|
-
catalog.waitForCatalog('postauth', 1)
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
});
|
|
633
|
+
catalog.waitForCatalog('postauth', 1).then(() => {
|
|
634
|
+
assert(true, 'promise resolved');
|
|
635
|
+
});
|
|
644
636
|
|
|
645
637
|
catalog.updateServiceUrls('postauth', formattedHM);
|
|
646
638
|
});
|
|
@@ -655,44 +647,71 @@ describe('webex-core', () => {
|
|
|
655
647
|
serviceLinks: {
|
|
656
648
|
'example-a': 'https://example-a.com/api/v1',
|
|
657
649
|
'example-b': 'https://example-b.com/api/v1',
|
|
658
|
-
'example-c': 'https://example-c.com/api/v1'
|
|
650
|
+
'example-c': 'https://example-c.com/api/v1',
|
|
659
651
|
},
|
|
660
652
|
hostCatalog: {
|
|
661
653
|
'example-a.com': [
|
|
662
654
|
{
|
|
663
|
-
host: 'example-a-1.com',
|
|
655
|
+
host: 'example-a-1.com',
|
|
656
|
+
ttl: -1,
|
|
657
|
+
priority: 5,
|
|
658
|
+
id: '0:0:0:example-a',
|
|
664
659
|
},
|
|
665
660
|
{
|
|
666
|
-
host: 'example-a-2.com',
|
|
661
|
+
host: 'example-a-2.com',
|
|
662
|
+
ttl: -1,
|
|
663
|
+
priority: 3,
|
|
664
|
+
id: '0:0:0:example-a',
|
|
667
665
|
},
|
|
668
666
|
{
|
|
669
|
-
host: 'example-a-3.com',
|
|
670
|
-
|
|
667
|
+
host: 'example-a-3.com',
|
|
668
|
+
ttl: -1,
|
|
669
|
+
priority: 1,
|
|
670
|
+
id: '0:0:0:example-a',
|
|
671
|
+
},
|
|
671
672
|
],
|
|
672
673
|
'example-b.com': [
|
|
673
674
|
{
|
|
674
|
-
host: 'example-b-1.com',
|
|
675
|
+
host: 'example-b-1.com',
|
|
676
|
+
ttl: -1,
|
|
677
|
+
priority: 5,
|
|
678
|
+
id: '0:0:0:example-b',
|
|
675
679
|
},
|
|
676
680
|
{
|
|
677
|
-
host: 'example-b-2.com',
|
|
681
|
+
host: 'example-b-2.com',
|
|
682
|
+
ttl: -1,
|
|
683
|
+
priority: 3,
|
|
684
|
+
id: '0:0:0:example-b',
|
|
678
685
|
},
|
|
679
686
|
{
|
|
680
|
-
host: 'example-b-3.com',
|
|
681
|
-
|
|
687
|
+
host: 'example-b-3.com',
|
|
688
|
+
ttl: -1,
|
|
689
|
+
priority: 1,
|
|
690
|
+
id: '0:0:0:example-b',
|
|
691
|
+
},
|
|
682
692
|
],
|
|
683
693
|
'example-c.com': [
|
|
684
694
|
{
|
|
685
|
-
host: 'example-c-1.com',
|
|
695
|
+
host: 'example-c-1.com',
|
|
696
|
+
ttl: -1,
|
|
697
|
+
priority: 5,
|
|
698
|
+
id: '0:0:0:example-c',
|
|
686
699
|
},
|
|
687
700
|
{
|
|
688
|
-
host: 'example-c-2.com',
|
|
701
|
+
host: 'example-c-2.com',
|
|
702
|
+
ttl: -1,
|
|
703
|
+
priority: 3,
|
|
704
|
+
id: '0:0:0:example-c',
|
|
689
705
|
},
|
|
690
706
|
{
|
|
691
|
-
host: 'example-c-3.com',
|
|
692
|
-
|
|
693
|
-
|
|
707
|
+
host: 'example-c-3.com',
|
|
708
|
+
ttl: -1,
|
|
709
|
+
priority: 1,
|
|
710
|
+
id: '0:0:0:example-c',
|
|
711
|
+
},
|
|
712
|
+
],
|
|
694
713
|
},
|
|
695
|
-
format: 'hostmap'
|
|
714
|
+
format: 'hostmap',
|
|
696
715
|
};
|
|
697
716
|
formattedHM = services._formatReceivedHostmap(serviceHostmap);
|
|
698
717
|
});
|
|
@@ -718,13 +737,13 @@ describe('webex-core', () => {
|
|
|
718
737
|
serviceLinks: {
|
|
719
738
|
'example-a': 'https://e-a.com/api/v1',
|
|
720
739
|
'example-b': 'https://e-b.com/api/v1',
|
|
721
|
-
'example-c': 'https://e-c.com/api/v1'
|
|
740
|
+
'example-c': 'https://e-c.com/api/v1',
|
|
722
741
|
},
|
|
723
742
|
hostCatalog: {
|
|
724
743
|
'e-a.com': [],
|
|
725
744
|
'e-b.com': [],
|
|
726
|
-
'e-c.com': []
|
|
727
|
-
}
|
|
745
|
+
'e-c.com': [],
|
|
746
|
+
},
|
|
728
747
|
};
|
|
729
748
|
|
|
730
749
|
const newFormattedHM = services._formatReceivedHostmap(newServiceHM);
|
|
@@ -749,19 +768,16 @@ describe('webex-core', () => {
|
|
|
749
768
|
});
|
|
750
769
|
|
|
751
770
|
it('creates an array of equal length of serviceLinks', () => {
|
|
752
|
-
assert.equal(Object.keys(serviceHostmap.serviceLinks).length,
|
|
753
|
-
formattedHM.length);
|
|
771
|
+
assert.equal(Object.keys(serviceHostmap.serviceLinks).length, formattedHM.length);
|
|
754
772
|
});
|
|
755
773
|
|
|
756
774
|
it('creates an array of equal length of hostMap', () => {
|
|
757
|
-
assert.equal(Object.keys(serviceHostmap.hostCatalog).length,
|
|
758
|
-
formattedHM.length);
|
|
775
|
+
assert.equal(Object.keys(serviceHostmap.hostCatalog).length, formattedHM.length);
|
|
759
776
|
});
|
|
760
777
|
|
|
761
778
|
it('creates an array with matching url data', () => {
|
|
762
779
|
formattedHM.forEach((entry) => {
|
|
763
|
-
assert.equal(serviceHostmap.serviceLinks[entry.name],
|
|
764
|
-
entry.defaultUrl);
|
|
780
|
+
assert.equal(serviceHostmap.serviceLinks[entry.name], entry.defaultUrl);
|
|
765
781
|
});
|
|
766
782
|
});
|
|
767
783
|
|
|
@@ -769,21 +785,26 @@ describe('webex-core', () => {
|
|
|
769
785
|
Object.keys(serviceHostmap.hostCatalog).forEach((key) => {
|
|
770
786
|
const hostGroup = serviceHostmap.hostCatalog[key];
|
|
771
787
|
|
|
772
|
-
const foundMatch = hostGroup.every(
|
|
773
|
-
(
|
|
774
|
-
|
|
788
|
+
const foundMatch = hostGroup.every((inboundHost) =>
|
|
789
|
+
formattedHM.find((formattedService) =>
|
|
790
|
+
formattedService.hosts.find(
|
|
775
791
|
(formattedHost) => formattedHost.host === inboundHost.host
|
|
776
792
|
)
|
|
777
793
|
)
|
|
778
794
|
);
|
|
779
795
|
|
|
780
|
-
assert.isTrue(
|
|
796
|
+
assert.isTrue(
|
|
797
|
+
foundMatch,
|
|
798
|
+
`did not find matching host data for the \`${key}\` host group.`
|
|
799
|
+
);
|
|
781
800
|
});
|
|
782
801
|
});
|
|
783
802
|
|
|
784
803
|
it('creates an array with matching names', () => {
|
|
785
|
-
assert.hasAllKeys(
|
|
786
|
-
|
|
804
|
+
assert.hasAllKeys(
|
|
805
|
+
serviceHostmap.serviceLinks,
|
|
806
|
+
formattedHM.map((item) => item.name)
|
|
807
|
+
);
|
|
787
808
|
});
|
|
788
809
|
|
|
789
810
|
it('returns self', () => {
|