@itentialopensource/adapter-nokia_altiplano 0.4.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/AUTH.md +15 -13
  2. package/BROKER.md +199 -0
  3. package/CALLS.md +163 -89
  4. package/CHANGELOG.md +30 -6
  5. package/CODE_OF_CONDUCT.md +12 -17
  6. package/CONTRIBUTING.md +88 -74
  7. package/ENHANCE.md +9 -9
  8. package/PROPERTIES.md +489 -89
  9. package/README.md +221 -571
  10. package/SUMMARY.md +5 -5
  11. package/SYSTEMINFO.md +6 -7
  12. package/TROUBLESHOOT.md +5 -4
  13. package/adapter.js +623 -481
  14. package/adapterBase.js +1006 -252
  15. package/entities/.generic/action.json +105 -0
  16. package/entities/.generic/schema.json +6 -1
  17. package/entities/Entity/action.json +70 -0
  18. package/entities/Entity/schema.json +21 -0
  19. package/entities/Intent/action.json +2 -2
  20. package/error.json +6 -0
  21. package/package.json +5 -3
  22. package/pronghorn.json +877 -573
  23. package/propertiesDecorators.json +14 -0
  24. package/propertiesSchema.json +421 -0
  25. package/refs?service=git-upload-pack +0 -0
  26. package/report/adapterInfo.json +10 -0
  27. package/report/updateReport1651493162166.json +114 -0
  28. package/report/updateReport1652197536783.json +120 -0
  29. package/report/updateReport1652620670443.json +120 -0
  30. package/sampleProperties.json +90 -1
  31. package/test/integration/adapterTestBasicGet.js +1 -1
  32. package/test/integration/adapterTestIntegration.js +101 -108
  33. package/test/unit/adapterBaseTestUnit.js +30 -25
  34. package/test/unit/adapterTestUnit.js +299 -180
  35. package/utils/adapterInfo.js +206 -0
  36. package/utils/entitiesToDB.js +12 -57
  37. package/utils/pre-commit.sh +3 -0
  38. package/utils/tbScript.js +35 -20
  39. package/utils/tbUtils.js +49 -31
  40. package/utils/testRunner.js +16 -16
