@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.
Files changed (184) hide show
  1. package/dist/config.js +1 -11
  2. package/dist/config.js.map +1 -1
  3. package/dist/credentials-config.js +44 -64
  4. package/dist/credentials-config.js.map +1 -1
  5. package/dist/index.js +0 -76
  6. package/dist/index.js.map +1 -1
  7. package/dist/interceptors/auth.js +22 -55
  8. package/dist/interceptors/auth.js.map +1 -1
  9. package/dist/interceptors/default-options.js +0 -20
  10. package/dist/interceptors/default-options.js.map +1 -1
  11. package/dist/interceptors/embargo.js +0 -21
  12. package/dist/interceptors/embargo.js.map +1 -1
  13. package/dist/interceptors/network-timing.js +2 -21
  14. package/dist/interceptors/network-timing.js.map +1 -1
  15. package/dist/interceptors/payload-transformer.js +2 -22
  16. package/dist/interceptors/payload-transformer.js.map +1 -1
  17. package/dist/interceptors/rate-limit.js +25 -57
  18. package/dist/interceptors/rate-limit.js.map +1 -1
  19. package/dist/interceptors/redirect.js +4 -33
  20. package/dist/interceptors/redirect.js.map +1 -1
  21. package/dist/interceptors/request-event.js +3 -30
  22. package/dist/interceptors/request-event.js.map +1 -1
  23. package/dist/interceptors/request-logger.js +1 -30
  24. package/dist/interceptors/request-logger.js.map +1 -1
  25. package/dist/interceptors/request-timing.js +3 -22
  26. package/dist/interceptors/request-timing.js.map +1 -1
  27. package/dist/interceptors/response-logger.js +2 -31
  28. package/dist/interceptors/response-logger.js.map +1 -1
  29. package/dist/interceptors/user-agent.js +2 -29
  30. package/dist/interceptors/user-agent.js.map +1 -1
  31. package/dist/interceptors/webex-tracking-id.js +5 -28
  32. package/dist/interceptors/webex-tracking-id.js.map +1 -1
  33. package/dist/interceptors/webex-user-agent.js +5 -38
  34. package/dist/interceptors/webex-user-agent.js.map +1 -1
  35. package/dist/lib/batcher.js +3 -51
  36. package/dist/lib/batcher.js.map +1 -1
  37. package/dist/lib/credentials/credentials.js +39 -119
  38. package/dist/lib/credentials/credentials.js.map +1 -1
  39. package/dist/lib/credentials/grant-errors.js +0 -49
  40. package/dist/lib/credentials/grant-errors.js.map +1 -1
  41. package/dist/lib/credentials/index.js +1 -13
  42. package/dist/lib/credentials/index.js.map +1 -1
  43. package/dist/lib/credentials/scope.js +1 -7
  44. package/dist/lib/credentials/scope.js.map +1 -1
  45. package/dist/lib/credentials/token-collection.js +1 -7
  46. package/dist/lib/credentials/token-collection.js.map +1 -1
  47. package/dist/lib/credentials/token.js +39 -118
  48. package/dist/lib/credentials/token.js.map +1 -1
  49. package/dist/lib/page.js +13 -26
  50. package/dist/lib/page.js.map +1 -1
  51. package/dist/lib/services/constants.js +0 -2
  52. package/dist/lib/services/constants.js.map +1 -1
  53. package/dist/lib/services/index.js +1 -28
  54. package/dist/lib/services/index.js.map +1 -1
  55. package/dist/lib/services/interceptors/server-error.js +2 -23
  56. package/dist/lib/services/interceptors/server-error.js.map +1 -1
  57. package/dist/lib/services/interceptors/service.js +12 -34
  58. package/dist/lib/services/interceptors/service.js.map +1 -1
  59. package/dist/lib/services/metrics.js +0 -2
  60. package/dist/lib/services/metrics.js.map +1 -1
  61. package/dist/lib/services/service-catalog.js +10 -90
  62. package/dist/lib/services/service-catalog.js.map +1 -1
  63. package/dist/lib/services/service-fed-ramp.js +0 -2
  64. package/dist/lib/services/service-fed-ramp.js.map +1 -1
  65. package/dist/lib/services/service-host.js +47 -62
  66. package/dist/lib/services/service-host.js.map +1 -1
  67. package/dist/lib/services/service-registry.js +78 -90
  68. package/dist/lib/services/service-registry.js.map +1 -1
  69. package/dist/lib/services/service-state.js +3 -15
  70. package/dist/lib/services/service-state.js.map +1 -1
  71. package/dist/lib/services/service-url.js +4 -25
  72. package/dist/lib/services/service-url.js.map +1 -1
  73. package/dist/lib/services/services.js +122 -238
  74. package/dist/lib/services/services.js.map +1 -1
  75. package/dist/lib/stateless-webex-plugin.js +5 -28
  76. package/dist/lib/stateless-webex-plugin.js.map +1 -1
  77. package/dist/lib/storage/decorators.js +19 -62
  78. package/dist/lib/storage/decorators.js.map +1 -1
  79. package/dist/lib/storage/errors.js +0 -23
  80. package/dist/lib/storage/errors.js.map +1 -1
  81. package/dist/lib/storage/index.js +2 -16
  82. package/dist/lib/storage/index.js.map +1 -1
  83. package/dist/lib/storage/make-webex-plugin-store.js +11 -41
  84. package/dist/lib/storage/make-webex-plugin-store.js.map +1 -1
  85. package/dist/lib/storage/make-webex-store.js +8 -30
  86. package/dist/lib/storage/make-webex-store.js.map +1 -1
  87. package/dist/lib/storage/memory-store-adapter.js +1 -19
  88. package/dist/lib/storage/memory-store-adapter.js.map +1 -1
  89. package/dist/lib/webex-core-plugin-mixin.js +9 -29
  90. package/dist/lib/webex-core-plugin-mixin.js.map +1 -1
  91. package/dist/lib/webex-http-error.js +1 -31
  92. package/dist/lib/webex-http-error.js.map +1 -1
  93. package/dist/lib/webex-internal-core-plugin-mixin.js +9 -29
  94. package/dist/lib/webex-internal-core-plugin-mixin.js.map +1 -1
  95. package/dist/lib/webex-plugin.js +6 -40
  96. package/dist/lib/webex-plugin.js.map +1 -1
  97. package/dist/plugins/logger.js +3 -17
  98. package/dist/plugins/logger.js.map +1 -1
  99. package/dist/webex-core.js +79 -203
  100. package/dist/webex-core.js.map +1 -1
  101. package/dist/webex-internal-core.js +0 -10
  102. package/dist/webex-internal-core.js.map +1 -1
  103. package/package.json +14 -14
  104. package/src/config.js +9 -11
  105. package/src/credentials-config.js +110 -72
  106. package/src/index.js +4 -14
  107. package/src/interceptors/auth.js +36 -37
  108. package/src/interceptors/default-options.js +0 -1
  109. package/src/interceptors/embargo.js +1 -1
  110. package/src/interceptors/payload-transformer.js +1 -2
  111. package/src/interceptors/rate-limit.js +8 -5
  112. package/src/interceptors/redirect.js +14 -8
  113. package/src/interceptors/request-event.js +4 -8
  114. package/src/interceptors/request-logger.js +8 -5
  115. package/src/interceptors/response-logger.js +11 -8
  116. package/src/interceptors/user-agent.js +1 -2
  117. package/src/interceptors/webex-user-agent.js +3 -9
  118. package/src/lib/batcher.js +70 -69
  119. package/src/lib/credentials/credentials.js +112 -122
  120. package/src/lib/credentials/grant-errors.js +6 -7
  121. package/src/lib/credentials/index.js +1 -4
  122. package/src/lib/credentials/scope.js +1 -4
  123. package/src/lib/credentials/token-collection.js +1 -1
  124. package/src/lib/credentials/token.js +86 -80
  125. package/src/lib/page.js +10 -11
  126. package/src/lib/services/constants.js +3 -13
  127. package/src/lib/services/index.js +2 -2
  128. package/src/lib/services/interceptors/server-error.js +12 -7
  129. package/src/lib/services/interceptors/service.js +6 -5
  130. package/src/lib/services/metrics.js +1 -1
  131. package/src/lib/services/service-catalog.js +110 -100
  132. package/src/lib/services/service-fed-ramp.js +1 -2
  133. package/src/lib/services/service-host.js +10 -17
  134. package/src/lib/services/service-registry.js +69 -96
  135. package/src/lib/services/service-state.js +4 -6
  136. package/src/lib/services/service-url.js +24 -23
  137. package/src/lib/services/services.js +260 -251
  138. package/src/lib/stateless-webex-plugin.js +4 -2
  139. package/src/lib/storage/decorators.js +68 -66
  140. package/src/lib/storage/index.js +4 -6
  141. package/src/lib/storage/make-webex-plugin-store.js +34 -21
  142. package/src/lib/storage/make-webex-store.js +6 -7
  143. package/src/lib/storage/memory-store-adapter.js +3 -3
  144. package/src/lib/webex-core-plugin-mixin.js +10 -7
  145. package/src/lib/webex-http-error.js +7 -8
  146. package/src/lib/webex-internal-core-plugin-mixin.js +9 -6
  147. package/src/lib/webex-plugin.js +41 -34
  148. package/src/plugins/logger.js +8 -3
  149. package/src/webex-core.js +185 -116
  150. package/src/webex-internal-core.js +15 -9
  151. package/test/integration/spec/credentials/credentials.js +26 -30
  152. package/test/integration/spec/credentials/token.js +36 -33
  153. package/test/integration/spec/services/service-catalog.js +177 -156
  154. package/test/integration/spec/services/services.js +313 -304
  155. package/test/integration/spec/webex-core.js +98 -86
  156. package/test/unit/spec/_setup.js +26 -18
  157. package/test/unit/spec/credentials/credentials.js +189 -154
  158. package/test/unit/spec/credentials/token.js +94 -76
  159. package/test/unit/spec/interceptors/auth.js +291 -243
  160. package/test/unit/spec/interceptors/default-options.js +36 -24
  161. package/test/unit/spec/interceptors/embargo.js +32 -27
  162. package/test/unit/spec/interceptors/network-timing.js +2 -2
  163. package/test/unit/spec/interceptors/payload-transformer.js +61 -52
  164. package/test/unit/spec/interceptors/rate-limit.js +104 -75
  165. package/test/unit/spec/interceptors/redirect.js +22 -20
  166. package/test/unit/spec/interceptors/request-timing.js +18 -22
  167. package/test/unit/spec/interceptors/user-agent.js +28 -16
  168. package/test/unit/spec/interceptors/webex-tracking-id.js +14 -8
  169. package/test/unit/spec/interceptors/webex-user-agent.js +83 -37
  170. package/test/unit/spec/lib/batcher.js +36 -32
  171. package/test/unit/spec/lib/page.js +36 -32
  172. package/test/unit/spec/lib/webex-plugin.js +1 -1
  173. package/test/unit/spec/services/interceptors/server-error.js +67 -90
  174. package/test/unit/spec/services/interceptors/service.js +17 -28
  175. package/test/unit/spec/services/service-catalog.js +19 -27
  176. package/test/unit/spec/services/service-host.js +29 -26
  177. package/test/unit/spec/services/service-registry.js +128 -170
  178. package/test/unit/spec/services/service-state.js +13 -22
  179. package/test/unit/spec/services/service-url.js +24 -43
  180. package/test/unit/spec/services/services.js +85 -41
  181. package/test/unit/spec/storage/persist.js +6 -9
  182. package/test/unit/spec/storage/wait-for-value.js +22 -21
  183. package/test/unit/spec/webex-core.js +78 -57
  184. package/test/unit/spec/webex-internal-core.js +56 -31
