@itentialopensource/adapter-webex_teams 0.5.6 → 0.6.0

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 (43) hide show
  1. package/AUTH.md +39 -0
  2. package/BROKER.md +199 -0
  3. package/CALLS.md +169 -0
  4. package/CHANGELOG.md +31 -24
  5. package/CODE_OF_CONDUCT.md +12 -17
  6. package/CONTRIBUTING.md +88 -74
  7. package/ENHANCE.md +69 -0
  8. package/PROPERTIES.md +641 -0
  9. package/README.md +225 -502
  10. package/SUMMARY.md +9 -0
  11. package/SYSTEMINFO.md +11 -0
  12. package/TROUBLESHOOT.md +47 -0
  13. package/adapter.js +348 -57
  14. package/adapterBase.js +1021 -245
  15. package/entities/.generic/action.json +110 -5
  16. package/entities/.generic/schema.json +6 -1
  17. package/error.json +12 -0
  18. package/package.json +20 -13
  19. package/pronghorn.json +642 -378
  20. package/propertiesDecorators.json +14 -0
  21. package/propertiesSchema.json +436 -0
  22. package/refs?service=git-upload-pack +0 -0
  23. package/report/adapterInfo.json +10 -0
  24. package/report/updateReport1653575821854.json +120 -0
  25. package/sampleProperties.json +94 -2
  26. package/storage/metrics.json +692 -0
  27. package/test/integration/adapterTestBasicGet.js +2 -2
  28. package/test/integration/adapterTestIntegration.js +38 -112
  29. package/test/unit/adapterBaseTestUnit.js +35 -27
  30. package/test/unit/adapterTestUnit.js +580 -182
  31. package/utils/adapterInfo.js +206 -0
  32. package/utils/addAuth.js +94 -0
  33. package/utils/basicGet.js +1 -14
  34. package/utils/entitiesToDB.js +179 -0
  35. package/utils/modify.js +1 -1
  36. package/utils/packModificationScript.js +1 -1
  37. package/utils/patches2bundledDeps.js +90 -0
  38. package/utils/pre-commit.sh +3 -0
  39. package/utils/removeHooks.js +20 -0
  40. package/utils/tbScript.js +43 -22
  41. package/utils/tbUtils.js +126 -29
  42. package/utils/testRunner.js +16 -16
  43. package/utils/troubleshootingAdapter.js +2 -26
@@ -3,6 +3,8 @@
3
3
  // Set globals
4
4
  /* global describe it log pronghornProps */
5
5
  /* eslint no-unused-vars: warn */
6
+ /* eslint no-underscore-dangle: warn */
7
+ /* eslint import/no-dynamic-require:warn */
6
8
 
7
9
  // include required items for testing & logging
8
10
  const assert = require('assert');
@@ -13,25 +15,39 @@ const winston = require('winston');
13
15
  const { expect } = require('chai');
14
16
  const { use } = require('chai');
15
17
  const td = require('testdouble');
18
+ const util = require('util');
16
19
 
17
20
  const anything = td.matchers.anything();
18
21
 
19
22
  // stub and attemptTimeout are used throughout the code so set them here
20
23
  let logLevel = 'none';
21
- const stub = true;
22
24
  const isRapidFail = false;
23
25
  const isSaveMockData = false;
24
- const attemptTimeout = 5000;
26
+
27
+ // read in the properties from the sampleProperties files
28
+ let adaptdir = __dirname;
29
+ if (adaptdir.endsWith('/test/integration')) {
30
+ adaptdir = adaptdir.substring(0, adaptdir.length - 17);
31
+ } else if (adaptdir.endsWith('/test/unit')) {
32
+ adaptdir = adaptdir.substring(0, adaptdir.length - 10);
33
+ }
34
+ const samProps = require(`${adaptdir}/sampleProperties.json`).properties;
25
35
 
26
36
  // these variables can be changed to run in integrated mode so easier to set them here
27
37
  // always check these in with bogus data!!!