@@ -0,0 +1,120 @@
1
+ {
2
+ "errors": [],
3
+ "statistics": [
4
+ {
5
+ "owner": "errorJson",
6
+ "description": "New adapter errors available for use",
7
+ "value": 0
8
+ },
9
+ {
10
+ "owner": "errorJson",
11
+ "description": "Adapter errors no longer available for use",
12
+ "value": 0
13
+ },
14
+ {
15
+ "owner": "errorJson",
16
+ "description": "Adapter errors that have been updated (e.g. recommendation changes)",
17
+ "value": 31
18
+ },
19
+ {
20
+ "owner": "packageJson",
21
+ "description": "Number of production dependencies",
22
+ "value": 13
23
+ },
24
+ {
25
+ "owner": "packageJson",
26
+ "description": "Number of development dependencies",
27
+ "value": 7
28
+ },
29
+ {
30
+ "owner": "packageJson",
31
+ "description": "Number of npm scripts",
32
+ "value": 22
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^4.45.4"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 69
43
+ },
44
+ {
45
+ "owner": "markdown",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 338
48
+ },
49
+ {
50
+ "owner": "markdown",
51
+ "description": "Number of lines in the SUMMARY.md",
52
+ "value": 9
53
+ },
54
+ {
55
+ "owner": "markdown",
56
+ "description": "Number of lines in the PROPERTIES.md",
57
+ "value": 642
58
+ },
59
+ {
60
+ "owner": "markdown",
61
+ "description": "Number of lines in the TROUBLESHOOT.md",
62
+ "value": 48
63
+ },
64
+ {
65
+ "owner": "markdown",
66
+ "description": "Number of lines in the ENHANCE.md",
67
+ "value": 70
68
+ },
69
+ {
70
+ "owner": "markdown",
71
+ "description": "Number of lines in the BROKER.md",
72
+ "value": 70
73
+ },
74
+ {
75
+ "owner": "unitTestJS",
76
+ "description": "Number of lines of code in unit tests",
77
+ "value": 2198
78
+ },
79
+ {
80
+ "owner": "unitTestJS",
81
+ "description": "Number of unit tests",
82
+ "value": 110
83
+ },
84
+ {
85
+ "owner": "integrationTestJS",
86
+ "description": "Number of lines of code in integration tests",
87
+ "value": 1086
88
+ },
89
+ {
90
+ "owner": "integrationTestJS",
91
+ "description": "Number of integration tests",
92
+ "value": 29
93
+ },
94
+ {
95
+ "owner": "staticFile",
96
+ "description": "Number of lines of code in adapterBase.js",
97
+ "value": 1750
98
+ },
99
+ {
100
+ "owner": "staticFile",
101
+ "description": "Number of static files added",
102
+ "value": 36
103
+ },
104
+ {
105
+ "owner": "Overall",
106
+ "description": "Total lines of Code",
107
+ "value": 5034
108
+ },
109
+ {
110
+ "owner": "Overall",
111
+ "description": "Total Tests",
112
+ "value": 139
113
+ },
114
+ {
115
+ "owner": "Overall",
116
+ "description": "Total Files",
117
+ "value": 6
118
+ }
119
+ ]
120
+ }
@@ -0,0 +1,120 @@
1
+ {
2
+ "errors": [],
3
+ "statistics": [
4
+ {
5
+ "owner": "errorJson",
6
+ "description": "New adapter errors available for use",
7
+ "value": 0
8
+ },
9
+ {
10
+ "owner": "errorJson",
11
+ "description": "Adapter errors no longer available for use",
12
+ "value": 0
13
+ },
14
+ {
15
+ "owner": "errorJson",
16
+ "description": "Adapter errors that have been updated (e.g. recommendation changes)",
17
+ "value": 31
18
+ },
19
+ {
20
+ "owner": "packageJson",
21
+ "description": "Number of production dependencies",
22
+ "value": 14
23
+ },
24
+ {
25
+ "owner": "packageJson",
26
+ "description": "Number of development dependencies",
27
+ "value": 7
28
+ },
29
+ {
30
+ "owner": "packageJson",
31
+ "description": "Number of npm scripts",
32
+ "value": 22
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^4.45.5"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 70
43
+ },
44
+ {
45
+ "owner": "markdown",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 338
48
+ },
49
+ {
50
+ "owner": "markdown",
51
+ "description": "Number of lines in the SUMMARY.md",
52
+ "value": 9
53
+ },
54
+ {
55
+ "owner": "markdown",
56
+ "description": "Number of lines in the PROPERTIES.md",
57
+ "value": 642
58
+ },
59
+ {
60
+ "owner": "markdown",
61
+ "description": "Number of lines in the TROUBLESHOOT.md",
62
+ "value": 48
63
+ },
64
+ {
65
+ "owner": "markdown",
66
+ "description": "Number of lines in the ENHANCE.md",
67
+ "value": 70
68
+ },
69
+ {
70
+ "owner": "markdown",
71
+ "description": "Number of lines in the BROKER.md",
72
+ "value": 70
73
+ },
74
+ {
75
+ "owner": "unitTestJS",
76
+ "description": "Number of lines of code in unit tests",
77
+ "value": 2132
78
+ },
79
+ {
80
+ "owner": "unitTestJS",
81
+ "description": "Number of unit tests",
82
+ "value": 111
83
+ },
84
+ {
85
+ "owner": "integrationTestJS",
86
+ "description": "Number of lines of code in integration tests",
87
+ "value": 1003
88
+ },
89
+ {
90
+ "owner": "integrationTestJS",
91
+ "description": "Number of integration tests",
92
+ "value": 29
93
+ },
94
+ {
95
+ "owner": "staticFile",
96
+ "description": "Number of lines of code in adapterBase.js",
97
+ "value": 1783
98
+ },
99
+ {
100
+ "owner": "staticFile",
101
+ "description": "Number of static files added",
102
+ "value": 36
103
+ },
104
+ {
105
+ "owner": "Overall",
106
+ "description": "Total lines of Code",
107
+ "value": 4918
108
+ },
109
+ {
110
+ "owner": "Overall",
111
+ "description": "Total Tests",
112
+ "value": 140
113
+ },
114
+ {
115
+ "owner": "Overall",
116
+ "description": "Total Files",
117
+ "value": 6
118
+ }
119
+ ]
120
+ }
@@ -8,7 +8,8 @@
8
8
  "version": "",
