@itentialopensource/adapter-netbrain 1.1.1 → 1.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.
- package/CALLS.md +18 -0
- package/CHANGELOG.md +8 -0
- package/CONTRIBUTING.md +1 -160
- package/ENHANCE.md +2 -2
- package/README.md +32 -23
- package/adapter.js +157 -329
- package/adapterBase.js +549 -879
- package/changelogs/changelog.md +151 -0
- package/metadata.json +47 -0
- package/package.json +24 -27
- package/pronghorn.json +981 -642
- package/propertiesSchema.json +431 -31
- package/refs?service=git-upload-pack +0 -0
- package/report/adapter-openapi.json +8023 -0
- package/report/adapter-openapi.yaml +5944 -0
- package/report/adapterInfo.json +8 -8
- package/report/updateReport1691507690977.json +120 -0
- package/report/updateReport1692202690574.json +120 -0
- package/report/updateReport1694462665367.json +120 -0
- package/report/updateReport1698421227451.json +120 -0
- package/sampleProperties.json +63 -2
- package/test/integration/adapterTestBasicGet.js +2 -4
- package/test/integration/adapterTestConnectivity.js +91 -42
- package/test/integration/adapterTestIntegration.js +130 -2
- package/test/unit/adapterBaseTestUnit.js +388 -313
- package/test/unit/adapterTestUnit.js +338 -130
- package/utils/adapterInfo.js +1 -1
- package/utils/addAuth.js +1 -1
- package/utils/artifactize.js +1 -1
- package/utils/checkMigrate.js +1 -1
- package/utils/entitiesToDB.js +2 -2
- package/utils/findPath.js +1 -1
- package/utils/methodDocumentor.js +273 -0
- package/utils/modify.js +13 -15
- package/utils/packModificationScript.js +1 -1
- package/utils/pre-commit.sh +2 -0
- package/utils/taskMover.js +309 -0
- package/utils/tbScript.js +89 -34
- package/utils/tbUtils.js +41 -21
- package/utils/testRunner.js +1 -1
- package/utils/troubleshootingAdapter.js +9 -6
- package/workflows/README.md +0 -3
|
@@ -8,16 +8,18 @@
|
|
|
8
8
|
|
|
9
9
|
// include required items for testing & logging
|
|
10
10
|
const assert = require('assert');
|
|
11
|
-
const fs = require('fs-extra');
|
|
12
|
-
const mocha = require('mocha');
|
|
13
11
|
const path = require('path');
|
|
14
12
|
const util = require('util');
|
|
15
|
-
const winston = require('winston');
|
|
16
13
|
const execute = require('child_process').execSync;
|
|
14
|
+
const fs = require('fs-extra');
|
|
15
|
+
const mocha = require('mocha');
|
|
16
|
+
const winston = require('winston');
|
|
17
17
|
const { expect } = require('chai');
|
|
18
18
|
const { use } = require('chai');
|
|
19
19
|
const td = require('testdouble');
|
|
20
|
+
const Ajv = require('ajv');
|
|
20
21
|
|
|
22
|
+
const ajv = new Ajv({ strictSchema: false, allErrors: true, allowUnionTypes: true });
|
|
21
23
|
const anything = td.matchers.anything();
|
|
22
24
|
let logLevel = 'none';
|
|
23
25
|
const isRapidFail = false;
|
|
@@ -41,10 +43,9 @@ samProps.protocol = 'http';
|
|
|
41
43
|
samProps.port = 80;
|
|
42
44
|
samProps.ssl.enabled = false;
|
|
43
45
|
samProps.ssl.accept_invalid_cert = false;
|
|
44
|
-
samProps.request.attempt_timeout =
|
|
46
|
+
samProps.request.attempt_timeout = 1200000;
|
|
45
47
|
const attemptTimeout = samProps.request.attempt_timeout;
|
|
46
48
|
const { stub } = samProps;
|
|
47
|
-
samProps.authentication.tenantId = '';
|
|
48
49
|
|
|
49
50
|
// these are the adapter properties. You generally should not need to alter
|
|
50
51
|
// any of these after they are initially set up
|
|
@@ -221,19 +222,24 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
221
222
|
it('package.json should be validated', (done) => {
|
|
222
223
|
try {
|
|
223
224
|
const packageDotJson = require('../../package.json');
|
|
224
|
-
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
// Define the JSON schema for package.json
|
|
226
|
+
const packageJsonSchema = {
|
|
227
|
+
type: 'object',
|
|
228
|
+
properties: {
|
|
229
|
+
name: { type: 'string' },
|
|
230
|
+
version: { type: 'string' }
|
|
231
|
+
// May need to add more properties as needed
|
|
232
|
+
},
|
|
233
|
+
required: ['name', 'version']
|
|
228
234
|
};
|
|
229
|
-
const
|
|
235
|
+
const validate = ajv.compile(packageJsonSchema);
|
|
236
|
+
const isValid = validate(packageDotJson);
|
|
230
237
|
|
|
231
|
-
if (
|
|
232
|
-
log.error('The package.json contains
|
|
233
|
-
|
|
234
|
-
assert.equal(true, results.valid);
|
|
238
|
+
if (isValid === false) {
|
|
239
|
+
log.error('The package.json contains errors');
|
|
240
|
+
assert.equal(true, isValid);
|
|
235
241
|
} else {
|
|
236
|
-
assert.equal(true,
|
|
242
|
+
assert.equal(true, isValid);
|
|
237
243
|
}
|
|
238
244
|
|
|
239
245
|
done();
|
|
@@ -272,7 +278,7 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
272
278
|
assert.notEqual(undefined, packageDotJson.scripts);
|
|
273
279
|
assert.notEqual(null, packageDotJson.scripts);
|
|
274
280
|
assert.notEqual('', packageDotJson.scripts);
|
|
275
|
-
assert.equal('node utils/setup.js
|
|
281
|
+
assert.equal('node utils/setup.js', packageDotJson.scripts.preinstall);
|
|
276
282
|
assert.equal('node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js', packageDotJson.scripts.lint);
|
|
277
283
|
assert.equal('node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js --quiet', packageDotJson.scripts['lint:errors']);
|
|
278
284
|
assert.equal('mocha test/unit/adapterBaseTestUnit.js --LOG=error', packageDotJson.scripts['test:baseunit']);
|
|
@@ -309,17 +315,17 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
309
315
|
assert.notEqual(undefined, packageDotJson.dependencies);
|
|
310
316
|
assert.notEqual(null, packageDotJson.dependencies);
|
|
311
317
|
assert.notEqual('', packageDotJson.dependencies);
|
|
312
|
-
assert.equal('^
|
|
313
|
-
assert.equal('^
|
|
314
|
-
assert.equal('^
|
|
315
|
-
assert.equal('^
|
|
316
|
-
assert.equal('^
|
|
318
|
+
assert.equal('^8.12.0', packageDotJson.dependencies.ajv);
|
|
319
|
+
assert.equal('^1.6.3', packageDotJson.dependencies.axios);
|
|
320
|
+
assert.equal('^11.0.0', packageDotJson.dependencies.commander);
|
|
321
|
+
assert.equal('^11.1.1', packageDotJson.dependencies['fs-extra']);
|
|
322
|
+
assert.equal('^10.2.0', packageDotJson.dependencies.mocha);
|
|
317
323
|
assert.equal('^2.0.1', packageDotJson.dependencies['mocha-param']);
|
|
318
|
-
assert.equal('^0.5.3', packageDotJson.dependencies['network-diagnostics']);
|
|
319
324
|
assert.equal('^15.1.0', packageDotJson.dependencies.nyc);
|
|
325
|
+
assert.equal('^0.4.4', packageDotJson.dependencies.ping);
|
|
320
326
|
assert.equal('^1.4.10', packageDotJson.dependencies['readline-sync']);
|
|
321
|
-
assert.equal('^7.3
|
|
322
|
-
assert.equal('^3.
|
|
327
|
+
assert.equal('^7.5.3', packageDotJson.dependencies.semver);
|
|
328
|
+
assert.equal('^3.9.0', packageDotJson.dependencies.winston);
|
|
323
329
|
done();
|
|
324
330
|
} catch (error) {
|
|
325
331
|
log.error(`Test Failure: ${error}`);
|
|
@@ -332,13 +338,12 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
332
338
|
assert.notEqual(undefined, packageDotJson.devDependencies);
|
|
333
339
|
assert.notEqual(null, packageDotJson.devDependencies);
|
|
334
340
|
assert.notEqual('', packageDotJson.devDependencies);
|
|
335
|
-
assert.equal('^4.3.
|
|
336
|
-
assert.equal('^
|
|
337
|
-
assert.equal('^
|
|
338
|
-
assert.equal('^2.
|
|
339
|
-
assert.equal('^3.
|
|
340
|
-
assert.equal('^
|
|
341
|
-
assert.equal('^3.16.1', packageDotJson.devDependencies.testdouble);
|
|
341
|
+
assert.equal('^4.3.7', packageDotJson.devDependencies.chai);
|
|
342
|
+
assert.equal('^8.44.0', packageDotJson.devDependencies.eslint);
|
|
343
|
+
assert.equal('^15.0.0', packageDotJson.devDependencies['eslint-config-airbnb-base']);
|
|
344
|
+
assert.equal('^2.27.5', packageDotJson.devDependencies['eslint-plugin-import']);
|
|
345
|
+
assert.equal('^3.1.0', packageDotJson.devDependencies['eslint-plugin-json']);
|
|
346
|
+
assert.equal('^3.18.0', packageDotJson.devDependencies.testdouble);
|
|
342
347
|
done();
|
|
343
348
|
} catch (error) {
|
|
344
349
|
log.error(`Test Failure: ${error}`);
|
|
@@ -382,16 +387,30 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
382
387
|
assert.equal(true, Array.isArray(pronghornDotJson.methods));
|
|
383
388
|
assert.notEqual(0, pronghornDotJson.methods.length);
|
|
384
389
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapUpdateAdapterConfiguration'));
|
|
390
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapSuspendAdapter'));
|
|
391
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapUnsuspendAdapter'));
|
|
392
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapGetAdapterQueue'));
|
|
385
393
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapFindAdapterPath'));
|
|
386
394
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapTroubleshootAdapter'));
|
|
387
395
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterHealthcheck'));
|
|
388
396
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterConnectivity'));
|
|
389
397
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterBasicGet'));
|
|
390
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
|
391
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
|
392
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
|
398
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapMoveAdapterEntitiesToDB'));
|
|
399
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapDeactivateTasks'));
|
|
400
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapActivateTasks'));
|
|
401
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapPopulateEntityCache'));
|
|
402
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRetrieveEntitiesCache'));
|
|
403
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'getDevice'));
|
|
404
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'getDevicesFiltered'));
|
|
405
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'isAlive'));
|
|
406
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'getConfig'));
|
|
407
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapGetDeviceCount'));
|
|
408
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapExpandedGenericAdapterRequest'));
|
|
393
409
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'genericAdapterRequest'));
|
|
394
410
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'genericAdapterRequestNoBasePath'));
|
|
411
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterLint'));
|
|
412
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterTests'));
|
|
413
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapGetAdapterInventory'));
|
|
395
414
|
done();
|
|
396
415
|
} catch (error) {
|
|
397
416
|
log.error(`Test Failure: ${error}`);
|
|
@@ -512,6 +531,39 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
512
531
|
done(error);
|
|
513
532
|
}
|
|
514
533
|
});
|
|
534
|
+
it('pronghorn.json verify input/output schema objects', (done) => {
|
|
535
|
+
const verifySchema = (methodName, schema) => {
|
|
536
|
+
try {
|
|
537
|
+
ajv.compile(schema);
|
|
538
|
+
} catch (error) {
|
|
539
|
+
const errorMessage = `Invalid schema found in '${methodName}' method.
|
|
540
|
+
Schema => ${JSON.stringify(schema)}.
|
|
541
|
+
Details => ${error.message}`;
|
|
542
|
+
throw new Error(errorMessage);
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
try {
|
|
547
|
+
const pronghornDotJson = require('../../pronghorn.json');
|
|
548
|
+
const { methods } = pronghornDotJson;
|
|
549
|
+
for (let i = 0; i < methods.length; i += 1) {
|
|
550
|
+
for (let j = 0; j < methods[i].input.length; j += 1) {
|
|
551
|
+
const inputSchema = methods[i].input[j].schema;
|
|
552
|
+
if (inputSchema) {
|
|
553
|
+
verifySchema(methods[i].name, inputSchema);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
const outputSchema = methods[i].output.schema;
|
|
557
|
+
if (outputSchema) {
|
|
558
|
+
verifySchema(methods[i].name, outputSchema);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
done();
|
|
562
|
+
} catch (error) {
|
|
563
|
+
log.error(`Adapter Exception: ${error}`);
|
|
564
|
+
done(error);
|
|
565
|
+
}
|
|
566
|
+
});
|
|
515
567
|
});
|
|
516
568
|
|
|
517
569
|
describe('propertiesSchema.json', () => {
|
|
@@ -547,6 +599,7 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
547
599
|
assert.equal('string', propertiesDotJson.properties.host.type);
|
|
548
600
|
assert.equal('integer', propertiesDotJson.properties.port.type);
|
|
549
601
|
assert.equal('boolean', propertiesDotJson.properties.stub.type);
|
|
602
|
+
assert.equal('string', propertiesDotJson.properties.protocol.type);
|
|
550
603
|
assert.notEqual(undefined, propertiesDotJson.definitions.authentication);
|
|
551
604
|
assert.notEqual(null, propertiesDotJson.definitions.authentication);
|
|
552
605
|
assert.notEqual('', propertiesDotJson.definitions.authentication);
|
|
@@ -580,7 +633,6 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
580
633
|
assert.equal('boolean', propertiesDotJson.properties.encode_pathvars.type);
|
|
581
634
|
assert.equal('boolean', propertiesDotJson.properties.encode_queryvars.type);
|
|
582
635
|
assert.equal(true, Array.isArray(propertiesDotJson.properties.save_metric.type));
|
|
583
|
-
assert.equal('string', propertiesDotJson.properties.protocol.type);
|
|
584
636
|
assert.notEqual(undefined, propertiesDotJson.definitions);
|
|
585
637
|
assert.notEqual(null, propertiesDotJson.definitions);
|
|
586
638
|
assert.notEqual('', propertiesDotJson.definitions);
|
|
@@ -737,6 +789,7 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
737
789
|
assert.notEqual(undefined, sampleDotJson.properties.host);
|
|
738
790
|
assert.notEqual(undefined, sampleDotJson.properties.port);
|
|
739
791
|
assert.notEqual(undefined, sampleDotJson.properties.stub);
|
|
792
|
+
assert.notEqual(undefined, sampleDotJson.properties.protocol);
|
|
740
793
|
assert.notEqual(undefined, sampleDotJson.properties.authentication);
|
|
741
794
|
assert.notEqual(null, sampleDotJson.properties.authentication);
|
|
742
795
|
assert.notEqual('', sampleDotJson.properties.authentication);
|
|
@@ -770,7 +823,6 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
770
823
|
assert.notEqual(undefined, sampleDotJson.properties.encode_pathvars);
|
|
771
824
|
assert.notEqual(undefined, sampleDotJson.properties.encode_queryvars);
|
|
772
825
|
assert.notEqual(undefined, sampleDotJson.properties.save_metric);
|
|
773
|
-
assert.notEqual(undefined, sampleDotJson.properties.protocol);
|
|
774
826
|
assert.notEqual(undefined, sampleDotJson.properties.healthcheck);
|
|
775
827
|
assert.notEqual(null, sampleDotJson.properties.healthcheck);
|
|
776
828
|
assert.notEqual('', sampleDotJson.properties.healthcheck);
|
|
@@ -835,6 +887,8 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
835
887
|
assert.notEqual(undefined, sampleDotJson.properties.devicebroker.isAlive);
|
|
836
888
|
assert.notEqual(undefined, sampleDotJson.properties.devicebroker.getConfig);
|
|
837
889
|
assert.notEqual(undefined, sampleDotJson.properties.devicebroker.getCount);
|
|
890
|
+
assert.notEqual(undefined, sampleDotJson.properties.cache);
|
|
891
|
+
assert.notEqual(undefined, sampleDotJson.properties.cache.entities);
|
|
838
892
|
done();
|
|
839
893
|
} catch (error) {
|
|
840
894
|
log.error(`Test Failure: ${error}`);
|
|
@@ -940,40 +994,6 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
940
994
|
});
|
|
941
995
|
});
|
|
942
996
|
|
|
943
|
-
describe('#iapFindAdapterPath', () => {
|
|
944
|
-
it('should have a iapFindAdapterPath function', (done) => {
|
|
945
|
-
try {
|
|
946
|
-
assert.equal(true, typeof a.iapFindAdapterPath === 'function');
|
|
947
|
-
done();
|
|
948
|
-
} catch (error) {
|
|
949
|
-
log.error(`Test Failure: ${error}`);
|
|
950
|
-
done(error);
|
|
951
|
-
}
|
|
952
|
-
});
|
|
953
|
-
it('iapFindAdapterPath should find atleast one path that matches', (done) => {
|
|
954
|
-
try {
|
|
955
|
-
a.iapFindAdapterPath('{base_path}/{version}', (data, error) => {
|
|
956
|
-
try {
|
|
957
|
-
assert.equal(undefined, error);
|
|
958
|
-
assert.notEqual(undefined, data);
|
|
959
|
-
assert.notEqual(null, data);
|
|
960
|
-
assert.equal(true, data.found);
|
|
961
|
-
assert.notEqual(undefined, data.foundIn);
|
|
962
|
-
assert.notEqual(null, data.foundIn);
|
|
963
|
-
assert.notEqual(0, data.foundIn.length);
|
|
964
|
-
done();
|
|
965
|
-
} catch (err) {
|
|
966
|
-
log.error(`Test Failure: ${err}`);
|
|
967
|
-
done(err);
|
|
968
|
-
}
|
|
969
|
-
});
|
|
970
|
-
} catch (error) {
|
|
971
|
-
log.error(`Adapter Exception: ${error}`);
|
|
972
|
-
done(error);
|
|
973
|
-
}
|
|
974
|
-
}).timeout(attemptTimeout);
|
|
975
|
-
});
|
|
976
|
-
|
|
977
997
|
describe('#iapSuspendAdapter', () => {
|
|
978
998
|
it('should have a iapSuspendAdapter function', (done) => {
|
|
979
999
|
try {
|
|
@@ -1010,6 +1030,40 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
1010
1030
|
});
|
|
1011
1031
|
});
|
|
1012
1032
|
|
|
1033
|
+
describe('#iapFindAdapterPath', () => {
|
|
1034
|
+
it('should have a iapFindAdapterPath function', (done) => {
|
|
1035
|
+
try {
|
|
1036
|
+
assert.equal(true, typeof a.iapFindAdapterPath === 'function');
|
|
1037
|
+
done();
|
|
1038
|
+
} catch (error) {
|
|
1039
|
+
log.error(`Test Failure: ${error}`);
|
|
1040
|
+
done(error);
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
it('iapFindAdapterPath should find atleast one path that matches', (done) => {
|
|
1044
|
+
try {
|
|
1045
|
+
a.iapFindAdapterPath('{base_path}/{version}', (data, error) => {
|
|
1046
|
+
try {
|
|
1047
|
+
assert.equal(undefined, error);
|
|
1048
|
+
assert.notEqual(undefined, data);
|
|
1049
|
+
assert.notEqual(null, data);
|
|
1050
|
+
assert.equal(true, data.found);
|
|
1051
|
+
assert.notEqual(undefined, data.foundIn);
|
|
1052
|
+
assert.notEqual(null, data.foundIn);
|
|
1053
|
+
assert.notEqual(0, data.foundIn.length);
|
|
1054
|
+
done();
|
|
1055
|
+
} catch (err) {
|
|
1056
|
+
log.error(`Test Failure: ${err}`);
|
|
1057
|
+
done(err);
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
} catch (error) {
|
|
1061
|
+
log.error(`Adapter Exception: ${error}`);
|
|
1062
|
+
done(error);
|
|
1063
|
+
}
|
|
1064
|
+
}).timeout(attemptTimeout);
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1013
1067
|
describe('#iapTroubleshootAdapter', () => {
|
|
1014
1068
|
it('should have a iapTroubleshootAdapter function', (done) => {
|
|
1015
1069
|
try {
|
|
@@ -1155,49 +1209,53 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
1155
1209
|
}).timeout(attemptTimeout);
|
|
1156
1210
|
});
|
|
1157
1211
|
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1212
|
+
describe('#iapDeactivateTasks', () => {
|
|
1213
|
+
it('should have a iapDeactivateTasks function', (done) => {
|
|
1214
|
+
try {
|
|
1215
|
+
assert.equal(true, typeof a.iapDeactivateTasks === 'function');
|
|
1216
|
+
done();
|
|
1217
|
+
} catch (error) {
|
|
1218
|
+
log.error(`Test Failure: ${error}`);
|
|
1219
|
+
done(error);
|
|
1220
|
+
}
|
|
1221
|
+
});
|
|
1222
|
+
});
|
|
1223
|
+
|
|
1224
|
+
describe('#iapActivateTasks', () => {
|
|
1225
|
+
it('should have a iapActivateTasks function', (done) => {
|
|
1226
|
+
try {
|
|
1227
|
+
assert.equal(true, typeof a.iapActivateTasks === 'function');
|
|
1228
|
+
done();
|
|
1229
|
+
} catch (error) {
|
|
1230
|
+
log.error(`Test Failure: ${error}`);
|
|
1231
|
+
done(error);
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
describe('#iapPopulateEntityCache', () => {
|
|
1237
|
+
it('should have a iapPopulateEntityCache function', (done) => {
|
|
1238
|
+
try {
|
|
1239
|
+
assert.equal(true, typeof a.iapPopulateEntityCache === 'function');
|
|
1240
|
+
done();
|
|
1241
|
+
} catch (error) {
|
|
1242
|
+
log.error(`Test Failure: ${error}`);
|
|
1243
|
+
done(error);
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
});
|
|
1247
|
+
|
|
1248
|
+
describe('#iapRetrieveEntitiesCache', () => {
|
|
1249
|
+
it('should have a iapRetrieveEntitiesCache function', (done) => {
|
|
1250
|
+
try {
|
|
1251
|
+
assert.equal(true, typeof a.iapRetrieveEntitiesCache === 'function');
|
|
1252
|
+
done();
|
|
1253
|
+
} catch (error) {
|
|
1254
|
+
log.error(`Test Failure: ${error}`);
|
|
1255
|
+
done(error);
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
});
|
|
1201
1259
|
|
|
1202
1260
|
describe('#hasEntities', () => {
|
|
1203
1261
|
it('should have a hasEntities function', (done) => {
|
|
@@ -1271,6 +1329,173 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
1271
1329
|
});
|
|
1272
1330
|
});
|
|
1273
1331
|
|
|
1332
|
+
describe('#iapExpandedGenericAdapterRequest', () => {
|
|
1333
|
+
it('should have a iapExpandedGenericAdapterRequest function', (done) => {
|
|
1334
|
+
try {
|
|
1335
|
+
assert.equal(true, typeof a.iapExpandedGenericAdapterRequest === 'function');
|
|
1336
|
+
done();
|
|
1337
|
+
} catch (error) {
|
|
1338
|
+
log.error(`Test Failure: ${error}`);
|
|
1339
|
+
done(error);
|
|
1340
|
+
}
|
|
1341
|
+
});
|
|
1342
|
+
});
|
|
1343
|
+
|
|
1344
|
+
describe('#genericAdapterRequest', () => {
|
|
1345
|
+
it('should have a genericAdapterRequest function', (done) => {
|
|
1346
|
+
try {
|
|
1347
|
+
assert.equal(true, typeof a.genericAdapterRequest === 'function');
|
|
1348
|
+
done();
|
|
1349
|
+
} catch (error) {
|
|
1350
|
+
log.error(`Test Failure: ${error}`);
|
|
1351
|
+
done(error);
|
|
1352
|
+
}
|
|
1353
|
+
});
|
|
1354
|
+
});
|
|
1355
|
+
|
|
1356
|
+
describe('#genericAdapterRequestNoBasePath', () => {
|
|
1357
|
+
it('should have a genericAdapterRequestNoBasePath function', (done) => {
|
|
1358
|
+
try {
|
|
1359
|
+
assert.equal(true, typeof a.genericAdapterRequestNoBasePath === 'function');
|
|
1360
|
+
done();
|
|
1361
|
+
} catch (error) {
|
|
1362
|
+
log.error(`Test Failure: ${error}`);
|
|
1363
|
+
done(error);
|
|
1364
|
+
}
|
|
1365
|
+
});
|
|
1366
|
+
});
|
|
1367
|
+
|
|
1368
|
+
describe('#iapRunAdapterLint', () => {
|
|
1369
|
+
it('should have a iapRunAdapterLint function', (done) => {
|
|
1370
|
+
try {
|
|
1371
|
+
assert.equal(true, typeof a.iapRunAdapterLint === 'function');
|
|
1372
|
+
done();
|
|
1373
|
+
} catch (error) {
|
|
1374
|
+
log.error(`Test Failure: ${error}`);
|
|
1375
|
+
done(error);
|
|
1376
|
+
}
|
|
1377
|
+
});
|
|
1378
|
+
it('retrieve the lint results', (done) => {
|
|
1379
|
+
try {
|
|
1380
|
+
a.iapRunAdapterLint((data, error) => {
|
|
1381
|
+
try {
|
|
1382
|
+
assert.equal(undefined, error);
|
|
1383
|
+
assert.notEqual(undefined, data);
|
|
1384
|
+
assert.notEqual(null, data);
|
|
1385
|
+
assert.notEqual(undefined, data.status);
|
|
1386
|
+
assert.notEqual(null, data.status);
|
|
1387
|
+
assert.equal('SUCCESS', data.status);
|
|
1388
|
+
done();
|
|
1389
|
+
} catch (err) {
|
|
1390
|
+
log.error(`Test Failure: ${err}`);
|
|
1391
|
+
done(err);
|
|
1392
|
+
}
|
|
1393
|
+
});
|
|
1394
|
+
} catch (error) {
|
|
1395
|
+
log.error(`Adapter Exception: ${error}`);
|
|
1396
|
+
done(error);
|
|
1397
|
+
}
|
|
1398
|
+
}).timeout(attemptTimeout);
|
|
1399
|
+
});
|
|
1400
|
+
|
|
1401
|
+
describe('#iapRunAdapterTests', () => {
|
|
1402
|
+
it('should have a iapRunAdapterTests function', (done) => {
|
|
1403
|
+
try {
|
|
1404
|
+
assert.equal(true, typeof a.iapRunAdapterTests === 'function');
|
|
1405
|
+
done();
|
|
1406
|
+
} catch (error) {
|
|
1407
|
+
log.error(`Test Failure: ${error}`);
|
|
1408
|
+
done(error);
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1411
|
+
});
|
|
1412
|
+
|
|
1413
|
+
describe('#iapGetAdapterInventory', () => {
|
|
1414
|
+
it('should have a iapGetAdapterInventory function', (done) => {
|
|
1415
|
+
try {
|
|
1416
|
+
assert.equal(true, typeof a.iapGetAdapterInventory === 'function');
|
|
1417
|
+
done();
|
|
1418
|
+
} catch (error) {
|
|
1419
|
+
log.error(`Test Failure: ${error}`);
|
|
1420
|
+
done(error);
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1423
|
+
it('retrieve the inventory', (done) => {
|
|
1424
|
+
try {
|
|
1425
|
+
a.iapGetAdapterInventory((data, error) => {
|
|
1426
|
+
try {
|
|
1427
|
+
assert.equal(undefined, error);
|
|
1428
|
+
assert.notEqual(undefined, data);
|
|
1429
|
+
assert.notEqual(null, data);
|
|
1430
|
+
done();
|
|
1431
|
+
} catch (err) {
|
|
1432
|
+
log.error(`Test Failure: ${err}`);
|
|
1433
|
+
done(err);
|
|
1434
|
+
}
|
|
1435
|
+
});
|
|
1436
|
+
} catch (error) {
|
|
1437
|
+
log.error(`Adapter Exception: ${error}`);
|
|
1438
|
+
done(error);
|
|
1439
|
+
}
|
|
1440
|
+
}).timeout(attemptTimeout);
|
|
1441
|
+
});
|
|
1442
|
+
describe('metadata.json', () => {
|
|
1443
|
+
it('should have a metadata.json', (done) => {
|
|
1444
|
+
try {
|
|
1445
|
+
fs.exists('metadata.json', (val) => {
|
|
1446
|
+
assert.equal(true, val);
|
|
1447
|
+
done();
|
|
1448
|
+
});
|
|
1449
|
+
} catch (error) {
|
|
1450
|
+
log.error(`Test Failure: ${error}`);
|
|
1451
|
+
done(error);
|
|
1452
|
+
}
|
|
1453
|
+
});
|
|
1454
|
+
it('metadata.json is customized', (done) => {
|
|
1455
|
+
try {
|
|
1456
|
+
const metadataDotJson = require('../../metadata.json');
|
|
1457
|
+
assert.equal('adapter-netbrain', metadataDotJson.name);
|
|
1458
|
+
assert.notEqual(undefined, metadataDotJson.webName);
|
|
1459
|
+
assert.notEqual(null, metadataDotJson.webName);
|
|
1460
|
+
assert.notEqual('', metadataDotJson.webName);
|
|
1461
|
+
assert.equal('Adapter', metadataDotJson.type);
|
|
1462
|
+
done();
|
|
1463
|
+
} catch (error) {
|
|
1464
|
+
log.error(`Test Failure: ${error}`);
|
|
1465
|
+
done(error);
|
|
1466
|
+
}
|
|
1467
|
+
});
|
|
1468
|
+
it('metadata.json contains accurate documentation', (done) => {
|
|
1469
|
+
try {
|
|
1470
|
+
const metadataDotJson = require('../../metadata.json');
|
|
1471
|
+
assert.notEqual(undefined, metadataDotJson.documentation);
|
|
1472
|
+
assert.equal('https://www.npmjs.com/package/@itentialopensource/adapter-netbrain', metadataDotJson.documentation.npmLink);
|
|
1473
|
+
assert.equal('https://docs.itential.com/opensource/docs/troubleshooting-an-adapter', metadataDotJson.documentation.faqLink);
|
|
1474
|
+
assert.equal('https://gitlab.com/itentialopensource/adapters/contributing-guide', metadataDotJson.documentation.contributeLink);
|
|
1475
|
+
assert.equal('https://itential.atlassian.net/servicedesk/customer/portals', metadataDotJson.documentation.issueLink);
|
|
1476
|
+
done();
|
|
1477
|
+
} catch (error) {
|
|
1478
|
+
log.error(`Test Failure: ${error}`);
|
|
1479
|
+
done(error);
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
it('metadata.json has related items', (done) => {
|
|
1483
|
+
try {
|
|
1484
|
+
const metadataDotJson = require('../../metadata.json');
|
|
1485
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems);
|
|
1486
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems.adapters);
|
|
1487
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems.integrations);
|
|
1488
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems.ecosystemApplications);
|
|
1489
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems.workflowProjects);
|
|
1490
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems.transformationProjects);
|
|
1491
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems.exampleProjects);
|
|
1492
|
+
done();
|
|
1493
|
+
} catch (error) {
|
|
1494
|
+
log.error(`Test Failure: ${error}`);
|
|
1495
|
+
done(error);
|
|
1496
|
+
}
|
|
1497
|
+
});
|
|
1498
|
+
});
|
|
1274
1499
|
/*
|
|
1275
1500
|
-----------------------------------------------------------------------
|
|
1276
1501
|
-----------------------------------------------------------------------
|
|
@@ -1517,23 +1742,6 @@ describe('[unit] Netbrain Adapter Test', () => {
|
|
|
1517
1742
|
done(error);
|
|
1518
1743
|
}
|
|
1519
1744
|
}).timeout(attemptTimeout);
|
|
1520
|
-
it('should error if - missing tenantId', (done) => {
|
|
1521
|
-
try {
|
|
1522
|
-
a.deleteV1CMDBTenantsTenantId(null, (data, error) => {
|
|
1523
|
-
try {
|
|
1524
|
-
const displayE = 'tenantId is required';
|
|
1525
|
-
runErrorAsserts(data, error, 'AD.300', 'Test-netbrain-adapter-deleteV1CMDBTenantsTenantId', displayE);
|
|
1526
|
-
done();
|
|
1527
|
-
} catch (err) {
|
|
1528
|
-
log.error(`Test Failure: ${err}`);
|
|
1529
|
-
done(err);
|
|
1530
|
-
}
|
|
1531
|
-
});
|
|
1532
|
-
} catch (error) {
|
|
1533
|
-
log.error(`Adapter Exception: ${error}`);
|
|
1534
|
-
done(error);
|
|
1535
|
-
}
|
|
1536
|
-
}).timeout(attemptTimeout);
|
|
1537
1745
|
});
|
|
1538
1746
|
|
|
1539
1747
|
describe('#postV1CMDBTenantsUsers - errors', () => {
|
package/utils/adapterInfo.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
/* eslint import/no-dynamic-require:warn */
|
|
5
5
|
/* eslint prefer-destructuring:warn */
|
|
6
6
|
|
|
7
|
-
const fs = require('fs-extra');
|
|
8
7
|
const path = require('path');
|
|
8
|
+
const fs = require('fs-extra');
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* This script will determine the information about the adapter and store
|
package/utils/addAuth.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
/* eslint global-require: warn */
|
|
3
3
|
/* eslint import/no-dynamic-require: warn */
|
|
4
4
|
|
|
5
|
-
const rls = require('readline-sync');
|
|
6
5
|
const path = require('path');
|
|
7
6
|
const fs = require('fs');
|
|
7
|
+
const rls = require('readline-sync');
|
|
8
8
|
|
|
9
9
|
function getQuestions(props, obj) {
|
|
10
10
|
const questions = props.map((p) => `${p}: ${(obj[p] !== undefined) ? `(${obj[p]})` : ''} `);
|
package/utils/artifactize.js
CHANGED
package/utils/checkMigrate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { execSync } = require('child_process');
|
|
2
|
+
const fs = require('fs');
|
|
2
3
|
const semver = require('semver');
|
|
3
4
|
const axios = require('axios');
|
|
4
|
-
const fs = require('fs');
|
|
5
5
|
const packageJson = require('../package.json');
|
|
6
6
|
|
|
7
7
|
const localEngineVer = packageJson.engineVersion;
|