@itentialopensource/adapter-nokia_netact 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 (73) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +18 -0
  3. package/.jshintrc +3 -0
  4. package/AUTH.md +32 -0
  5. package/BROKER.md +211 -0
  6. package/CALLS.md +447 -0
  7. package/CODE_OF_CONDUCT.md +43 -0
  8. package/CONTRIBUTING.md +13 -0
  9. package/ENHANCE.md +69 -0
  10. package/LICENSE +201 -0
  11. package/PROPERTIES.md +646 -0
  12. package/README.md +343 -0
  13. package/SUMMARY.md +9 -0
  14. package/SYSTEMINFO.md +18 -0
  15. package/TAB1.md +11 -0
  16. package/TAB2.md +303 -0
  17. package/TROUBLESHOOT.md +47 -0
  18. package/adapter.js +4743 -0
  19. package/adapterBase.js +1452 -0
  20. package/changelogs/CHANGELOG.md +0 -0
  21. package/entities/.generic/action.json +214 -0
  22. package/entities/.generic/schema.json +28 -0
  23. package/entities/.system/action.json +50 -0
  24. package/entities/.system/mockdatafiles/getToken-default.json +3 -0
  25. package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
  26. package/entities/.system/schema.json +19 -0
  27. package/entities/.system/schemaTokenReq.json +53 -0
  28. package/entities/.system/schemaTokenResp.json +53 -0
  29. package/entities/OpenCmOperationsPortBinding/action.json +64 -0
  30. package/entities/OpenCmOperationsPortBinding/schema.json +21 -0
  31. package/entities/OpenCmPersistencyPortBinding/action.json +244 -0
  32. package/entities/OpenCmPersistencyPortBinding/schema.json +30 -0
  33. package/entities/Operations/action.json +169 -0
  34. package/entities/Operations/schema.json +26 -0
  35. package/entities/Persistency/action.json +348 -0
  36. package/entities/Persistency/schema.json +35 -0
  37. package/error.json +190 -0
  38. package/metadata.json +78 -0
  39. package/package.json +81 -0
  40. package/pronghorn.json +2889 -0
  41. package/propertiesDecorators.json +14 -0
  42. package/propertiesSchema.json +1574 -0
  43. package/report/Nokia-NetAct-REST-SOAP-OpenAPI3.v1.json +3014 -0
  44. package/report/adapter-openapi.json +3014 -0
  45. package/report/adapter-openapi.yaml +2396 -0
  46. package/report/adapterInfo.json +10 -0
  47. package/report/auto-adapter-openapi.json +1420 -0
  48. package/report/creationReport.json +455 -0
  49. package/sampleProperties.json +257 -0
  50. package/test/integration/adapterTestBasicGet.js +83 -0
  51. package/test/integration/adapterTestConnectivity.js +118 -0
  52. package/test/integration/adapterTestIntegration.js +1509 -0
  53. package/test/unit/adapterBaseTestUnit.js +1024 -0
  54. package/test/unit/adapterTestUnit.js +2477 -0
  55. package/utils/adapterInfo.js +206 -0
  56. package/utils/addAuth.js +94 -0
  57. package/utils/artifactize.js +146 -0
  58. package/utils/basicGet.js +50 -0
  59. package/utils/checkMigrate.js +63 -0
  60. package/utils/entitiesToDB.js +179 -0
  61. package/utils/findPath.js +74 -0
  62. package/utils/methodDocumentor.js +273 -0
  63. package/utils/modify.js +152 -0
  64. package/utils/packModificationScript.js +35 -0
  65. package/utils/patches2bundledDeps.js +90 -0
  66. package/utils/pre-commit.sh +32 -0
  67. package/utils/removeHooks.js +20 -0
  68. package/utils/setup.js +33 -0
  69. package/utils/taskMover.js +309 -0
  70. package/utils/tbScript.js +239 -0
  71. package/utils/tbUtils.js +489 -0
  72. package/utils/testRunner.js +298 -0
  73. package/utils/troubleshootingAdapter.js +193 -0
@@ -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 path = require('path');
11
+ const assert = require('assert');
12
+ const mocha = require('mocha');
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,118 @@
1
+ /* @copyright Itential, LLC 2020 */
2
+
3
+ /* global describe it context before after */
4
+ /* eslint no-unused-vars: warn */
5
+
6
+ const assert = require('assert');
7
+ const https = require('https');
8
+ const mocha = require('mocha');
9
+ const ping = require('ping');
10
+ const dnsLookup = require('dns-lookup-promise');
11
+
12
+ let host;
13
+ process.argv.forEach((val) => {
14
+ if (val.indexOf('--HOST') === 0) {
15
+ [, host] = val.split('=');
16
+ }
17
+ });
18
+
19
+ describe('[integration] Adapter Test', () => {
20
+ context(`Testing network connection on ${host}`, () => {
21
+ after((done) => {
22
+ done();
23
+ });
24
+
25
+ it('DNS resolve', (done) => {
26
+ dnsLookup(host)
27
+ .then((addresses) => {
28
+ try {
29
+ assert.ok(addresses.length > 0);
30
+ done();
31
+ } catch (error) {
32
+ done(error);
33
+ }
34
+ })
35
+ .catch((err) => {
36
+ done(err);
37
+ });
38
+ });
39
+
40
+ it('Responds to ping', (done) => {
41
+ ping.promise.probe(host)
42
+ .then((result) => {
43
+ try {
44
+ assert.ok(result.alive);
45
+ done();
46
+ } catch (error) {
47
+ done(error);
48
+ }
49
+ })
50
+ .catch((err) => {
51
+ done(err);
52
+ });
53
+ });
54
+
55
+ it('Support HTTPS on port 443', (done) => {
56
+ const requestOptions = {
57
+ host,
58
+ port: 443,
59
+ method: 'HEAD'
60
+ };
61
+
62
+ const req = https.request(requestOptions, (res) => {
63
+ try {
64
+ assert.ok(res.statusCode >= 200 && res.statusCode < 400);
65
+ done();
66
+ } catch (error) {
67
+ done(error);
68
+ }
69
+ });
70
+
71
+ req.on('error', (err) => {
72
+ done(err);
73
+ });
74
+
75
+ req.end();
76
+ });
77
+
78
+ it('Support IPv4', (done) => {
79
+ const options = {
80
+ family: 4,
81
+ hints: dnsLookup.ADDRCONFIG
82
+ };
83
+
84
+ dnsLookup.lookup(host, options)
85
+ .then((address, family) => {
86
+ try {
87
+ assert.ok(address !== null && family === 4);
88
+ done();
89
+ } catch (error) {
90
+ done(error);
91
+ }
92
+ })
93
+ .catch((err) => {
94
+ done(err);
95
+ });
96
+ });
97
+
98
+ it('Support IPv6', (done) => {
99
+ const options = {
100
+ family: 6,
101
+ hints: dnsLookup.ADDRCONFIG
102
+ };
103
+
104
+ dnsLookup.lookup(host, options)
105
+ .then((address, family) => {
106
+ try {
107
+ assert.ok(address !== null && family === 6);
108
+ done();
109
+ } catch (error) {
110
+ done(error);
111
+ }
112
+ })
113
+ .catch((err) => {
114
+ done(err);
115
+ });
116
+ });
117
+ });
118
+ });