28
- const host = 'replace.hostorip.here';
29
- const username = 'username';
30
- const password = 'password';
31
- const protocol = 'http';
32
- const port = 80;
33
- const sslenable = false;
34
- const sslinvalid = false;
38
+ samProps.stub = true;
39
+ samProps.host = 'replace.hostorip.here';
40
+ samProps.authentication.username = 'username';
41
+ samProps.authentication.password = 'password';
42
+ samProps.protocol = 'http';
43
+ samProps.port = 80;
44
+ samProps.ssl.enabled = false;
45
+ samProps.ssl.accept_invalid_cert = false;
46
+ if (samProps.request.attempt_timeout < 30000) {
47
+ samProps.request.attempt_timeout = 30000;
48
+ }
49
+ const attemptTimeout = samProps.request.attempt_timeout;
50
+ const { stub } = samProps;
35
51
 
36
52
  // these are the adapter properties. You generally should not need to alter
37
53
  // any of these after they are initially set up
@@ -41,101 +57,9 @@ global.pronghornProps = {
41
57
  },
42
58
  adapterProps: {
43
59
  adapters: [{
44
- id: 'Test-WebexTeams',
60
+ id: 'Test-webex_teams',
45
61
  type: 'WebexTeams',
46
- properties: {
47
- host,
48
- port,
49
- base_path: '//api',
50
- version: 'v1.3.1',
51
- cache_location: 'none',
52
- encode_pathvars: true,
53
- save_metric: false,
54
- stub,
55
- protocol,
56
- authentication: {
57
- auth_method: 'no_authentication',
58
- username,
59
- password,
60
- token: '',
61
- token_timeout: -1,
62
- token_cache: 'local',
63
- invalid_token_error: 401,
64
- auth_field: 'header.headers.Authorization',
65
- auth_field_format: 'Basic {b64}{username}:{password}{/b64}',
66
- auth_logging: false
67
- },
68
- healthcheck: {
69
- type: 'none',
70
- frequency: 60000,
71
- query_object: {}
72
- },
73
- throttle: {
74
- throttle_enabled: false,
75
- number_pronghorns: 1,
76
- sync_async: 'sync',
77
- max_in_queue: 1000,
78
- concurrent_max: 1,
79
- expire_timeout: 0,
80
- avg_runtime: 200,
81
- priorities: [
82
- {
83
- value: 0,
84
- percent: 100
85
- }
86
- ]
87
- },
88
- request: {
89
- number_redirects: 0,
90
- number_retries: 3,
91
- limit_retry_error: 0,
92
- failover_codes: [],
93
- attempt_timeout: attemptTimeout,
94
- global_request: {
95
- payload: {},
96
- uriOptions: {},
97
- addlHeaders: {},
98
- authData: {}
99
- },
100
- healthcheck_on_timeout: true,
101
- return_raw: true,
102
- archiving: false,
103
- return_request: false
104
- },
105
- proxy: {
106
- enabled: false,
107
- host: '',
108
- port: 1,
109
- protocol: 'http',
110
- username: '',
111
- password: ''
112
- },
113
- ssl: {
114
- ecdhCurve: '',
115
- enabled: sslenable,
116
- accept_invalid_cert: sslinvalid,
117
- ca_file: '',
118
- key_file: '',
119
- cert_file: '',
120
- secure_protocol: '',
121
- ciphers: ''
122
- },
123
- mongo: {
124
- host: '',
125
- port: 0,
126
- database: '',
127
- username,
128
- password: '',
129
- replSet: '',
130
- db_ssl: {
131
- enabled: false,
132
- accept_invalid_cert: false,
133
- ca_file: '',
134
- key_file: '',
135
- cert_file: ''
136
- }
137
- }
138
- }
62
+ properties: samProps
139
63
  }]
140
64
  }
141
65
  };
@@ -310,7 +234,7 @@ function saveMockData(entityName, actionName, descriptor, responseData) {
310
234
  }
311
235
 