9
9
  "cache_location": "none",
10
10
  "encode_pathvars": false,
11
- "save_metric": true,
11
+ "encode_queryvars": false,
12
+ "save_metric": false,
12
13
  "stub": true,
13
14
  "protocol": "https",
14
15
  "authentication": {
@@ -97,6 +98,94 @@
97
98
  "key_file": "",
98
99
  "cert_file": ""
99
100
  }
101
+ },
102
+ "devicebroker": {
103
+ "getDevice": [
104
+ {
105
+ "path": "/get/devices/{id}",
106
+ "method": "GET",
107
+ "query": {},
108
+ "body": {},
109
+ "headers": {},
110
+ "handleFailure": "ignore",
111
+ "requestFields": {
112
+ "id": "name"
113
+ },
114
+ "responseDatakey": "",
115
+ "responseFields": {
116
+ "name": "host",
117
+ "ostype": "os",
118
+ "ostypePrefix": "system-",
119
+ "ipaddress": "attributes.ipaddr",
120
+ "port": "443"
121
+ }
122
+ }
123
+ ],
124
+ "getDevicesFiltered": [
125
+ {
126
+ "path": "/get/devices",
127
+ "method": "GET",
128
+ "query": {},
129
+ "body": {},
130
+ "headers": {},
131
+ "handleFailure": "ignore",
132
+ "requestFields": {},
133
+ "responseDatakey": "",
134
+ "responseFields": {
135
+ "name": "host",
136
+ "ostype": "os",
137
+ "ostypePrefix": "system-",
138
+ "ipaddress": "attributes.ipaddr",
139
+ "port": "443"
140
+ }
141
+ }
142
+ ],
143
+ "isAlive": [
144
+ {
145
+ "path": "/get/devices/{id}/status",
146
+ "method": "GET",
147
+ "query": {},
148
+ "body": {},
149
+ "headers": {},
150
+ "handleFailure": "ignore",
151
+ "requestFields": {
152
+ "id": "name"
153
+ },
154
+ "responseDatakey": "",
155
+ "responseFields": {
156
+ "status": "status",
157
+ "statusValue": "online"
158
+ }
159
+ }
160
+ ],
161
+ "getConfig": [
162
+ {
163
+ "path": "/get/devices/{id}/configPart1",
164
+ "method": "GET",
165
+ "query": {},
166
+ "body": {},
167
+ "headers": {},
168
+ "handleFailure": "ignore",
169
+ "requestFields": {
170
+ "id": "name"
171
+ },
172
+ "responseDatakey": "",
173
+ "responseFields": {}
174
+ }
175
+ ],
176
+ "getCount": [
177
+ {
178
+ "path": "/get/devices",
179
+ "method": "GET",
180
+ "query": {},
181
+ "body": {},
182
+ "headers": {},
183
+ "handleFailure": "ignore",
184
+ "requestFields": {},
185
+ "responseDatakey": "",
186
+ "responseFields": {}
187
+ }
188
+ ]
100
189
  }
101
190
  },
102
191
  "groups": [],
@@ -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');
@@ -14,27 +16,38 @@ const { expect } = require('chai');
14
16
  const { use } = require('chai');
15
17
  const td = require('testdouble');
