@itentialopensource/adapter-metaswitch 0.1.1

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 (71) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +18 -0
  3. package/.jshintrc +3 -0
  4. package/AUTH.md +39 -0
  5. package/BROKER.md +199 -0
  6. package/CALLS.md +170 -0
  7. package/CHANGELOG.md +9 -0
  8. package/CODE_OF_CONDUCT.md +43 -0
  9. package/CONTRIBUTING.md +172 -0
  10. package/ENHANCE.md +69 -0
  11. package/LICENSE +201 -0
  12. package/PROPERTIES.md +641 -0
  13. package/README.md +337 -0
  14. package/SUMMARY.md +9 -0
  15. package/SYSTEMINFO.md +11 -0
  16. package/TROUBLESHOOT.md +47 -0
  17. package/adapter.js +1173 -0
  18. package/adapterBase.js +1787 -0
  19. package/entities/.generic/action.json +214 -0
  20. package/entities/.generic/schema.json +28 -0
  21. package/entities/.system/action.json +50 -0
  22. package/entities/.system/mockdatafiles/getToken-default.json +3 -0
  23. package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
  24. package/entities/.system/schema.json +19 -0
  25. package/entities/.system/schemaTokenReq.json +53 -0
  26. package/entities/.system/schemaTokenResp.json +53 -0
  27. package/entities/EAS/action.json +24 -0
  28. package/entities/EAS/mockdatafiles/postMetaSphereEAS-default.json +39 -0
  29. package/entities/EAS/schema.json +19 -0
  30. package/entities/Metaview/action.json +24 -0
  31. package/entities/Metaview/mockdatafiles/postMetaview-default.json +174 -0
  32. package/entities/Metaview/schema.json +19 -0
  33. package/entities/NSeries/action.json +24 -0
  34. package/entities/NSeries/mockdatafiles/postNSeries-default.json +54 -0
  35. package/entities/NSeries/schema.json +19 -0
  36. package/entities/NWSAP/action.json +24 -0
  37. package/entities/NWSAP/mockdatafiles/postNWSAP-default.json +193 -0
  38. package/entities/NWSAP/schema.json +19 -0
  39. package/error.json +190 -0
  40. package/package.json +85 -0
  41. package/pronghorn.json +1818 -0
  42. package/propertiesDecorators.json +14 -0
  43. package/propertiesSchema.json +1248 -0
  44. package/refs?service=git-upload-pack +0 -0
  45. package/report/Metaswitch.json +1615 -0
  46. package/report/creationReport.json +254 -0
  47. package/sampleProperties.json +197 -0
  48. package/test/integration/adapterTestBasicGet.js +83 -0
  49. package/test/integration/adapterTestConnectivity.js +93 -0
  50. package/test/integration/adapterTestIntegration.js +451 -0
  51. package/test/unit/adapterBaseTestUnit.js +949 -0
  52. package/test/unit/adapterTestUnit.js +1427 -0
  53. package/utils/adapterInfo.js +206 -0
  54. package/utils/addAuth.js +94 -0
  55. package/utils/artifactize.js +146 -0
  56. package/utils/basicGet.js +50 -0
  57. package/utils/checkMigrate.js +63 -0
  58. package/utils/entitiesToDB.js +178 -0
  59. package/utils/findPath.js +74 -0
  60. package/utils/methodDocumentor.js +225 -0
  61. package/utils/modify.js +154 -0
  62. package/utils/packModificationScript.js +35 -0
  63. package/utils/patches2bundledDeps.js +90 -0
  64. package/utils/pre-commit.sh +32 -0
  65. package/utils/removeHooks.js +20 -0
  66. package/utils/setup.js +33 -0
  67. package/utils/tbScript.js +246 -0
  68. package/utils/tbUtils.js +490 -0
  69. package/utils/testRunner.js +298 -0
  70. package/utils/troubleshootingAdapter.js +195 -0
  71. package/workflows/README.md +3 -0