312
236
  // require the adapter that we are going to be using
313
- const WebexTeams = require('../../adapter.js');
237
+ const WebexTeams = require('../../adapter');
314
238
 
315
239
  // begin the testing - these should be pretty well defined between the describe and the it!
316
240
  describe('[integration] WebexTeams Adapter Test', () => {
@@ -341,6 +265,8 @@ describe('[integration] WebexTeams Adapter Test', () => {
341
265
  try {
342
266
  assert.notEqual(null, a);
343
267
  assert.notEqual(undefined, a);
268
+ const checkId = global.pronghornProps.adapterProps.adapters[0].id;
269
+ assert.equal(checkId, a.id);
344
270
  assert.notEqual(null, a.allProps);
345
271
  const check = global.pronghornProps.adapterProps.adapters[0].properties.healthcheck.type;
346
272
  assert.equal(check, a.healthcheckType);
@@ -575,7 +501,7 @@ describe('[integration] WebexTeams Adapter Test', () => {
575
501
  try {
576
502
  if (stub) {
577
503
  const displayE = 'Error 400 received on request';
578
- runErrorAsserts(data, error, 'AD.500', 'Test-WebexTeams-connectorRest-handleEndResponse', displayE);
504
+ runErrorAsserts(data, error, 'AD.500', 'Test-webex_teams-connectorRest-handleEndResponse', displayE);
579
505
  } else {
580
506
  runCommonAsserts(data, error);
581
507
  }
@@ -771,7 +697,7 @@ describe('[integration] WebexTeams Adapter Test', () => {
771
697
  try {
772
698
  if (stub) {
773
699
  const displayE = 'Error 400 received on request';
774
- runErrorAsserts(data, error, 'AD.500', 'Test-WebexTeams-connectorRest-handleEndResponse', displayE);
700
+ runErrorAsserts(data, error, 'AD.500', 'Test-webex_teams-connectorRest-handleEndResponse', displayE);
775
701
  } else {
776
702
  runCommonAsserts(data, error);
777
703
  }
@@ -926,7 +852,7 @@ describe('[integration] WebexTeams Adapter Test', () => {
926
852
  try {
927
853
  if (stub) {
928
854
  const displayE = 'Error 400 received on request';
929
- runErrorAsserts(data, error, 'AD.500', 'Test-WebexTeams-connectorRest-handleEndResponse', displayE);
855
+ runErrorAsserts(data, error, 'AD.500', 'Test-webex_teams-connectorRest-handleEndResponse', displayE);
930
856
  } else {
931
857
  runCommonAsserts(data, error);
932
858
  }
@@ -1057,7 +983,7 @@ describe('[integration] WebexTeams Adapter Test', () => {
1057
983
  try {
1058
984
  if (stub) {
1059
985
  const displayE = 'Error 400 received on request';
1060
- runErrorAsserts(data, error, 'AD.500', 'Test-WebexTeams-connectorRest-handleEndResponse', displayE);
986
+ runErrorAsserts(data, error, 'AD.500', 'Test-webex_teams-connectorRest-handleEndResponse', displayE);
1061
987
  } else {
1062
988
  runCommonAsserts(data, error);
1063
989
  }
@@ -1200,7 +1126,7 @@ describe('[integration] WebexTeams Adapter Test', () => {
1200
1126
  try {
1201
1127
  if (stub) {
1202
1128
  const displayE = 'Error 400 received on request';
1203
- runErrorAsserts(data, error, 'AD.500', 'Test-WebexTeams-connectorRest-handleEndResponse', displayE);
1129
+ runErrorAsserts(data, error, 'AD.500', 'Test-webex_teams-connectorRest-handleEndResponse', displayE);
1204
1130
  } else {
1205
1131
  runCommonAsserts(data, error);
1206
1132
  }
@@ -1352,7 +1278,7 @@ describe('[integration] WebexTeams Adapter Test', () => {
1352
1278
  try {
1353
1279
  if (stub) {
1354
1280
  const displayE = 'Error 400 received on request';
1355
- runErrorAsserts(data, error, 'AD.500', 'Test-WebexTeams-connectorRest-handleEndResponse', displayE);
1281
+ runErrorAsserts(data, error, 'AD.500', 'Test-webex_teams-connectorRest-handleEndResponse', displayE);
1356
1282
  } else {
1357
1283
  runCommonAsserts(data, error);
1358
1284
  }
@@ -1522,7 +1448,7 @@ describe('[integration] WebexTeams Adapter Test', () => {
1522
1448
  try {
1523
1449
  if (stub) {
1524
1450
  const displayE = 'Error 400 received on request';
1525
- runErrorAsserts(data, error, 'AD.500', 'Test-WebexTeams-connectorRest-handleEndResponse', displayE);
1451
+ runErrorAsserts(data, error, 'AD.500', 'Test-webex_teams-connectorRest-handleEndResponse', displayE);
1526
1452
  } else {
1527
1453
  runCommonAsserts(data, error);
1528
1454
  }
@@ -1716,7 +1642,7 @@ describe('[integration] WebexTeams Adapter Test', () => {
1716
1642
  try {
1717
1643
  if (stub) {
1718
1644
  const displayE = 'Error 400 received on request';
1719
- runErrorAsserts(data, error, 'AD.500', 'Test-WebexTeams-connectorRest-handleEndResponse', displayE);
1645
+ runErrorAsserts(data, error, 'AD.500', 'Test-webex_teams-connectorRest-handleEndResponse', displayE);
1720
1646
  } else {
1721
1647
  runCommonAsserts(data, error);
1722
1648
  }
@@ -61,7 +61,10 @@ global.pronghornProps = {
61
61
  token_cache: 'local',
62
62
  auth_field: 'header.headers.Authorization',
63
63
  auth_field_format: 'Basic {b64}{username}:{password}{/b64}',
64
- auth_logging: false
64
+ auth_logging: false,
65
+ client_id: '',
66
+ client_secret: '',
67
+ grant_type: ''
65
68
  },
66
69
  healthcheck: {
67
70
  type: 'none',
@@ -194,7 +197,7 @@ function runErrorAsserts(data, error, code, origin, displayStr) {
194
197
  }
195
198
 
196
199
  // require the adapter that we are going to be using
197
- const AdapterBase = require('../../adapterBase.js');
200
+ const AdapterBase = require('../../adapterBase');
198
201
 
199
202
  // delete the .DS_Store directory in entities -- otherwise this will cause errors
200
203
  const dirPath = path.join(__dirname, '../../entities/.DS_Store');
@@ -314,8 +317,10 @@ describe('[unit] Adapter Base Test', () => {
314
317
  });
315
318
  it('should return a list of functions', (done) => {
316
319
  const returnedFunctions = ['addEntityCache', 'capabilityResults', 'checkActionFiles', 'checkProperties', 'connect', 'encryptProperty',
317
- 'entityInList', 'findPath', 'getAllCapabilities', 'getAllFunctions', 'getQueue', 'getWorkflowFunctions', 'healthCheck',
318
- 'refreshProperties', 'runBasicGet', 'runConnectivity', 'runHealthcheck', 'suspend', 'troubleshoot', 'unsuspend', 'updateAdapterConfiguration', 'addListener',
320
+ 'entityInList', 'getAllCapabilities', 'getAllFunctions', 'getConfig', 'getDevice', 'getDevicesFiltered', 'hasDevices', 'hasEntities',
321
+ 'healthCheck', 'iapFindAdapterPath', 'iapGetAdapterQueue', 'iapGetAdapterWorkflowFunctions', 'iapGetDeviceCount', 'iapMakeBrokerCall',
322
+ 'iapMoveAdapterEntitiesToDB', 'iapRunAdapterBasicGet', 'iapRunAdapterConnectivity', 'iapRunAdapterHealthcheck', 'iapSuspendAdapter',
323
+ 'iapTroubleshootAdapter', 'iapUnsuspendAdapter', 'iapUpdateAdapterConfiguration', 'isAlive', 'refreshProperties', 'addListener',
319
324
  'emit', 'eventNames', 'getMaxListeners', 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener',
320
325
  'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
321
326
  try {
@@ -334,10 +339,10 @@ describe('[unit] Adapter Base Test', () => {
334
339
  }).timeout(attemptTimeout);
335
340
  });
336
341
 
337
- describe('#getWorkflowFunctions', () => {
338
- it('should have a getWorkflowFunctions function', (done) => {
342
+ describe('#iapGetAdapterWorkflowFunctions', () => {
343
+ it('should have a iapGetAdapterWorkflowFunctions function', (done) => {
339
344
  try {
340
- assert.equal(true, typeof a.getWorkflowFunctions === 'function');
345
+ assert.equal(true, typeof a.iapGetAdapterWorkflowFunctions === 'function');
341
346
  done();
342
347
  } catch (error) {
343
348
  log.error(`Test Failure: ${error}`);
@@ -346,7 +351,7 @@ describe('[unit] Adapter Base Test', () => {
346
351
  });
347
352
  it('should retrieve workflow functions', (done) => {
348
353
  try {
349
- const expectedFunctions = a.getWorkflowFunctions([]);
354
+ const expectedFunctions = a.iapGetAdapterWorkflowFunctions([]);
350
355
  try {
351
356
  assert.equal(0, expectedFunctions.length);
352
357
  done();
@@ -423,10 +428,10 @@ describe('[unit] Adapter Base Test', () => {
423
428
  }).timeout(attemptTimeout);
424
429
  });
425
430
 
426
- describe('#getQueue', () => {
427
- it('should have a getQueue function', (done) => {
431
+ describe('#iapGetAdapterQueue', () => {
432
+ it('should have a iapGetAdapterQueue function', (done) => {
428
433
  try {
429
- assert.equal(true, typeof a.getQueue === 'function');
434
+ assert.equal(true, typeof a.iapGetAdapterQueue === 'function');
430
435
  done();
431
436
  } catch (error) {
432
437
  log.error(`Test Failure: ${error}`);
@@ -435,7 +440,7 @@ describe('[unit] Adapter Base Test', () => {
435
440
  });
436
441
  it('should get information for all of the requests currently in the queue', (done) => {
437
442
  try {
438
- const expectedFunctions = a.getQueue();
443
+ const expectedFunctions = a.iapGetAdapterQueue();
439
444
  try {
440
445
  assert.equal(0, expectedFunctions.length);
441
446
  done();
@@ -814,12 +819,17 @@ describe('[unit] Adapter Base Test', () => {
814
819
  try {
815
820
  assert.notEqual(0, expectedCapabilities.length);
816
821
  assert.equal('.generic', expectedCapabilities[0].entity);
817
- assert.equal(5, expectedCapabilities[0].actions.length);
822
+ assert.equal(10, expectedCapabilities[0].actions.length);
818
823
  assert.equal('getGenerics', expectedCapabilities[0].actions[0]);
819
824
  assert.equal('createGeneric', expectedCapabilities[0].actions[1]);
820
825
  assert.equal('updateGeneric', expectedCapabilities[0].actions[2]);
821
826
  assert.equal('patchGeneric', expectedCapabilities[0].actions[3]);
822
827
  assert.equal('deleteGeneric', expectedCapabilities[0].actions[4]);
828
+ assert.equal('getGenericsNoBase', expectedCapabilities[0].actions[5]);
829
+ assert.equal('createGenericNoBase', expectedCapabilities[0].actions[6]);
830
+ assert.equal('updateGenericNoBase', expectedCapabilities[0].actions[7]);
831
+ assert.equal('patchGenericNoBase', expectedCapabilities[0].actions[8]);
832
+ assert.equal('deleteGenericNoBase', expectedCapabilities[0].actions[9]);
823
833
  assert.equal('.system', expectedCapabilities[1].entity);
824
834
  assert.equal(2, expectedCapabilities[1].actions.length);
825
835
  assert.equal('getToken', expectedCapabilities[1].actions[0]);
@@ -840,12 +850,10 @@ describe('[unit] Adapter Base Test', () => {
840
850
  }).timeout(attemptTimeout);
841
851
  });
842
852
 
843
- // const returnedFunctions = ['updateAdapterConfiguration'];
844
-
845
- describe('#updateAdapterConfiguration', () => {
846
- it('should have a updateAdapterConfiguration function', (done) => {
853
+ describe('#iapUpdateAdapterConfiguration', () => {
854
+ it('should have a iapUpdateAdapterConfiguration function', (done) => {
847
855
  try {
848
- assert.equal(true, typeof a.updateAdapterConfiguration === 'function');
856
+ assert.equal(true, typeof a.iapUpdateAdapterConfiguration === 'function');
849
857
  done();
850
858
  } catch (error) {
851
859
  log.error(`Test Failure: ${error}`);
@@ -854,7 +862,7 @@ describe('[unit] Adapter Base Test', () => {
854
862
  });
855
863
  it('should return no updated if no changes are provided', (done) => {
856
864
  try {
857
- a.updateAdapterConfiguration(null, null, null, null, null, (data, error) => {
865
+ a.iapUpdateAdapterConfiguration(null, null, null, null, null, (data, error) => {
858
866
  try {
859
867
  assert.equal('No configuration updates to make', data.response);
860
868
  done();
@@ -870,10 +878,10 @@ describe('[unit] Adapter Base Test', () => {
870
878
  }).timeout(attemptTimeout);
871
879
  it('should throw an error if missing configuration file', (done) => {
872
880
  try {
873
- a.updateAdapterConfiguration(null, { name: 'fakeChange' }, null, null, null, (data, error) => {
881
+ a.iapUpdateAdapterConfiguration(null, { name: 'fakeChange' }, null, null, null, (data, error) => {
874
882
  try {
875
883
  const displayE = 'configFile is required';
876
- runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
884
+ runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
877
885
  done();
878
886
  } catch (err) {
879
887
  log.error(`Test Failure: ${err}`);
@@ -887,10 +895,10 @@ describe('[unit] Adapter Base Test', () => {
887
895
  }).timeout(attemptTimeout);
888
896
  it('if not package.json, entity is required', (done) => {
889
897
  try {
890
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, null, null, null, (data, error) => {
898
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, null, null, null, (data, error) => {
891
899
  try {
892
900
  const displayE = 'Unsupported Configuration Change or Missing Entity';
893
- runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
901
+ runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
894
902
  done();
895
903
  } catch (err) {
896
904
  log.error(`Test Failure: ${err}`);
@@ -904,10 +912,10 @@ describe('[unit] Adapter Base Test', () => {
904
912
  }).timeout(attemptTimeout);
905
913
  it('if not package.json, type is required', (done) => {
906
914
  try {
907
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'entity', null, null, (data, error) => {
915
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'entity', null, null, (data, error) => {
908
916
  try {
909
917
  const displayE = 'type is required';
910
- runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
918
+ runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
911
919
  done();
912
920
  } catch (err) {
913
921
  log.error(`Test Failure: ${err}`);
@@ -921,10 +929,10 @@ describe('[unit] Adapter Base Test', () => {
921
929
  }).timeout(attemptTimeout);
922
930
  it('if not package.json, entity must be valid', (done) => {
923
931
  try {
924
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'fakeEntity', 'fakeType', null, (data, error) => {
932
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'fakeEntity', 'fakeType', null, (data, error) => {
925
933
  try {
926
934
  const displayE = 'Incomplete Configuration Change: Invalid Entity - fakeEntity';
927
- runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
935
+ runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
928
936
  done();
929
937
  } catch (err) {
930
938
  log.error(`Test Failure: ${err}`);