16
18
  const util = require('util');
17
- const pronghorn = require('../../pronghorn.json');
18
19
 
19
- pronghorn.methodsByName = pronghorn.methods.reduce((result, meth) => ({ ...result, [meth.name]: meth }), {});
20
20
  const anything = td.matchers.anything();
21
21
 
22
22
  // stub and attemptTimeout are used throughout the code so set them here
23
23
  let logLevel = 'none';
24
- const stub = true;
25
24
  const isRapidFail = false;
26
25
  const isSaveMockData = false;
27
- 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;
28
35
 
29
36
  // these variables can be changed to run in integrated mode so easier to set them here
30
37
  // always check these in with bogus data!!!
31
- const host = 'replace.hostorip.here';
32
- const username = 'username';
33
- const password = 'password';
34
- const protocol = 'http';
35
- const port = 80;
36
- const sslenable = false;
37
- 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;
38
51
 
39
52
  // these are the adapter properties. You generally should not need to alter
40
53
  // any of these after they are initially set up
@@ -46,102 +59,7 @@ global.pronghornProps = {
46
59
  adapters: [{
47
60
  id: 'Test-nokia_altiplano',
48
61
  type: 'NokiaAltiplano',
49
- properties: {
50
- host,
51
- port,
52
- base_path: '/rest',
53
- version: '',
54
- cache_location: 'none',
55
- encode_pathvars: true,
56
- save_metric: false,
57
- stub,
58
- protocol,
59
- authentication: {
60
- auth_method: 'request_token',
61
- username,
62
- password,
63
- token: '',
64
- invalid_token_error: 401,
65
- token_timeout: 1800000,
66
- token_cache: 'local',
67
- auth_field: 'header.headers.Authorization',
68
- auth_field_format: '{token}',
69
- auth_logging: false,
70
- client_id: '',
71
- client_secret: '',
72
- grant_type: ''
73
- },
74
- healthcheck: {
75
- type: 'none',
76
- frequency: 60000,
77
- query_object: {}
78
- },
79
- throttle: {
80
- throttle_enabled: false,
81
- number_pronghorns: 1,
82
- sync_async: 'sync',
83
- max_in_queue: 1000,
84
- concurrent_max: 1,
85
- expire_timeout: 0,
86
- avg_runtime: 200,
87
- priorities: [
88
- {
89
- value: 0,
90
- percent: 100
91
- }
92
- ]
93
- },
94
- request: {
95
- number_redirects: 0,
96
- number_retries: 3,
97
- limit_retry_error: [0],
98
- failover_codes: [],
99
- attempt_timeout: attemptTimeout,
100
- global_request: {
101
- payload: {},
102
- uriOptions: {},
103
- addlHeaders: {},
104
- authData: {}
105
- },
106
- healthcheck_on_timeout: true,
107
- return_raw: true,
108
- archiving: false,
109
- return_request: false
110
- },
111
- proxy: {
112
- enabled: false,
113
- host: '',
114
- port: 1,
115
- protocol: 'http',
116
- username: '',
117
- password: ''
118
- },
119
- ssl: {
120
- ecdhCurve: '',
121
- enabled: sslenable,
122
- accept_invalid_cert: sslinvalid,
123
- ca_file: '',
124
- key_file: '',
125
- cert_file: '',
126
- secure_protocol: '',
127
- ciphers: ''
128
- },
129
- mongo: {
130
- host: '',
131
- port: 0,
132
- database: '',
133
- username: '',
134
- password: '',
135
- replSet: '',
136
- db_ssl: {
137
- enabled: false,
138
- accept_invalid_cert: false,
139
- ca_file: '',
140
- key_file: '',
141
- cert_file: ''
142
- }
143
- }
144
- }
62
+ properties: samProps
145
63
  }]
146
64
  }
147
65
  };
@@ -931,6 +849,81 @@ describe('[integration] Nokia_altiplano Adapter Test', () => {
931
849
  }).timeout(attemptTimeout);