@@ -0,0 +1,254 @@
1
+ {
2
+ "errors": [],
3
+ "statistics": [
4
+ {
5
+ "owner": "errorJson",
6
+ "description": "Standard adapter errors available for use",
7
+ "value": 31
8
+ },
9
+ {
10
+ "owner": "packageJson",
11
+ "description": "Number of production dependencies",
12
+ "value": 16
13
+ },
14
+ {
15
+ "owner": "packageJson",
16
+ "description": "Number of development dependencies",
17
+ "value": 7
18
+ },
19
+ {
20
+ "owner": "packageJson",
21
+ "description": "Number of npm scripts",
22
+ "value": 22
23
+ },
24
+ {
25
+ "owner": "packageJson",
26
+ "description": "Runtime Library dependency",
27
+ "value": "^4.48.0"
28
+ },
29
+ {
30
+ "owner": "propertiesSchemaJson",
31
+ "description": "Adapter properties defined in the propertiesSchema file",
32
+ "value": 70
33
+ },
34
+ {
35
+ "owner": "adapterJS",
36
+ "description": "Lines of code generated in adapter.js",
37
+ "value": 1174
38
+ },
39
+ {
40
+ "owner": "adapterJS",
41
+ "description": "Number of Functions added to adapter.js",
42
+ "value": 4
43
+ },
44
+ {
45
+ "owner": "pronghornJson",
46
+ "description": "Number of Methods added to pronghorn.json",
47
+ "value": 4
48
+ },
49
+ {
50
+ "owner": "markdown",
51
+ "description": "Number of lines in the README.md",
52
+ "value": 338
53
+ },
54
+ {
55
+ "owner": "markdown",
56
+ "description": "Number of lines in the SUMMARY.md",
57
+ "value": 9
58
+ },
59
+ {
60
+ "owner": "markdown",
61
+ "description": "Number of lines in the PROPERTIES.md",
62
+ "value": 642
63
+ },
64
+ {
65
+ "owner": "markdown",
66
+ "description": "Number of lines in the TROUBLESHOOT.md",
67
+ "value": 48
68
+ },
69
+ {
70
+ "owner": "markdown",
71
+ "description": "Number of lines in the ENHANCE.md",
72
+ "value": 70
73
+ },
74
+ {
75
+ "owner": "markdown",
76
+ "description": "Number of lines in the BROKER.md",
77
+ "value": 200
78
+ },
79
+ {
80
+ "owner": "markdown",
81
+ "description": "Number of lines in the CALLS.md",
82
+ "value": 171
83
+ },
84
+ {
85
+ "owner": "markdown",
86
+ "description": "Number of lines in the AUTH.md",
87
+ "value": 40
88
+ },
89
+ {
90
+ "owner": "markdown",
91
+ "description": "Number of lines in the SYSTEMINFO.md",
92
+ "value": 11
93
+ },
94
+ {
95
+ "owner": "unitTestJS",
96
+ "description": "Number of lines of code in unit tests",
97
+ "value": 1428
98
+ },
99
+ {
100
+ "owner": "unitTestJS",
101
+ "description": "Number of unit tests",
102
+ "value": 63
103
+ },
104
+ {
105
+ "owner": "integrationTestJS",
106
+ "description": "Number of lines of code in integration tests",
107
+ "value": 452
108
+ },
109
+ {
110
+ "owner": "integrationTestJS",
111
+ "description": "Number of integration tests",
112
+ "value": 9
113
+ },
114
+ {
115
+ "owner": "actionJson",
116
+ "description": "Number of actions for EAS entity",
117
+ "value": 1
118
+ },
119
+ {
120
+ "owner": "actionJson",
121
+ "description": "Number of actions for NSeries entity",
122
+ "value": 1
123
+ },
124
+ {
125
+ "owner": "actionJson",
126
+ "description": "Number of actions for Metaview entity",
127
+ "value": 1
128
+ },
129
+ {
130
+ "owner": "actionJson",
131
+ "description": "Number of actions for NWSAP entity",
132
+ "value": 1
133
+ },
134
+ {
135
+ "owner": "actionJson",
136
+ "description": "Total number of actions",
137
+ "value": 4
138
+ },
139
+ {
140
+ "owner": "actionJson",
141
+ "description": "Total number of entities",
142
+ "value": 4
143
+ },
144
+ {
145
+ "owner": "schemaJson",
146
+ "description": "Number of schemas for EAS entity",
147
+ "value": 1
148
+ },
149
+ {
150
+ "owner": "schemaJson",
151
+ "description": "Number of schemas for NSeries entity",
152
+ "value": 1
153
+ },
154
+ {
155
+ "owner": "schemaJson",
156
+ "description": "Number of schemas for Metaview entity",
157
+ "value": 1
158
+ },
159
+ {
160
+ "owner": "schemaJson",
161
+ "description": "Number of schemas for NWSAP entity",
162
+ "value": 1
163
+ },
164
+ {
165
+ "owner": "schemaJson",
166
+ "description": "Total number of schemas",
167
+ "value": 4
168
+ },
169
+ {
170
+ "owner": "mockdata",
171
+ "description": "Number of mock data files for EAS entity",
172
+ "value": 1
173
+ },
174
+ {
175
+ "owner": "mockdata",
176
+ "description": "Number of mock data files for NSeries entity",
177
+ "value": 1
178
+ },
179
+ {
180
+ "owner": "mockdata",
181
+ "description": "Number of mock data files for Metaview entity",
182
+ "value": 1
183
+ },
184
+ {
185
+ "owner": "mockdata",
186
+ "description": "Number of mock data files for NWSAP entity",
187
+ "value": 1
188
+ },
189
+ {
190
+ "owner": "mockdata",
191
+ "description": "Total number of mock data files",
192
+ "value": 4
193
+ },
194
+ {
195
+ "owner": "actionJson",
196
+ "description": "Number of actions for .system entity",
197
+ "value": 2
198
+ },
199
+ {
200
+ "owner": "schemaJson",
201
+ "description": "Number of schemas for .system entity",
202
+ "value": 3
203
+ },
204
+ {
205
+ "owner": "mockdata",
206
+ "description": "Number of mock data files for .system entity",
207
+ "value": 2
208
+ },
209
+ {
210
+ "owner": "System",
211
+ "description": "System entity files",
212
+ "value": 6
213
+ },
214
+ {
215
+ "owner": "usecases",
216
+ "description": "Number of workflows",
217
+ "value": 0
218
+ },
219
+ {
220
+ "owner": "staticFile",
221
+ "description": "Number of lines of code in adapterBase.js",
222
+ "value": 1788
223
+ },
224
+ {
225
+ "owner": "staticFile",
226
+ "description": "Number of static files added",
227
+ "value": 38
228
+ },
229
+ {
230
+ "owner": "Overall",
231
+ "description": "Total lines of Code",
232
+ "value": 4842
233
+ },
234
+ {
235
+ "owner": "Overall",
236
+ "description": "Total Tests",
237
+ "value": 72
238
+ },
239
+ {
240
+ "owner": "Overall",
241
+ "description": "Total Files",
242
+ "value": 64
243
+ }
244
+ ],
245
+ "warnings": [],
246
+ "apiParsingReport": {
247
+ "no_mockdata": [],
248
+ "errors": [],
249
+ "warnings": [],
250
+ "callsTotal": 4,
251
+ "callsConverted": 4,
252
+ "no_mockdata_num": 0
253
+ }
254
+ }
@@ -0,0 +1,197 @@
1
+ {
2
+ "id": "Adapter-metaswitch",
3
+ "type": "Metaswitch",
4
+ "properties": {
5
+ "host": "localhost",
6
+ "port": 80,
7
+ "base_path": "/",
8
+ "version": "",
9
+ "cache_location": "none",
10
+ "encode_pathvars": true,
11
+ "encode_queryvars": true,
12
+ "save_metric": false,
13
+ "stub": true,
14
+ "protocol": "http",
15
+ "authentication": {
16
+ "auth_method": "basic user_password",
17
+ "username": "username",
18
+ "password": "password",
19
+ "token": "token",
20
+ "token_timeout": 600000,
21
+ "token_cache": "local",
22
+ "invalid_token_error": 401,
23
+ "auth_field": "header.headers.Authorization",
24
+ "auth_field_format": "Basic {b64}{username}:{password}{/b64}",
25
+ "auth_logging": false,
26
+ "client_id": "",
27
+ "client_secret": "",
28
+ "grant_type": ""
29
+ },
30
+ "healthcheck": {
31
+ "type": "none",
32
+ "frequency": 60000,
33
+ "query_object": {}
34
+ },
35
+ "throttle": {
36
+ "throttle_enabled": false,
37
+ "number_pronghorns": 1,
38
+ "sync_async": "sync",
39
+ "max_in_queue": 1000,
40
+ "concurrent_max": 1,
41
+ "expire_timeout": 0,
42
+ "avg_runtime": 200,
43
+ "priorities": [
44
+ {
45
+ "value": 0,
46
+ "percent": 100
47
+ }
48
+ ]
49
+ },
50
+ "request": {
51
+ "number_redirects": 0,
52
+ "number_retries": 3,
53
+ "limit_retry_error": [
54
+ 0
55
+ ],
56
+ "failover_codes": [],
57
+ "attempt_timeout": 5000,
58
+ "global_request": {
59
+ "payload": {},
60
+ "uriOptions": {},
61
+ "addlHeaders": {
62
+ "Content-Type": "text/xml;charset=UTF-8"
63
+ },
64
+ "authData": {}
65
+ },
66
+ "healthcheck_on_timeout": true,
67
+ "return_raw": false,
68
+ "archiving": false,
69
+ "return_request": false
70
+ },
71
+ "proxy": {
72
+ "enabled": false,
73
+ "host": "",
74
+ "port": 1,
75
+ "protocol": "http",
76
+ "username": "",
77
+ "password": ""
78
+ },
79
+ "ssl": {
80
+ "ecdhCurve": "",
81
+ "enabled": false,
82
+ "accept_invalid_cert": false,
83
+ "ca_file": "",
84
+ "key_file": "",
85
+ "cert_file": "",
86
+ "secure_protocol": "",
87
+ "ciphers": ""
88
+ },
89
+ "mongo": {
90
+ "host": "",
91
+ "port": 0,
92
+ "database": "",
93
+ "username": "",
94
+ "password": "",
95
+ "replSet": "",
96
+ "db_ssl": {
97
+ "enabled": false,
98
+ "accept_invalid_cert": false,
99
+ "ca_file": "",
100
+ "key_file": "",
101
+ "cert_file": ""
102
+ }
103
+ },
104
+ "devicebroker": {
105
+ "getDevice": [
106
+ {
107
+ "path": "/get/devices/{id}",
108
+ "method": "GET",
109
+ "query": {},
110
+ "body": {},
111
+ "headers": {},
112
+ "handleFailure": "ignore",
113
+ "requestFields": {
114
+ "id": "name"
115
+ },
116
+ "responseDatakey": "",
117
+ "responseFields": {
118
+ "name": "host",
119
+ "ostype": "os",
120
+ "ostypePrefix": "system-",
121
+ "ipaddress": "attributes.ipaddr",
122
+ "port": "443"
123
+ }
124
+ }
125
+ ],
126
+ "getDevicesFiltered": [
127
+ {
128
+ "path": "/get/devices",
129
+ "method": "GET",
130
+ "query": {},
131
+ "body": {},
132
+ "headers": {},
133
+ "handleFailure": "ignore",
134
+ "requestFields": {},
135
+ "responseDatakey": "",
136
+ "responseFields": {
137
+ "name": "host",
138
+ "ostype": "os",
139
+ "ostypePrefix": "system-",
140
+ "ipaddress": "attributes.ipaddr",
141
+ "port": "443"
142
+ }
143
+ }
144
+ ],
145
+ "isAlive": [
146
+ {
147
+ "path": "/get/devices/{id}/status",
148
+ "method": "GET",
149
+ "query": {},
150
+ "body": {},
151
+ "headers": {},
152
+ "handleFailure": "ignore",
153
+ "requestFields": {
154
+ "id": "name"
155
+ },
156
+ "responseDatakey": "",
157
+ "responseFields": {
158
+ "status": "status",
159
+ "statusValue": "online"
160
+ }
161
+ }
162
+ ],
163
+ "getConfig": [
164
+ {
165
+ "path": "/get/devices/{id}/configPart1",
166
+ "method": "GET",
167
+ "query": {},
168
+ "body": {},
169
+ "headers": {},
170
+ "handleFailure": "ignore",
171
+ "requestFields": {
172
+ "id": "name"
173
+ },
174
+ "responseDatakey": "",
175
+ "responseFields": {}
176
+ }
177
+ ],
178
+ "getCount": [
179
+ {
180
+ "path": "/get/devices",
181
+ "method": "GET",
182
+ "query": {},
183
+ "body": {},
184
+ "headers": {},
185
+ "handleFailure": "ignore",
186
+ "requestFields": {},
187
+ "responseDatakey": "",
188
+ "responseFields": {}
189
+ }
190
+ ]
191
+ }
192
+ },
193
+ "groups": [],
194
+ "brokers": [],
195
+ "logLevel": "none",
196
+ "timeout": 120000
197
+ }
@@ -0,0 +1,83 @@
1
+ /* @copyright Itential, LLC 2020 */
2
+
3
+ /* global describe context before after */
4
+ /* eslint global-require: warn */
5
+ /* eslint no-unused-vars: warn */
6
+ /* eslint import/no-extraneous-dependencies: warn */
7
+ /* eslint import/no-dynamic-require: warn */
8
+ /* eslint import/no-unresolved: warn */
9
+
10
+ const mocha = require('mocha');
11
+ const path = require('path');
12
+ const assert = require('assert');
13
+ const itParam = require('mocha-param');
14
+
15
+ const utils = require('../../utils/tbUtils');
16
+ const basicGet = require('../../utils/basicGet');
17
+ const { name } = require('../../package.json');
18
+ const { methods } = require('../../pronghorn.json');
19
+
20
+ const getPronghornProps = (iapDir) => {
21
+ console.log('Retrieving properties.json file...');
22
+ const rawProps = require(path.join(iapDir, 'properties.json'));
23
+ console.log('Decrypting properties...');
24
+ const pronghornProps = utils.decryptProperties(rawProps, iapDir);
25
+ console.log('Found properties.\n');
26
+ return pronghornProps;
27
+ };
28
+
29
+ let a;
30
+
31
+ describe('[integration] Adapter BasicGET Test', () => {
32
+ context('Testing GET calls without query parameters', () => {
33
+ before(async () => {
34
+ const iapDir = path.join(__dirname, '../../../../../');
35
+ if (!utils.areWeUnderIAPinstallationDirectory()) {
36
+ const sampleProperties = require('../../sampleProperties.json');
37
+ const adapter = { properties: sampleProperties };
38
+ a = basicGet.getAdapterInstance(adapter);
39
+ } else {
40
+ const pronghornProps = getPronghornProps(iapDir);
41
+ console.log('Connecting to Database...');
42
+ const database = await basicGet.connect(pronghornProps);
43
+ console.log('Connection established.');
44
+ const adapter = await database.collection(utils.SERVICE_CONFIGS_COLLECTION).findOne(
45
+ { model: name }
46
+ );
47
+ a = basicGet.getAdapterInstance(adapter);
48
+ }
49
+ });
50
+
51
+ after((done) => {
52
+ done();
53
+ });
54
+
55
+ const basicGets = methods.filter((method) => (method.route.verb === 'GET' && method.input.length === 0));
56
+ if (basicGets.length === 0) {
57
+ console.log('No non-parameter GET calls found.');
58
+ process.exit(0);
59
+ }
60
+ const functionNames = basicGets.map((g) => g.name);
61
+ const request = function request(f, ad) {
62
+ return new Promise((resolve, reject) => {
63
+ const getRespCode = (resp) => {
64
+ if (resp) {
65
+ if (resp.metrics.code !== 200) {
66
+ console.log('\x1b[31m', `Testing ${f} \nResponseCode: ${resp.metrics.code}`);
67
+ }
68
+ resolve(resp.metrics.code);
69
+ } else {
70
+ console.log('\x1b[31m', `call ${f} results in failure`);
71
+ reject(new Error(`${f} failed`));
72
+ }
73
+ };
74
+ ad[f](getRespCode, console.log);
75
+ });
76
+ };
77
+
78
+ itParam('GET call should return 200', functionNames, (fname) => {
79
+ console.log(`\t ${fname}`);
80
+ return request(fname, a).then((result) => assert.equal(result, 200));
81
+ });
82
+ });
83
+ });
@@ -0,0 +1,93 @@
1
+ /* @copyright Itential, LLC 2020 */
2
+
3
+ /* global describe it context before after */
4
+ /* eslint no-unused-vars: warn */
5
+
6
+ const mocha = require('mocha');
7
+ const assert = require('assert');
8
+ const diagnostics = require('network-diagnostics');
9
+
10
+ let host;
11
+ process.argv.forEach((val) => {
12
+ if (val.indexOf('--HOST') === 0) {
13
+ [, host] = val.split('=');
14
+ }
15
+ });
16
+
17
+ describe('[integration] Adapter Test', () => {
18
+ context(`Testing network connection on ${host}`, () => {
19
+ before(() => {
20
+ diagnostics.setTestURL(host);
21
+ });
22
+
23
+ after((done) => {
24
+ done();
25
+ });
26
+
27
+ it('DNS resolve', (done) => {
28
+ diagnostics.haveDNS((result) => {
29
+ try {
30
+ assert.equal(result, true);
31
+ done();
32
+ } catch (error) {
33
+ done(error);
34
+ }
35
+ });
36
+ });
37
+
38
+ it('Responds to ping', (done) => {
39
+ diagnostics.havePing((result) => {
40
+ try {
41
+ assert.equal(result, true);
42
+ done();
43
+ } catch (error) {
44
+ done(error);
45
+ }
46
+ });
47
+ });
48
+
49
+ it('Support HTTP on port 80', (done) => {
50
+ diagnostics.haveHTTP((result) => {
51
+ try {
52
+ assert.equal(result, true);
53
+ done();
54
+ } catch (error) {
55
+ done(error);
56
+ }
57
+ });
58
+ });
59
+
60
+ it('Support HTTPS on port 443', (done) => {
61
+ diagnostics.haveHTTPS((result) => {
62
+ try {
63
+ assert.equal(result, true);
64
+ done();
65
+ } catch (error) {
66
+ done(error);
67
+ }
68
+ });
69
+ });
70
+
71
+ it('Support IPv4', (done) => {
72
+ diagnostics.haveIPv4Async((result) => {
73
+ try {
74
+ assert.equal(result, true);
75
+ done();
76
+ } catch (error) {
77
+ done(error);
78
+ }
79
+ });
80
+ });
81
+
82
+ it('Support IPv6', (done) => {
83
+ diagnostics.haveIPv6Async((result) => {
84
+ try {
85
+ assert.equal(result, true);
86
+ done();
87
+ } catch (error) {
88
+ done(error);
89
+ }
90
+ });
91
+ });
92
+ });
93
+ });