@itentialopensource/adapter-efficientip_solidserver 0.1.1 → 0.2.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 (42) hide show
  1. package/AUTH.md +39 -0
  2. package/BROKER.md +199 -0
  3. package/CALLS.md +169 -0
  4. package/CHANGELOG.md +9 -2
  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 +221 -571
  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 +6 -0
  18. package/package.json +13 -7
  19. package/pronghorn.json +642 -378
  20. package/propertiesDecorators.json +14 -0
  21. package/propertiesSchema.json +422 -1
  22. package/refs?service=git-upload-pack +0 -0
  23. package/report/adapterInfo.json +10 -0
  24. package/report/updateReport1653233995404.json +120 -0
  25. package/sampleProperties.json +90 -1
  26. package/test/integration/adapterTestBasicGet.js +1 -1
  27. package/test/integration/adapterTestIntegration.js +26 -105
  28. package/test/unit/adapterBaseTestUnit.js +30 -25
  29. package/test/unit/adapterTestUnit.js +174 -159
  30. package/utils/adapterInfo.js +206 -0
  31. package/utils/addAuth.js +94 -0
  32. package/utils/artifactize.js +0 -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/patches2bundledDeps.js +90 -0
  37. package/utils/pre-commit.sh +3 -0
  38. package/utils/removeHooks.js +20 -0
  39. package/utils/tbScript.js +43 -22
  40. package/utils/tbUtils.js +99 -19
  41. package/utils/testRunner.js +16 -16
  42. package/utils/troubleshootingAdapter.js +2 -26