932
850
  });
933
851
 
852
+ describe('#getEntityOntView - errors', () => {
853
+ it('should work if integrated but since no mockdata should error when run standalone', (done) => {
854
+ try {
855
+ a.getEntityOntView('fakedata', 'fakedata', 'fakedata', null, null, (data, error) => {
856
+ try {
857
+ if (stub) {
858
+ const displayE = 'Error 400 received on request';
859
+ runErrorAsserts(data, error, 'AD.500', 'Test-nokia_altiplano-connectorRest-handleEndResponse', displayE);
860
+ } else {
861
+ runCommonAsserts(data, error);
862
+ }
863
+ saveMockData('Entity', 'getEntityOntView', 'default', data);
864
+ done();
865
+ } catch (err) {
866
+ log.error(`Test Failure: ${err}`);
867
+ done(err);
868
+ }
869
+ });
870
+ } catch (error) {
871
+ log.error(`Adapter Exception: ${error}`);
872
+ done(error);
873
+ }
874
+ }).timeout(attemptTimeout);
875
+ });
876
+
877
+ describe('#getEntityOntPort - errors', () => {
878
+ it('should work if integrated but since no mockdata should error when run standalone', (done) => {
879
+ try {
880
+ a.getEntityOntPort('fakedata', 'fakedata', 'fakedata', null, null, (data, error) => {
881
+ try {
882
+ if (stub) {
883
+ const displayE = 'Error 400 received on request';
884
+ runErrorAsserts(data, error, 'AD.500', 'Test-nokia_altiplano-connectorRest-handleEndResponse', displayE);
885
+ } else {
886
+ runCommonAsserts(data, error);
887
+ }
888
+ saveMockData('Entity', 'getEntityOntPort', 'default', data);
889
+ done();
890
+ } catch (err) {
891
+ log.error(`Test Failure: ${err}`);
892
+ done(err);
893
+ }
894
+ });
895
+ } catch (error) {
896
+ log.error(`Adapter Exception: ${error}`);
897
+ done(error);
898
+ }
899
+ }).timeout(attemptTimeout);
900
+ });
901
+
902
+ describe('#getEntityOntVlanAssociation - errors', () => {
903
+ it('should work if integrated but since no mockdata should error when run standalone', (done) => {
904
+ try {
905
+ a.getEntityOntVlanAssociation('fakedata', 'fakedata', 'fakedata', null, null, (data, error) => {
906
+ try {
907
+ if (stub) {
908
+ const displayE = 'Error 400 received on request';
909
+ runErrorAsserts(data, error, 'AD.500', 'Test-nokia_altiplano-connectorRest-handleEndResponse', displayE);
910
+ } else {
911
+ runCommonAsserts(data, error);
912
+ }
913
+ saveMockData('Entity', 'getEntityOntVlanAssociation', 'default', data);
914
+ done();
915
+ } catch (err) {
916
+ log.error(`Test Failure: ${err}`);
917
+ done(err);
918
+ }
919
+ });
920
+ } catch (error) {
921
+ log.error(`Adapter Exception: ${error}`);
922
+ done(error);
923
+ }
924
+ }).timeout(attemptTimeout);
925
+ });
926
+
934
927
  describe('#deletel2User - errors', () => {
935
928
  it('should work if integrated but since no mockdata should error when run standalone', (done) => {
936
929
  try {
@@ -984,7 +977,7 @@ describe('[integration] Nokia_altiplano Adapter Test', () => {
984
977
  describe('#deleteIbnIntent - errors', () => {
985
978
  it('should work if integrated but since no mockdata should error when run standalone', (done) => {
986
979
  try {
987
- a.deleteIbnIntent(intentIntent, (data, error) => {
980
+ a.deleteIbnIntent(intentIntent, 'fakedata', (data, error) => {
988
981
  try {
989
982
  if (stub) {
990
983
  const displayE = 'Error 400 received on request';