@@ -10,7 +10,7 @@ import WebexCore, {
10
10
  ServiceCatalog,
11
11
  ServiceRegistry,
12
12
  ServiceState,
13
- ServiceUrl
13
+ ServiceUrl,
14
14
  } from '@webex/webex-core';
15
15
  import testUsers from '@webex/test-helper-test-users';
16
16
  import uuid from 'uuid';
@@ -27,20 +27,20 @@ describe('webex-core', () => {
27
27
  let servicesEU;
28
28
  let catalog;
29
29
 
30
- before('create users', () => Promise.all([
31
- testUsers.create({count: 1}),
32
- testUsers.create({
33
- count: 1,
34
- config: {
35
- orgId: process.env.EU_PRIMARY_ORG_ID
36
- }
37
- })
38
- ])
39
- .then(([[user], [userEU]]) => {
30
+ before('create users', () =>
31
+ Promise.all([
32
+ testUsers.create({count: 1}),
33
+ testUsers.create({
34
+ count: 1,
35
+ config: {
36
+ orgId: process.env.EU_PRIMARY_ORG_ID,
37
+ },
38
+ }),
39
+ ]).then(([[user], [userEU]]) => {
40
40
  webexUser = user;
41
41
  webexUserEU = userEU;
42
- }));
43
-
42
+ })
43
+ );
44
44
 
45
45
  beforeEach('create webex instance', () => {
46
46
  webex = new WebexCore({credentials: {supertoken: webexUser.token}});
@@ -51,12 +51,13 @@ describe('webex-core', () => {
51
51
 
52
52
  return Promise.all([
53
53
  services.waitForCatalog('postauth', 10),
54
- servicesEU.waitForCatalog('postauth', 10)
55
- ])
56
- .then(() => services.updateServices({
54
+ servicesEU.waitForCatalog('postauth', 10),
55
+ ]).then(() =>
56
+ services.updateServices({
57
57
  from: 'limited',
58
- query: {userId: webexUser.id}
59
- }));
58
+ query: {userId: webexUser.id},
59
+ })
60
+ );
60
61
  });
61
62
 
62
63
  describe('#_getCatalog()', () => {
@@ -90,7 +91,7 @@ describe('webex-core', () => {
90
91
  testUrlTemplate = {
91
92
  defaultUrl: 'https://www.example.com/api/v1',
92
93
  hosts: [],
93
- name: 'exampleValid'
94
+ name: 'exampleValid',
94
95
  };
95
96
  testUrl = new ServiceUrl(testUrlTemplate);
96
97
  catalog._loadServiceUrls('preauth', [testUrl]);
@@ -107,7 +108,7 @@ describe('webex-core', () => {
107
108
  assert.equal(url, testUrlTemplate.defaultUrl);
108
109
  });
109
110
 
110
- it('returns undefined if url doesn\'t exist', () => {
111
+ it("returns undefined if url doesn't exist", () => {
111
112
  const s = services.get('invalidUrl');
112
113
 
113
114
  assert.typeOf(s, 'undefined');
@@ -117,9 +118,8 @@ describe('webex-core', () => {
117
118
  assert.isDefined(services.get(testUrlTemplate.name, false, 'preauth'));
118
119
  });
119
120
 
120
- it('fails to get a service if serviceGroup isn\'t accurate', () => {
121
- assert.isUndefined(services.get(testUrlTemplate.name,
122
- false, 'discovery'));
121
+ it("fails to get a service if serviceGroup isn't accurate", () => {
122
+ assert.isUndefined(services.get(testUrlTemplate.name, false, 'discovery'));
123
123
  });
124
124
  });
125
125
 
@@ -136,29 +136,30 @@ describe('webex-core', () => {
136
136
  host: 'www.example-p5.com',
137
137
  ttl: -1,
138
138
  priority: 5,
139
- id: 'exampleClusterId'
139
+ id: 'exampleClusterId',
140
140
  },
141
141
  {
142
142
  host: 'www.example-p3.com',
143
143
  ttl: -1,
144
144
  priority: 3,
145
- id: 'exampleClusterId'
146
- }
145
+ id: 'exampleClusterId',
146
+ },
147
147
  ],
148
- name: 'exampleValid'
148
+ name: 'exampleValid',
149
149
  };
150
150
  testUrl = new ServiceUrl(testUrlTemplate);
151
151
  catalog._loadServiceUrls('preauth', [testUrl]);
152
152
  });
153
153
 
154
154
  it('returns a clusterId when found with default url', () => {
155
- assert.equal(services.getClusterId(testUrlTemplate.defaultUrl),
156
- testUrlTemplate.hosts[0].id);
155
+ assert.equal(
156
+ services.getClusterId(testUrlTemplate.defaultUrl),
157
+ testUrlTemplate.hosts[0].id
158
+ );
157
159
  });
158
160
 
159
161
  it('returns a clusterId when found with priority host url', () => {
160
- assert.equal(services.getClusterId(testUrl.get(true)),
161
- testUrlTemplate.hosts[0].id);
162
+ assert.equal(services.getClusterId(testUrl.get(true)), testUrlTemplate.hosts[0].id);
162
163
  });
163
164
 
164
165
  it('returns a clusterId when found with resource-appended url', () => {
@@ -168,13 +169,11 @@ describe('webex-core', () => {
168
169
  );
169
170
  });
170
171
 
171
- it('returns undefined when the url doesn\'t exist in catalog', () => {
172
- assert.isUndefined(
173
- services.getClusterId('http://not-a-known-url.com/')
174
- );
172
+ it("returns undefined when the url doesn't exist in catalog", () => {
173
+ assert.isUndefined(services.getClusterId('http://not-a-known-url.com/'));
175
174
  });
176
175
 
177
- it('returns undefined when the string isn\'t a url', () => {
176
+ it("returns undefined when the string isn't a url", () => {
178
177
  assert.isUndefined(services.getClusterId('not a url'));
179
178
  });
180
179
  });
@@ -192,16 +191,16 @@ describe('webex-core', () => {
192
191
  host: 'www.example-p5.com',
193
192
  ttl: -1,
194
193
  priority: 5,
195
- id: '0:0:cluster-a:exampleValid'
194
+ id: '0:0:cluster-a:exampleValid',
196
195
  },
197
196
  {
198
197
  host: 'www.example-p3.com',
199
198
  ttl: -1,
200
199
  priority: 3,
201
- id: '0:0:cluster-b:exampleValid'
202
- }
200
+ id: '0:0:cluster-b:exampleValid',
201
+ },
203
202
  ],
204
- name: 'exampleValid'
203
+ name: 'exampleValid',
205
204
  };
206
205
  testUrl = new ServiceUrl(testUrlTemplate);
207
206
  catalog._loadServiceUrls('preauth', [testUrl]);
@@ -210,7 +209,7 @@ describe('webex-core', () => {
210
209
  it('finds a valid service url from only a clusterId', () => {
211
210
  const serviceFound = services.getServiceFromClusterId({
212
211
  clusterId: testUrlTemplate.hosts[0].id,
213
- priorityHost: false
212
+ priorityHost: false,
214
213
  });
215
214
 
216
215
  assert.equal(serviceFound.name, testUrl.name);
@@ -220,7 +219,7 @@ describe('webex-core', () => {
220
219
  it('finds a valid priority service url', () => {
221
220
  const serviceFound = services.getServiceFromClusterId({
222
221
  clusterId: testUrlTemplate.hosts[0].id,
223
- priorityHost: true
222
+ priorityHost: true,
224
223
  });
225
224
 
226
225
  assert.equal(serviceFound.name, testUrl.name);
@@ -235,26 +234,24 @@ describe('webex-core', () => {
235
234
  const serviceFound = catalog.findServiceFromClusterId({
236
235
  clusterId: testUrlTemplate.hosts[0].id,
237
236
  priorityHost: false,
238
- serviceGroup: 'preauth'
237
+ serviceGroup: 'preauth',
239
238
  });
240
239
 
241
240
  assert.equal(serviceFound.name, testUrl.name);
242
241
  assert.equal(serviceFound.url, testUrl.defaultUrl);
243
242
  });
244
243
 
245
- it('fails to find a valid service when it\'s not in a group', () => {
244
+ it("fails to find a valid service when it's not in a group", () => {
246
245
  assert.isUndefined(
247
246
  services.getServiceFromClusterId({
248
247
  clusterId: testUrlTemplate.hosts[0].id,
249
- serviceGroup: 'signin'
248
+ serviceGroup: 'signin',
250
249
  })
251
250
  );
252
251
  });
253
252
 
254
- it('returns undefined when service doesn\'t exist', () => {
255
- assert.isUndefined(
256
- services.getServiceFromClusterId({clusterId: 'not a clusterId'})
257
- );
253
+ it("returns undefined when service doesn't exist", () => {
254
+ assert.isUndefined(services.getServiceFromClusterId({clusterId: 'not a clusterId'}));
258
255
  });
259
256
  });
260
257
 
@@ -270,16 +267,16 @@ describe('webex-core', () => {
270
267
  host: 'www.example-p5.com',
271
268
  ttl: -1,
272
269
  priority: 5,
273
- id: 'exampleClusterId'
270
+ id: 'exampleClusterId',
274
271
  },
275
272
  {
276
273
  host: 'www.example-p3.com',
277
274
  ttl: -1,
278
275
  priority: 3,
279
- id: 'exampleClusterId'
280
- }
276
+ id: 'exampleClusterId',
277
+ },
281
278
  ],
282
- name: 'exampleValid'
279
+ name: 'exampleValid',
283
280
  };
284
281
  testUrl = new ServiceUrl(testUrlTemplate);
285
282
  catalog._loadServiceUrls('preauth', [testUrl]);
@@ -290,8 +287,7 @@ describe('webex-core', () => {
290
287
  });
291
288
 
292
289
  it('gets a valid service object from an existing service', () => {
293
- const serviceObject = services
294
- .getServiceFromUrl(testUrlTemplate.defaultUrl);
290
+ const serviceObject = services.getServiceFromUrl(testUrlTemplate.defaultUrl);
295
291
 
296
292
  assert.isDefined(serviceObject);
297
293
  assert.hasAllKeys(serviceObject, ['name', 'defaultUrl', 'priorityUrl']);
@@ -301,9 +297,8 @@ describe('webex-core', () => {
301
297
  assert.equal(testUrl.get(true), serviceObject.priorityUrl);
302
298
  });
303
299
 
304
- it('returns undefined when the service url doesn\'t exist', () => {
305
- const serviceObject = services
306
- .getServiceFromUrl('http://www.not-real.com/');
300
+ it("returns undefined when the service url doesn't exist", () => {
301
+ const serviceObject = services.getServiceFromUrl('http://www.not-real.com/');
307
302
 
308
303
  assert.isUndefined(serviceObject);
309
304
  });
@@ -368,10 +363,7 @@ describe('webex-core', () => {
368
363
 
369
364
  services.initConfig();
370
365
 
371
- assert.deepEqual(
372
- allowedDomains,
373
- services._getCatalog().allowedDomains
374
- );
366
+ assert.deepEqual(allowedDomains, services._getCatalog().allowedDomains);
375
367
  });
376
368
  });
377
369
 
@@ -382,8 +374,7 @@ describe('webex-core', () => {
382
374
  it('should create a registry', () =>
383
375
  assert.instanceOf(services.getRegistry(), ServiceRegistry));
384
376
 
385
- it('should create a state', () =>
386
- assert.instanceOf(services.getState(), ServiceState));
377
+ it('should create a state', () => assert.instanceOf(services.getState(), ServiceState));
387
378
 
388
379
  it('should call services#initConfig() when webex config changes', () => {
389
380
  services.initConfig = sinon.spy();
@@ -402,10 +393,7 @@ describe('webex-core', () => {
402
393
  });
403
394
 
404
395
  it('should collect different catalogs based on OrgId region', () =>
405
- assert.notDeepEqual(
406
- services.list(true),
407
- servicesEU.list(true)
408
- ));
396
+ assert.notDeepEqual(services.list(true), servicesEU.list(true)));
409
397
 
410
398
  it('should not attempt to collect catalogs without authorization', (done) => {
411
399
  const otherWebex = new WebexCore();
@@ -431,11 +419,14 @@ describe('webex-core', () => {
431
419
  it('should call services#collectPreauthCatalog with the OrgId', () => {
432
420
  services.collectPreauthCatalog = sinon.stub().resolves();
433
421
 
434
- return services.initServiceCatalogs()
435
- .then(() =>
436
- assert.calledWith(services.collectPreauthCatalog, sinon.match({
437
- orgId: webex.credentials.getOrgId()
438
- })));
422
+ return services.initServiceCatalogs().then(() =>
423
+ assert.calledWith(
424
+ services.collectPreauthCatalog,
425
+ sinon.match({
426
+ orgId: webex.credentials.getOrgId(),
427
+ })
428
+ )
429
+ );
439
430
  });
440
431
 
441
432
  it('should not call services#updateServices() when not authed', () => {
@@ -448,19 +439,25 @@ describe('webex-core', () => {
448
439
 
449
440
  webex.credentials.getOrgId = sinon.stub().returns(webexUser.orgId);
450
441
 
451
- return services.initServiceCatalogs()
452
- // services#updateServices() gets called once by the limited catalog
453
- // retrieval and should not be called again when not authorized.
454
- .then(() => assert.calledOnce(services.updateServices));
442
+ return (
443
+ services
444
+ .initServiceCatalogs()
445
+ // services#updateServices() gets called once by the limited catalog
446
+ // retrieval and should not be called again when not authorized.
447
+ .then(() => assert.calledOnce(services.updateServices))
448
+ );
455
449
  });
456
450
 
457
451
  it('should call services#updateServices() when authed', () => {
458
452
  services.updateServices = sinon.stub().resolves();
459
453
 
460
- return services.initServiceCatalogs()
461
- // services#updateServices() gets called once by the limited catalog
462
- // retrieval and should get called again when authorized.
463
- .then(() => assert.calledTwice(services.updateServices));
454
+ return (
455
+ services
456
+ .initServiceCatalogs()
457
+ // services#updateServices() gets called once by the limited catalog
458
+ // retrieval and should get called again when authorized.
459
+ .then(() => assert.calledTwice(services.updateServices))
460
+ );
464
461
  });
465
462
  });
466
463
 
@@ -477,16 +474,16 @@ describe('webex-core', () => {
477
474
  host: 'www.example-p5.com',
478
475
  ttl: -1,
479
476
  priority: 5,
480
- id: 'exampleClusterId'
477
+ id: 'exampleClusterId',
481
478
  },
482
479
  {
483
480
  host: 'www.example-p3.com',
484
481
  ttl: -1,
485
482
  priority: 3,
486
- id: 'exampleClusterId'
487
- }
483
+ id: 'exampleClusterId',
484
+ },
488
485
  ],
489
- name: 'exampleValid'
486
+ name: 'exampleValid',
490
487
  };
491
488
  testUrl = new ServiceUrl(testUrlTemplate);
492
489
  catalog._loadServiceUrls('preauth', [testUrl]);
@@ -500,7 +497,7 @@ describe('webex-core', () => {
500
497
  assert.isTrue(services.isServiceUrl(testUrl.get(true)));
501
498
  });
502
499
 
503
- it('returns undefined if the url doesn\'t exist', () => {
500
+ it("returns undefined if the url doesn't exist", () => {
504
501
  assert.isFalse(services.isServiceUrl('https://na.com/'));
505
502
  });
506
503
 
@@ -513,10 +510,7 @@ describe('webex-core', () => {
513
510
  let list;
514
511
 
515
512
  beforeEach(() => {
516
- catalog.setAllowedDomains([
517
- 'some-domain-a',
518
- 'some-domain-b'
519
- ]);
513
+ catalog.setAllowedDomains(['some-domain-a', 'some-domain-b']);
520
514
 
521
515
  list = catalog.getAllowedDomains();
522
516
  });
@@ -547,16 +541,16 @@ describe('webex-core', () => {
547
541
  host: 'www.example-p5.com',
548
542
  ttl: -1,
549
543
  priority: 5,
550
- id: '0:0:cluster-a:exampleValid'
544
+ id: '0:0:cluster-a:exampleValid',
551
545
  },
552
546
  {
553
547
  host: 'www.example-p3.com',
554
548
  ttl: -1,
555
549
  priority: 3,
556
- id: '0:0:cluster-b:exampleValid'
557
- }
550
+ id: '0:0:cluster-b:exampleValid',
551
+ },
558
552
  ],
559
- name: 'exampleValid'
553
+ name: 'exampleValid',
560
554
  };
561
555
  testUrl = new ServiceUrl(testUrlTemplate);
562
556
  catalog._loadServiceUrls('preauth', [testUrl]);
@@ -576,8 +570,7 @@ describe('webex-core', () => {
576
570
  assert.throws(services.convertUrlToPriorityHostUrl, Error);
577
571
 
578
572
  assert.throws(
579
- services.convertUrlToPriorityHostUrl
580
- .bind(services, 'not-a-valid-service'),
573
+ services.convertUrlToPriorityHostUrl.bind(services, 'not-a-valid-service'),
581
574
  Error
582
575
  );
583
576
  });
@@ -601,16 +594,16 @@ describe('webex-core', () => {
601
594
  host: 'www.example-phr-p5.com',
602
595
  ttl: -1,
603
596
  priority: 5,
604
- homeCluster: true
597
+ homeCluster: true,
605
598
  },
606
599
  {
607
600
  host: 'www.example-phr-p3.com',
608
601
  ttl: -1,
609
602
  priority: 3,
610
- homeCluster: true
611
- }
603
+ homeCluster: true,
604
+ },
612
605
  ],
613
- name: 'exampleValid-phr'
606
+ name: 'exampleValid-phr',
614
607
  };
615
608
  testUrl = new ServiceUrl(testUrlTemplate);
616
609
  catalog._loadServiceUrls('preauth', [testUrl]);
@@ -626,9 +619,7 @@ describe('webex-core', () => {
626
619
 
627
620
  services.markFailedUrl(priorityUrl);
628
621
 
629
- const failedHost = priorityServiceUrl.hosts.find(
630
- (host) => host.failed
631
- );
622
+ const failedHost = priorityServiceUrl.hosts.find((host) => host.failed);
632
623
 
633
624
  assert.isTrue(priorityUrl.includes(failedHost.host));
634
625
  });
@@ -645,13 +636,11 @@ describe('webex-core', () => {
645
636
  const priorityServiceUrl = catalog._getUrl(testUrlTemplate.name);
646
637
  const firstPriorityUrl = priorityServiceUrl._getPriorityHostUrl();
647
638
 
648
- priorityServiceUrl.hosts.forEach(
649
- () => {
650
- const priorityUrl = priorityServiceUrl._getPriorityHostUrl();
639
+ priorityServiceUrl.hosts.forEach(() => {
640
+ const priorityUrl = priorityServiceUrl._getPriorityHostUrl();
651
641
 
652
- services.markFailedUrl(priorityUrl);
653
- }
654
- );
642
+ services.markFailedUrl(priorityUrl);
643
+ });
655
644
 
656
645
  const lastPriorityUrl = priorityServiceUrl._getPriorityHostUrl();
657
646
 
@@ -678,11 +667,10 @@ describe('webex-core', () => {
678
667
  it('updates the services list', (done) => {
679
668
  catalog.serviceGroups.postauth = [];
680
669
 
681
- services.updateServices()
682
- .then(() => {
683
- assert.isAbove(catalog.serviceGroups.postauth.length, 0);
684
- done();
685
- });
670
+ services.updateServices().then(() => {
671
+ assert.isAbove(catalog.serviceGroups.postauth.length, 0);
672
+ done();
673
+ });
686
674
 
687
675
  services.updateServices();
688
676
  });
@@ -691,16 +679,15 @@ describe('webex-core', () => {
691
679
  catalog.updateServiceUrls = sinon.stub().returns({}); // returns `this`
692
680
  services._fetchNewServiceHostmap = sinon.stub().resolves();
693
681
 
694
- services.updateServices({
695
- from: 'limited',
696
- query: {email: webexUser.email}
697
- })
682
+ services
683
+ .updateServices({
684
+ from: 'limited',
685
+ query: {email: webexUser.email},
686
+ })
698
687
  .then(() => {
699
688
  assert.calledWith(
700
689
  services._fetchNewServiceHostmap,
701
- sinon.match.has(
702
- 'query', {emailhash: sinon.match(/\b[A-Fa-f0-9]{64}\b/)}
703
- )
690
+ sinon.match.has('query', {emailhash: sinon.match(/\b[A-Fa-f0-9]{64}\b/)})
704
691
  );
705
692
  done();
706
693
  });
@@ -709,10 +696,11 @@ describe('webex-core', () => {
709
696
  it('updates the limited catalog when email is provided', (done) => {
710
697
  catalog.serviceGroups.preauth = [];
711
698
 
712
- services.updateServices({
713
- from: 'limited',
714
- query: {email: webexUser.email}
715
- })
699
+ services
700
+ .updateServices({
701
+ from: 'limited',
702
+ query: {email: webexUser.email},
703
+ })
716
704
  .then(() => {
717
705
  assert.isAbove(catalog.serviceGroups.preauth.length, 0);
718
706
  done();
@@ -722,10 +710,11 @@ describe('webex-core', () => {
722
710
  it('updates the limited catalog when userId is provided', (done) => {
723
711
  catalog.serviceGroups.preauth = [];
724
712
 
725
- services.updateServices({
726
- from: 'limited',
727
- query: {userId: webexUser.id}
728
- })
713
+ services
714
+ .updateServices({
715
+ from: 'limited',
716
+ query: {userId: webexUser.id},
717
+ })
729
718
  .then(() => {
730
719
  assert.isAbove(catalog.serviceGroups.preauth.length, 0);
731
720
  done();
@@ -735,10 +724,11 @@ describe('webex-core', () => {
735
724
  it('updates the limited catalog when orgId is provided', (done) => {
736
725
  catalog.serviceGroups.preauth = [];
737
726
 
738
- services.updateServices({
739
- from: 'limited',
740
- query: {orgId: webexUser.orgId}
741
- })
727
+ services
728
+ .updateServices({
729
+ from: 'limited',
730
+ query: {orgId: webexUser.orgId},
731
+ })
742
732
  .then(() => {
743
733
  assert.isAbove(catalog.serviceGroups.preauth.length, 0);
744
734
  done();
@@ -747,10 +737,11 @@ describe('webex-core', () => {
747
737
  it('updates the limited catalog when query param mode is provided', (done) => {
748
738
  catalog.serviceGroups.preauth = [];
749
739
 
750
- services.updateServices({
751
- from: 'limited',
752
- query: {mode: 'DEFAULT_BY_PROXIMITY'}
753
- })
740
+ services
741
+ .updateServices({
742
+ from: 'limited',
743
+ query: {mode: 'DEFAULT_BY_PROXIMITY'},
744
+ })
754
745
  .then(() => {
755
746
  assert.isAbove(catalog.serviceGroups.preauth.length, 0);
756
747
  done();
@@ -759,7 +750,8 @@ describe('webex-core', () => {
759
750
  it('does not update the limited catalog when nothing is provided', () => {
760
751
  catalog.serviceGroups.preauth = [];
761
752
 
762
- return services.updateServices({from: 'limited'})
753
+ return services
754
+ .updateServices({from: 'limited'})
763
755
  .then(() => {
764
756
  assert(false, 'resolved, should have thrown');
765
757
  })
@@ -772,19 +764,23 @@ describe('webex-core', () => {
772
764
  const forceRefresh = true;
773
765
  const fetchNewServiceHostmapSpy = sinon.spy(services, '_fetchNewServiceHostmap');
774
766
 
775
- services.updateServices({
776
- from: 'limited',
777
- query: {email: webexUser.email},
778
- forceRefresh
779
- })
767
+ services
768
+ .updateServices({
769
+ from: 'limited',
770
+ query: {email: webexUser.email},
771
+ forceRefresh,
772
+ })
780
773
  .then(() => {
781
774
  assert.calledOnce(fetchNewServiceHostmapSpy);
782
775
  assert.calledWith(
783
776
  fetchNewServiceHostmapSpy,
784
777
  sinon.match.has(
785
- 'from', 'limited',
786
- 'query', {emailhash: sinon.match(/\b[A-Fa-f0-9]{64}\b/)},
787
- 'forceFresh', forceRefresh
778
+ 'from',
779
+ 'limited',
780
+ 'query',
781
+ {emailhash: sinon.match(/\b[A-Fa-f0-9]{64}\b/)},
782
+ 'forceFresh',
783
+ forceRefresh
788
784
  )
789
785
  );
790
786
 
@@ -797,8 +793,8 @@ describe('webex-core', () => {
797
793
  });
798
794
 
799
795
  describe('#fetchClientRegionInfo()', () => {
800
- it('returns client region info', () => services.fetchClientRegionInfo()
801
- .then((r) => {
796
+ it('returns client region info', () =>
797
+ services.fetchClientRegionInfo().then((r) => {
802
798
  assert.isDefined(r.countryCode);
803
799
  assert.isDefined(r.timezone);
804
800
  }));
@@ -811,9 +807,7 @@ describe('webex-core', () => {
811
807
 
812
808
  const getActivationRequest = (requestStub) => {
813
809
  const requests = requestStub.args.filter(
814
- ([request]) =>
815
- request.service === 'license' &&
816
- request.resource === 'users/activations'
810
+ ([request]) => request.service === 'license' && request.resource === 'users/activations'
817
811
  );
818
812
 
819
813
  assert.strictEqual(requests.length, 1);
@@ -830,72 +824,89 @@ describe('webex-core', () => {
830
824
  sandbox = null;
831
825
  });
832
826
 
833
- it('returns a rejected promise when no email is specified', () => unauthServices.validateUser({})
834
- .then(() => {
835
- assert(false, 'resolved, should have thrown');
836
- })
837
- .catch(() => {
838
- assert(true);
839
- }));
827
+ it('returns a rejected promise when no email is specified', () =>
828
+ unauthServices
829
+ .validateUser({})
830
+ .then(() => {
831
+ assert(false, 'resolved, should have thrown');
832
+ })
833
+ .catch(() => {
834
+ assert(true);
835
+ }));
840
836
 
841
- it('validates an authorized user and webex instance', () => services.validateUser({email: webexUser.email})
842
- .then((r) => {
837
+ it('validates an authorized user and webex instance', () =>
838
+ services.validateUser({email: webexUser.email}).then((r) => {
843
839
  assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
844
840
  assert.equal(r.activated, true);
845
841
  assert.equal(r.exists, true);
846
842
  }));
847
843
 
848
- it('validates an authorized EU user and webex instance', () => servicesEU.validateUser({email: webexUserEU.email})
849
- .then((r) => {
844
+ it('validates an authorized EU user and webex instance', () =>
845
+ servicesEU.validateUser({email: webexUserEU.email}).then((r) => {
850
846
  assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
851
847
  assert.equal(r.activated, true);
852
848
  assert.equal(r.exists, true);
853
849
  }));
854
850
 
855
- it('returns a rejected promise if the provided email isn\'t valid', () => unauthServices.validateUser({email: 'not an email'})
856
- .then(() => {
857
- assert(false, 'resolved, should have thrown');
858
- })
859
- .catch(() => {
860
- assert(true);
861
- }));
851
+ it("returns a rejected promise if the provided email isn't valid", () =>
852
+ unauthServices
853
+ .validateUser({email: 'not an email'})
854
+ .then(() => {
855
+ assert(false, 'resolved, should have thrown');
856
+ })
857
+ .catch(() => {
858
+ assert(true);
859
+ }));
862
860
 
863
- it('validates a non-existing user', () => unauthServices.validateUser({email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`})
864
- .then((r) => {
865
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
866
- assert.equal(r.activated, false);
867
- assert.equal(r.exists, false);
868
- assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
869
- assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
870
- assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
871
- }));
861
+ it('validates a non-existing user', () =>
862
+ unauthServices
863
+ .validateUser({email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`})
864
+ .then((r) => {
865
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
866
+ assert.equal(r.activated, false);
867
+ assert.equal(r.exists, false);
868
+ assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
869
+ assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
870
+ assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
871
+ }));
872
872
 
873
- it('validates new user with activationOptions suppressEmail false', () => unauthServices.validateUser({email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`, activationOptions: {suppressEmail: false}})
874
- .then((r) => {
875
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
876
- assert.equal(r.activated, false);
877
- assert.equal(r.exists, false);
878
- assert.equal(r.user.verificationEmailTriggered, true);
879
- assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
880
- assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
881
- assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
882
- }));
873
+ it('validates new user with activationOptions suppressEmail false', () =>
874
+ unauthServices
875
+ .validateUser({
876
+ email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`,
877
+ activationOptions: {suppressEmail: false},
878
+ })
879
+ .then((r) => {
880
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
881
+ assert.equal(r.activated, false);
882
+ assert.equal(r.exists, false);
883
+ assert.equal(r.user.verificationEmailTriggered, true);
884
+ assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
885
+ assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
886
+ assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
887
+ }));
883
888
 
884
- it('validates new user with activationOptions suppressEmail true', () => unauthServices.validateUser({email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`, activationOptions: {suppressEmail: true}})
885
- .then((r) => {
886
- assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
887
- assert.equal(r.activated, false);
888
- assert.equal(r.exists, false);
889
- assert.equal(r.user.verificationEmailTriggered, false);
890
- assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
891
- assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
892
- assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
893
- }));
889
+ it('validates new user with activationOptions suppressEmail true', () =>
890
+ unauthServices
891
+ .validateUser({
892
+ email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`,
893
+ activationOptions: {suppressEmail: true},
894
+ })
895
+ .then((r) => {
896
+ assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
897
+ assert.equal(r.activated, false);
898
+ assert.equal(r.exists, false);
899
+ assert.equal(r.user.verificationEmailTriggered, false);
900
+ assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
901
+ assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
902
+ assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
903
+ }));
894
904
 
895
905
  it('validates an inactive user', () => {
896
906
  const inactive = 'webex.web.client+nonactivated@gmail.com';
897
907
 
898
- return unauthServices.validateUser({email: inactive, activationOptions: {suppressEmail: true}})
908
+ return unauthServices
909
+ .validateUser({email: inactive, activationOptions: {suppressEmail: true}})
899
910
  .then((r) => {
900
911
  assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
901
912
  assert.equal(r.activated, false, 'activated');
@@ -903,13 +914,14 @@ describe('webex-core', () => {
903
914
  assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
904
915
  assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
905
916
  assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
906
- }).catch(() => {
917
+ })
918
+ .catch(() => {
907
919
  assert(true);
908
920
  });
909
921
  });
910
922
 
911
- it('validates an existing user', () => unauthServices.validateUser({email: webexUser.email})
912
- .then((r) => {
923
+ it('validates an existing user', () =>
924
+ unauthServices.validateUser({email: webexUser.email}).then((r) => {
913
925
  assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
914
926
  assert.equal(r.activated, true);
915
927
  assert.equal(r.exists, true);
@@ -918,8 +930,8 @@ describe('webex-core', () => {
918
930
  assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
919
931
  }));
920
932
 
921
- it('validates an existing EU user', () => unauthServices.validateUser({email: webexUserEU.email})
922
- .then((r) => {
933
+ it('validates an existing EU user', () =>
934
+ unauthServices.validateUser({email: webexUserEU.email}).then((r) => {
923
935
  assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
924
936
  assert.equal(r.activated, true);
925
937
  assert.equal(r.exists, true);
@@ -931,30 +943,32 @@ describe('webex-core', () => {
931
943
  it('sends the prelogin user id as undefined when not specified', () => {
932
944
  const requestStub = sandbox.spy(unauthServices, 'request');
933
945
 
934
- return unauthServices.validateUser({
935
- email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`,
936
- activationOptions: {suppressEmail: true}
937
- }).then(() => {
938
- assert.isUndefined(
939
- getActivationRequest(requestStub).headers['x-prelogin-userid']
940
- );
941
- });
946
+ return unauthServices
947
+ .validateUser({
948
+ email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`,
949
+ activationOptions: {suppressEmail: true},
950
+ })
951
+ .then(() => {
952
+ assert.isUndefined(getActivationRequest(requestStub).headers['x-prelogin-userid']);
953
+ });
942
954
  });
943
955
 
944
956
  it('sends the prelogin user id as provided when specified', () => {
945
957
  const requestStub = sandbox.spy(unauthServices, 'request');
946
958
  const preloginUserId = uuid.v4();
947
959
 
948
- return unauthServices.validateUser({
949
- email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`,
950
- activationOptions: {suppressEmail: true},
951
- preloginUserId
952
- }).then(() => {
953
- assert.strictEqual(
954
- getActivationRequest(requestStub).headers['x-prelogin-userid'],
955
- preloginUserId
956
- );
957
- });
960
+ return unauthServices
961
+ .validateUser({
962
+ email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`,
963
+ activationOptions: {suppressEmail: true},
964
+ preloginUserId,
965
+ })
966
+ .then(() => {
967
+ assert.strictEqual(
968
+ getActivationRequest(requestStub).headers['x-prelogin-userid'],
969
+ preloginUserId
970
+ );
971
+ });
958
972
  });
959
973
  });
960
974
 
@@ -970,20 +984,17 @@ describe('webex-core', () => {
970
984
 
971
985
  describe('when using the name parameter property', () => {
972
986
  it('should resolve to the appropriate url', () =>
973
- services.waitForService({name})
974
- .then((foundUrl) => assert.equal(foundUrl, url)));
987
+ services.waitForService({name}).then((foundUrl) => assert.equal(foundUrl, url)));
975
988
  });
976
989
 
977
990
  describe('when using the url parameter property', () => {
978
991
  it('should resolve to the appropriate url', () =>
979
- services.waitForService({url})
980
- .then((foundUrl) => assert.equal(foundUrl, url)));
992
+ services.waitForService({url}).then((foundUrl) => assert.equal(foundUrl, url)));
981
993
  });
982
994
 
983
995
  describe('when using the url and name parameter properties', () => {
984
996
  it('should resolve to the appropriate url', () =>
985
- services.waitForService({name, url})
986
- .then((foundUrl) => assert.equal(foundUrl, url)));
997
+ services.waitForService({name, url}).then((foundUrl) => assert.equal(foundUrl, url)));
987
998
  });
988
999
  });
989
1000
 
@@ -998,7 +1009,7 @@ describe('webex-core', () => {
998
1009
 
999
1010
  describe('when using the url parameter property', () => {
1000
1011
  it('should return a resolve promise', () =>
1001
- // const waitForService = services.waitForService({url, timeout});
1012
+ // const waitForService = services.waitForService({url, timeout});
1002
1013
 
1003
1014
  services.waitForService({url, timeout}).then((foundUrl) => {
1004
1015
  assert.equal(foundUrl, url);
@@ -1020,7 +1031,9 @@ describe('webex-core', () => {
1020
1031
  describe('when using the name and url parameter properties', () => {
1021
1032
  it('should return a rejected promise', () => {
1022
1033
  const waitForService = services.waitForService({
1023
- name, url, timeout
1034
+ name,
1035
+ url,
1036
+ timeout,
1024
1037
  });
1025
1038
 
1026
1039
  assert.isRejected(waitForService);
@@ -1041,56 +1054,48 @@ describe('webex-core', () => {
1041
1054
  it('should resolve to the appropriate url', () =>
1042
1055
  Promise.all([
1043
1056
  services.waitForService({name}),
1044
- services.collectPreauthCatalog()
1045
- ])
1046
- .then(([foundUrl]) => assert.equal(foundUrl, url)));
1057
+ services.collectPreauthCatalog(),
1058
+ ]).then(([foundUrl]) => assert.equal(foundUrl, url)));
1047
1059
  });
1048
1060
 
1049
1061
  describe('when using the url parameter property', () => {
1050
1062
  it('should resolve to the appropriate url', () =>
1051
1063
  Promise.all([
1052
1064
  services.waitForService({url}),
1053
- services.collectPreauthCatalog()
1054
- ])
1055
- .then(([foundUrl]) => assert.equal(foundUrl, url)));
1065
+ services.collectPreauthCatalog(),
1066
+ ]).then(([foundUrl]) => assert.equal(foundUrl, url)));
1056
1067
  });
1057
1068
 
1058
1069
  describe('when using the name and url parameter property', () => {
1059
1070
  it('should resolve to the appropriate url', () =>
1060
1071
  Promise.all([
1061
1072
  services.waitForService({name, url}),
1062
- services.collectPreauthCatalog()
1063
- ])
1064
- .then(([foundUrl]) => assert.equal(foundUrl, url)));
1073
+ services.collectPreauthCatalog(),
1074
+ ]).then(([foundUrl]) => assert.equal(foundUrl, url)));
1065
1075
  });
1066
1076
  });
1067
1077
 
1068
1078
  describe('when all catalogs become available', () => {
1069
1079
  describe('when using the name parameter property', () => {
1070
1080
  it('should resolve to the appropriate url', () =>
1071
- Promise.all([
1072
- services.waitForService({name}),
1073
- services.initServiceCatalogs()
1074
- ])
1075
- .then(([foundUrl]) => assert.equal(foundUrl, url)));
1081
+ Promise.all([services.waitForService({name}), services.initServiceCatalogs()]).then(
1082
+ ([foundUrl]) => assert.equal(foundUrl, url)
1083
+ ));
1076
1084
  });
1077
1085
 
1078
1086
  describe('when using the url parameter property', () => {
1079
1087
  it('should resolve to the appropriate url', () =>
1080
- Promise.all([
1081
- services.waitForService({url}),
1082
- services.initServiceCatalogs()
1083
- ])
1084
- .then(([foundUrl]) => assert.equal(foundUrl, url)));
1088
+ Promise.all([services.waitForService({url}), services.initServiceCatalogs()]).then(
1089
+ ([foundUrl]) => assert.equal(foundUrl, url)
1090
+ ));
1085
1091
  });
1086
1092
 
1087
1093
  describe('when using the name and url parameter property', () => {
1088
1094
  it('should resolve to the appropriate url', () =>
1089
1095
  Promise.all([
1090
1096
  services.waitForService({name, url}),
1091
- services.initServiceCatalogs()
1092
- ])
1093
- .then(([foundUrl]) => assert.equal(foundUrl, url)));
1097
+ services.initServiceCatalogs(),
1098
+ ]).then(([foundUrl]) => assert.equal(foundUrl, url)));
1094
1099
  });
1095
1100
  });
1096
1101
  });
@@ -1102,13 +1107,13 @@ describe('webex-core', () => {
1102
1107
  const unauthServices = unauthWebex.internal.services;
1103
1108
  const forceRefresh = true;
1104
1109
 
1105
- it('updates the preauth catalog without email', () => unauthServices.collectPreauthCatalog()
1106
- .then(() => {
1110
+ it('updates the preauth catalog without email', () =>
1111
+ unauthServices.collectPreauthCatalog().then(() => {
1107
1112
  assert.isAbove(Object.keys(unauthServices.list()).length, 0);
1108
1113
  }));
1109
1114
 
1110
- it('updates the preauth catalog with email', () => unauthServices.collectPreauthCatalog({email: webexUser.email})
1111
- .then(() => {
1115
+ it('updates the preauth catalog with email', () =>
1116
+ unauthServices.collectPreauthCatalog({email: webexUser.email}).then(() => {
1112
1117
  assert.isAbove(Object.keys(unauthServices.list()).length, 0);
1113
1118
  }));
1114
1119
 
@@ -1116,35 +1121,38 @@ describe('webex-core', () => {
1116
1121
  const updateServiceSpy = sinon.spy(unauthServices, 'updateServices');
1117
1122
  const fetchNewServiceHostmapSpy = sinon.spy(unauthServices, '_fetchNewServiceHostmap');
1118
1123
 
1119
- unauthServices.collectPreauthCatalog(
1120
- {email: webexUser.email}, forceRefresh
1121
- )
1122
- .then(() => {
1123
- assert.calledOnce(updateServiceSpy);
1124
- assert.calledWith(
1125
- updateServiceSpy,
1126
- sinon.match.has(
1127
- 'from', 'limited',
1128
- 'query', {emailhash: sinon.match(/\b[A-Fa-f0-9]{64}\b/)},
1129
- 'forceRefresh', forceRefresh
1130
- )
1131
- );
1124
+ unauthServices.collectPreauthCatalog({email: webexUser.email}, forceRefresh).then(() => {
1125
+ assert.calledOnce(updateServiceSpy);
1126
+ assert.calledWith(
1127
+ updateServiceSpy,
1128
+ sinon.match.has(
1129
+ 'from',
1130
+ 'limited',
1131
+ 'query',
1132
+ {emailhash: sinon.match(/\b[A-Fa-f0-9]{64}\b/)},
1133
+ 'forceRefresh',
1134
+ forceRefresh
1135
+ )
1136
+ );
1132
1137
 
1133
- assert.calledOnce(fetchNewServiceHostmapSpy);
1134
- assert.calledWith(
1135
- fetchNewServiceHostmapSpy,
1136
- sinon.match.has(
1137
- 'from', 'limited',
1138
- 'query', {emailhash: sinon.match(/\b[A-Fa-f0-9]{64}\b/)},
1139
- 'forceRefresh', forceRefresh
1140
- )
1141
- );
1138
+ assert.calledOnce(fetchNewServiceHostmapSpy);
1139
+ assert.calledWith(
1140
+ fetchNewServiceHostmapSpy,
1141
+ sinon.match.has(
1142
+ 'from',
1143
+ 'limited',
1144
+ 'query',
1145
+ {emailhash: sinon.match(/\b[A-Fa-f0-9]{64}\b/)},
1146
+ 'forceRefresh',
1147
+ forceRefresh
1148
+ )
1149
+ );
1142
1150
 
1143
- fetchNewServiceHostmapSpy.returnValues[0].then((res) => {
1144
- assert.isAbove(res.length, 0);
1145
- });
1146
- done();
1151
+ fetchNewServiceHostmapSpy.returnValues[0].then((res) => {
1152
+ assert.isAbove(res.length, 0);
1147
1153
  });
1154
+ done();
1155
+ });
1148
1156
  });
1149
1157
  });
1150
1158
 
@@ -1152,18 +1160,18 @@ describe('webex-core', () => {
1152
1160
  const unauthWebex = new WebexCore({config: {credentials: {federation: true}}});
1153
1161
  const unauthServices = unauthWebex.internal.services;
1154
1162
 
1155
- it('requires an email as the parameter', () => unauthServices.collectPreauthCatalog()
1156
- .catch((e) => {
1163
+ it('requires an email as the parameter', () =>
1164
+ unauthServices.collectPreauthCatalog().catch((e) => {
1157
1165
  assert(true, e);
1158
1166
  }));
1159
1167
 
1160
- it('requires a token as the parameter', () => unauthServices.collectPreauthCatalog({email: 'email@website.com'})
1161
- .catch((e) => {
1168
+ it('requires a token as the parameter', () =>
1169
+ unauthServices.collectPreauthCatalog({email: 'email@website.com'}).catch((e) => {
1162
1170
  assert(true, e);
1163
1171
  }));
1164
1172
 
1165
- it('updates the preauth catalog', () => unauthServices.collectPreauthCatalog({email: webexUser.email})
1166
- .then(() => {
1173
+ it('updates the preauth catalog', () =>
1174
+ unauthServices.collectPreauthCatalog({email: webexUser.email}).then(() => {
1167
1175
  assert.isAbove(Object.keys(unauthServices.list()).length, 0);
1168
1176
  }));
1169
1177
  });
@@ -1172,17 +1180,18 @@ describe('webex-core', () => {
1172
1180
  let fullRemoteHM;
1173
1181
  let limitedRemoteHM;
1174
1182
 
1175
- before('collect remote catalogs', () => Promise.all([
1176
- services._fetchNewServiceHostmap(),
1177
- services._fetchNewServiceHostmap({
1178
- from: 'limited',
1179
- query: {userId: webexUser.id}
1180
- })
1181
- ])
1182
- .then(([fRHM, lRHM]) => {
1183
+ before('collect remote catalogs', () =>
1184
+ Promise.all([
1185
+ services._fetchNewServiceHostmap(),
1186
+ services._fetchNewServiceHostmap({
1187
+ from: 'limited',
1188
+ query: {userId: webexUser.id},
1189
+ }),
1190
+ ]).then(([fRHM, lRHM]) => {
1183
1191
  fullRemoteHM = fRHM;
1184
1192
  limitedRemoteHM = lRHM;
1185
- }));
1193
+ })
1194
+ );
1186
1195
 
1187
1196
  it('resolves to an authed u2c hostmap when no params specified', () => {
1188
1197
  assert.typeOf(fullRemoteHM, 'array');
@@ -1194,18 +1203,18 @@ describe('webex-core', () => {
1194
1203
  assert.isAbove(limitedRemoteHM.length, 0);
1195
1204
  });
1196
1205
 
1197
- it('rejects if the params provided are invalid', () => (
1198
- services._fetchNewServiceHostmap({
1199
- from: 'limited',
1200
- query: {userId: 'notValid'}
1201
- })
1206
+ it('rejects if the params provided are invalid', () =>
1207
+ services
1208
+ ._fetchNewServiceHostmap({
1209
+ from: 'limited',
1210
+ query: {userId: 'notValid'},
1211
+ })
1202
1212
  .then(() => {
1203
1213
  assert.isTrue(false, 'should have rejected');
1204
1214
  })
1205
1215
  .catch((e) => {
1206
1216
  assert.typeOf(e, 'Error');
1207
- })
1208
- ));
1217
+ }));
1209
1218
  });
1210
1219
  });
1211
1220
  });