@@ -34,7 +34,7 @@ describe('[integration] Adapter BasicGET Test', () => {
34
34
  context('Testing GET calls without query parameters', () => {
35
35
  before(async () => {
36
36
  const iapDir = path.join(__dirname, '../../../../../');
37
- if (!utils.withinIAP(iapDir)) {
37
+ if (!utils.areWeUnderIAPinstallationDirectory()) {
38
38
  const sampleProperties = require('../../sampleProperties.json');
39
39
  const adapter = { properties: sampleProperties };
40
40
  a = basicGet.getAdapterInstance(adapter);
@@ -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
@@ -43,102 +59,7 @@ global.pronghornProps = {
43
59
  adapters: [{
44
60
  id: 'Test-efficientip_solidserver',
45
61
  type: 'EfficientipSolidserver',
46
- properties: {
47
- host,
48
- port,
49
- base_path: '/rest',
50
- version: '',
51
- cache_location: 'none',
52
- encode_pathvars: true,
53
- save_metric: false,
54
- stub,
55
- protocol,
56
- authentication: {
57
- auth_method: 'basic user_password',
58
- username,
59
- password,
60
- token: '',
61
- invalid_token_error: 401,
62
- token_timeout: -1,
63
- token_cache: 'local',
64
- auth_field: 'header.headers.Authorization',
65
- auth_field_format: 'Basic {b64}{username}:{password}{/b64}',
66
- auth_logging: false,
67
- client_id: '',
68
- client_secret: '',
69
- grant_type: ''
70
- },
71
- healthcheck: {
72
- type: 'intermittent',
73
- frequency: 600000,
74
- query_object: {}
75
- },
76
- throttle: {
77
- throttle_enabled: false,
78
- number_pronghorns: 1,
79
- sync_async: 'sync',
80
- max_in_queue: 1000,
81
- concurrent_max: 1,
82
- expire_timeout: 0,
83
- avg_runtime: 200,
84
- priorities: [
85
- {
86
- value: 0,
87
- percent: 100
88
- }
89
- ]
90
- },
91
- request: {
92
- number_redirects: 0,
93
- number_retries: 3,
94
- limit_retry_error: [0],
95
- failover_codes: [],
96
- attempt_timeout: attemptTimeout,
97
- global_request: {
98
- payload: {},
99
- uriOptions: {},
100
- addlHeaders: {},
101
- authData: {}
102
- },
103
- healthcheck_on_timeout: true,
104
- return_raw: true,
105
- archiving: false,
106
- return_request: false
107
- },
108
- proxy: {
109
- enabled: false,
110
- host: '',
111
- port: 1,
112
- protocol: 'http',
113
- username: '',
114
- password: ''
115
- },
116
- ssl: {
117
- ecdhCurve: '',
118
- enabled: sslenable,
119
- accept_invalid_cert: sslinvalid,
120
- ca_file: '',
121
- key_file: '',
122
- cert_file: '',
123
- secure_protocol: '',
124
- ciphers: ''
125
- },
126
- mongo: {
127
- host: '',
128
- port: 0,
129
- database: '',
130
- username: '',
131
- password: '',
132
- replSet: '',
133
- db_ssl: {
134
- enabled: false,
135
- accept_invalid_cert: false,
136
- ca_file: '',
137
- key_file: '',
138
- cert_file: ''
139
- }
140
- }
141
- }
62
+ properties: samProps
142
63
  }]
143
64
  }
144
65
  };
@@ -317,8 +317,10 @@ describe('[unit] Adapter Base Test', () => {
317
317
  });
318
318
  it('should return a list of functions', (done) => {
319
319
  const returnedFunctions = ['addEntityCache', 'capabilityResults', 'checkActionFiles', 'checkProperties', 'connect', 'encryptProperty',
320
- 'entityInList', 'findPath', 'getAllCapabilities', 'getAllFunctions', 'getQueue', 'getWorkflowFunctions', 'healthCheck',
321
- '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',
322
324
  'emit', 'eventNames', 'getMaxListeners', 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener',
323
325
  'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
324
326
  try {
@@ -337,10 +339,10 @@ describe('[unit] Adapter Base Test', () => {
337
339
  }).timeout(attemptTimeout);
338
340
  });
339
341
 
340
- describe('#getWorkflowFunctions', () => {
341
- it('should have a getWorkflowFunctions function', (done) => {
342
+ describe('#iapGetAdapterWorkflowFunctions', () => {
343
+ it('should have a iapGetAdapterWorkflowFunctions function', (done) => {
342
344
  try {
343
- assert.equal(true, typeof a.getWorkflowFunctions === 'function');
345
+ assert.equal(true, typeof a.iapGetAdapterWorkflowFunctions === 'function');
344
346
  done();
345
347
  } catch (error) {
346
348
  log.error(`Test Failure: ${error}`);
@@ -349,7 +351,7 @@ describe('[unit] Adapter Base Test', () => {
349
351
  });
350
352
  it('should retrieve workflow functions', (done) => {
351
353
  try {
352
- const expectedFunctions = a.getWorkflowFunctions([]);
354
+ const expectedFunctions = a.iapGetAdapterWorkflowFunctions([]);
353
355
  try {
354
356
  assert.equal(0, expectedFunctions.length);
355
357
  done();
@@ -426,10 +428,10 @@ describe('[unit] Adapter Base Test', () => {
426
428
  }).timeout(attemptTimeout);
427
429
  });
428
430
 
429
- describe('#getQueue', () => {
430
- it('should have a getQueue function', (done) => {
431
+ describe('#iapGetAdapterQueue', () => {
432
+ it('should have a iapGetAdapterQueue function', (done) => {
431
433
  try {
432
- assert.equal(true, typeof a.getQueue === 'function');
434
+ assert.equal(true, typeof a.iapGetAdapterQueue === 'function');
433
435
  done();
434
436
  } catch (error) {
435
437
  log.error(`Test Failure: ${error}`);
@@ -438,7 +440,7 @@ describe('[unit] Adapter Base Test', () => {
438
440
  });
439
441
  it('should get information for all of the requests currently in the queue', (done) => {
440
442
  try {
441
- const expectedFunctions = a.getQueue();
443
+ const expectedFunctions = a.iapGetAdapterQueue();
442
444
  try {
443
445
  assert.equal(0, expectedFunctions.length);
444
446
  done();
@@ -817,12 +819,17 @@ describe('[unit] Adapter Base Test', () => {
817
819
  try {
818
820
  assert.notEqual(0, expectedCapabilities.length);
819
821
  assert.equal('.generic', expectedCapabilities[0].entity);
820
- assert.equal(5, expectedCapabilities[0].actions.length);
822
+ assert.equal(10, expectedCapabilities[0].actions.length);
821
823
  assert.equal('getGenerics', expectedCapabilities[0].actions[0]);
822
824
  assert.equal('createGeneric', expectedCapabilities[0].actions[1]);
823
825
  assert.equal('updateGeneric', expectedCapabilities[0].actions[2]);
824
826
  assert.equal('patchGeneric', expectedCapabilities[0].actions[3]);
825
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]);
826
833
  assert.equal('.system', expectedCapabilities[1].entity);
827
834
  assert.equal(2, expectedCapabilities[1].actions.length);
828
835
  assert.equal('getToken', expectedCapabilities[1].actions[0]);
@@ -843,12 +850,10 @@ describe('[unit] Adapter Base Test', () => {
843
850
  }).timeout(attemptTimeout);
844
851
  });
845
852
 
846
- // const returnedFunctions = ['updateAdapterConfiguration'];
847
-
848
- describe('#updateAdapterConfiguration', () => {
849
- it('should have a updateAdapterConfiguration function', (done) => {
853
+ describe('#iapUpdateAdapterConfiguration', () => {
854
+ it('should have a iapUpdateAdapterConfiguration function', (done) => {
850
855
  try {
851
- assert.equal(true, typeof a.updateAdapterConfiguration === 'function');
856
+ assert.equal(true, typeof a.iapUpdateAdapterConfiguration === 'function');
852
857
  done();
853
858
  } catch (error) {
854
859
  log.error(`Test Failure: ${error}`);
@@ -857,7 +862,7 @@ describe('[unit] Adapter Base Test', () => {
857
862
  });
858
863
  it('should return no updated if no changes are provided', (done) => {
859
864
  try {
860
- a.updateAdapterConfiguration(null, null, null, null, null, (data, error) => {
865
+ a.iapUpdateAdapterConfiguration(null, null, null, null, null, (data, error) => {
861
866
  try {
862
867
  assert.equal('No configuration updates to make', data.response);
863
868
  done();
@@ -873,10 +878,10 @@ describe('[unit] Adapter Base Test', () => {
873
878
  }).timeout(attemptTimeout);
874
879
  it('should throw an error if missing configuration file', (done) => {
875
880
  try {
876
- a.updateAdapterConfiguration(null, { name: 'fakeChange' }, null, null, null, (data, error) => {
881
+ a.iapUpdateAdapterConfiguration(null, { name: 'fakeChange' }, null, null, null, (data, error) => {
877
882
  try {
878
883
  const displayE = 'configFile is required';
879
- runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
884
+ runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
880
885
  done();
881
886
  } catch (err) {
882
887
  log.error(`Test Failure: ${err}`);
@@ -890,10 +895,10 @@ describe('[unit] Adapter Base Test', () => {
890
895
  }).timeout(attemptTimeout);
891
896
  it('if not package.json, entity is required', (done) => {
892
897
  try {
893
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, null, null, null, (data, error) => {
898
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, null, null, null, (data, error) => {
894
899
  try {
895
900
  const displayE = 'Unsupported Configuration Change or Missing Entity';
896
- runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
901
+ runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
897
902
  done();
898
903
  } catch (err) {
899
904
  log.error(`Test Failure: ${err}`);
@@ -907,10 +912,10 @@ describe('[unit] Adapter Base Test', () => {
907
912
  }).timeout(attemptTimeout);
908
913
  it('if not package.json, type is required', (done) => {
909
914
  try {
910
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'entity', null, null, (data, error) => {
915
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'entity', null, null, (data, error) => {
911
916
  try {
912
917
  const displayE = 'type is required';
913
- runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
918
+ runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
914
919
  done();
915
920
  } catch (err) {
916
921
  log.error(`Test Failure: ${err}`);
@@ -924,10 +929,10 @@ describe('[unit] Adapter Base Test', () => {
924
929
  }).timeout(attemptTimeout);
925
930
  it('if not package.json, entity must be valid', (done) => {
926
931
  try {
927
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'fakeEntity', 'fakeType', null, (data, error) => {
932
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'fakeEntity', 'fakeType', null, (data, error) => {
928
933
  try {
929
934
  const displayE = 'Incomplete Configuration Change: Invalid Entity - fakeEntity';
930
- runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
935
+ runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
931
936
  done();
932
937
  } catch (err) {
933
938
  log.error(`Test Failure: ${err}`);