@itentialopensource/adapter-meraki 0.8.0 → 0.8.3
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/AUTH.md +39 -0
- package/BROKER.md +195 -0
- package/CALLS.md +169 -0
- package/CHANGELOG.md +24 -0
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +88 -74
- package/ENHANCE.md +69 -0
- package/PROPERTIES.md +641 -0
- package/README.md +221 -571
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +291 -471
- package/adapterBase.js +973 -252
- package/entities/.generic/action.json +105 -0
- package/entities/.generic/schema.json +6 -1
- package/error.json +6 -0
- package/package.json +4 -3
- package/pronghorn.json +170 -98
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +380 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/updateReport1651511176919.json +115 -0
- package/sampleProperties.json +82 -0
- package/test/integration/adapterTestIntegration.js +1 -0
- package/test/unit/adapterBaseTestUnit.js +30 -25
- package/test/unit/adapterTestUnit.js +61 -65
- package/utils/adapterInfo.js +206 -0
- package/utils/pre-commit.sh +3 -0
- package/utils/tbUtils.js +20 -7
@@ -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', '
|
321
|
-
'
|
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('#
|
341
|
-
it('should have a
|
342
|
+
describe('#iapGetAdapterWorkflowFunctions', () => {
|
343
|
+
it('should have a iapGetAdapterWorkflowFunctions function', (done) => {
|
342
344
|
try {
|
343
|
-
assert.equal(true, typeof a.
|
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.
|
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('#
|
430
|
-
it('should have a
|
431
|
+
describe('#iapGetAdapterQueue', () => {
|
432
|
+
it('should have a iapGetAdapterQueue function', (done) => {
|
431
433
|
try {
|
432
|
-
assert.equal(true, typeof a.
|
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.
|
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(
|
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
|
-
|
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.
|
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.
|
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.
|
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-
|
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.
|
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-
|
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.
|
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-
|
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.
|
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-
|
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}`);
|
@@ -271,10 +271,10 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
271
271
|
});
|
272
272
|
|
273
273
|
let wffunctions = [];
|
274
|
-
describe('#
|
274
|
+
describe('#iapGetAdapterWorkflowFunctions', () => {
|
275
275
|
it('should retrieve workflow functions', (done) => {
|
276
276
|
try {
|
277
|
-
wffunctions = a.
|
277
|
+
wffunctions = a.iapGetAdapterWorkflowFunctions([]);
|
278
278
|
|
279
279
|
try {
|
280
280
|
assert.notEqual(0, wffunctions.length);
|
@@ -465,16 +465,17 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
465
465
|
assert.notEqual('', pronghornDotJson.methods);
|
466
466
|
assert.equal(true, Array.isArray(pronghornDotJson.methods));
|
467
467
|
assert.notEqual(0, pronghornDotJson.methods.length);
|
468
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
469
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
470
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
471
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
472
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
473
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
474
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
475
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
476
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
468
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapUpdateAdapterConfiguration'));
|
469
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapFindAdapterPath'));
|
470
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapTroubleshootAdapter'));
|
471
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterHealthcheck'));
|
472
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterConnectivity'));
|
473
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterBasicGet'));
|
474
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapSuspendAdapter'));
|
475
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapUnsuspendAdapter'));
|
476
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapGetAdapterQueue'));
|
477
477
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'genericAdapterRequest'));
|
478
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'genericAdapterRequestNoBasePath'));
|
478
479
|
done();
|
479
480
|
} catch (error) {
|
480
481
|
log.error(`Test Failure: ${error}`);
|
@@ -646,6 +647,8 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
646
647
|
assert.equal('string', propertiesDotJson.definitions.authentication.properties.client_id.type);
|
647
648
|
assert.equal('string', propertiesDotJson.definitions.authentication.properties.client_secret.type);
|
648
649
|
assert.equal('string', propertiesDotJson.definitions.authentication.properties.grant_type.type);
|
650
|
+
assert.notEqual(undefined, propertiesDotJson.definitions.ssl);
|
651
|
+
assert.notEqual(null, propertiesDotJson.definitions.ssl);
|
649
652
|
assert.notEqual('', propertiesDotJson.definitions.ssl);
|
650
653
|
assert.equal('string', propertiesDotJson.definitions.ssl.properties.ecdhCurve.type);
|
651
654
|
assert.equal('boolean', propertiesDotJson.definitions.ssl.properties.enabled.type);
|
@@ -659,6 +662,7 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
659
662
|
assert.equal('string', propertiesDotJson.properties.version.type);
|
660
663
|
assert.equal('string', propertiesDotJson.properties.cache_location.type);
|
661
664
|
assert.equal('boolean', propertiesDotJson.properties.encode_pathvars.type);
|
665
|
+
assert.equal('boolean', propertiesDotJson.properties.encode_queryvars.type);
|
662
666
|
assert.equal(true, Array.isArray(propertiesDotJson.properties.save_metric.type));
|
663
667
|
assert.equal('string', propertiesDotJson.properties.protocol.type);
|
664
668
|
assert.notEqual(undefined, propertiesDotJson.definitions);
|
@@ -707,8 +711,6 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
707
711
|
assert.equal('string', propertiesDotJson.definitions.proxy.properties.protocol.type);
|
708
712
|
assert.equal('string', propertiesDotJson.definitions.proxy.properties.username.type);
|
709
713
|
assert.equal('string', propertiesDotJson.definitions.proxy.properties.password.type);
|
710
|
-
assert.notEqual(undefined, propertiesDotJson.definitions.ssl);
|
711
|
-
assert.notEqual(null, propertiesDotJson.definitions.ssl);
|
712
714
|
assert.notEqual(undefined, propertiesDotJson.definitions.mongo);
|
713
715
|
assert.notEqual(null, propertiesDotJson.definitions.mongo);
|
714
716
|
assert.notEqual('', propertiesDotJson.definitions.mongo);
|
@@ -724,6 +726,12 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
724
726
|
assert.equal('string', propertiesDotJson.definitions.mongo.properties.db_ssl.properties.ca_file.type);
|
725
727
|
assert.equal('string', propertiesDotJson.definitions.mongo.properties.db_ssl.properties.key_file.type);
|
726
728
|
assert.equal('string', propertiesDotJson.definitions.mongo.properties.db_ssl.properties.cert_file.type);
|
729
|
+
assert.notEqual('', propertiesDotJson.definitions.devicebroker);
|
730
|
+
assert.equal('array', propertiesDotJson.definitions.devicebroker.properties.getDevice.type);
|
731
|
+
assert.equal('array', propertiesDotJson.definitions.devicebroker.properties.getDevicesFiltered.type);
|
732
|
+
assert.equal('array', propertiesDotJson.definitions.devicebroker.properties.isAlive.type);
|
733
|
+
assert.equal('array', propertiesDotJson.definitions.devicebroker.properties.getConfig.type);
|
734
|
+
assert.equal('array', propertiesDotJson.definitions.devicebroker.properties.getCount.type);
|
727
735
|
done();
|
728
736
|
} catch (error) {
|
729
737
|
log.error(`Test Failure: ${error}`);
|
@@ -1002,10 +1010,10 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1002
1010
|
});
|
1003
1011
|
});
|
1004
1012
|
|
1005
|
-
describe('#
|
1006
|
-
it('should have a
|
1013
|
+
describe('#iapUpdateAdapterConfiguration', () => {
|
1014
|
+
it('should have a iapUpdateAdapterConfiguration function', (done) => {
|
1007
1015
|
try {
|
1008
|
-
assert.equal(true, typeof a.
|
1016
|
+
assert.equal(true, typeof a.iapUpdateAdapterConfiguration === 'function');
|
1009
1017
|
done();
|
1010
1018
|
} catch (error) {
|
1011
1019
|
log.error(`Test Failure: ${error}`);
|
@@ -1014,19 +1022,19 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1014
1022
|
});
|
1015
1023
|
});
|
1016
1024
|
|
1017
|
-
describe('#
|
1018
|
-
it('should have a
|
1025
|
+
describe('#iapFindAdapterPath', () => {
|
1026
|
+
it('should have a iapFindAdapterPath function', (done) => {
|
1019
1027
|
try {
|
1020
|
-
assert.equal(true, typeof a.
|
1028
|
+
assert.equal(true, typeof a.iapFindAdapterPath === 'function');
|
1021
1029
|
done();
|
1022
1030
|
} catch (error) {
|
1023
1031
|
log.error(`Test Failure: ${error}`);
|
1024
1032
|
done(error);
|
1025
1033
|
}
|
1026
1034
|
});
|
1027
|
-
it('
|
1035
|
+
it('iapFindAdapterPath should find atleast one path that matches', (done) => {
|
1028
1036
|
try {
|
1029
|
-
a.
|
1037
|
+
a.iapFindAdapterPath('{base_path}/{version}', (data, error) => {
|
1030
1038
|
try {
|
1031
1039
|
assert.equal(undefined, error);
|
1032
1040
|
assert.notEqual(undefined, data);
|
@@ -1048,10 +1056,10 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1048
1056
|
}).timeout(attemptTimeout);
|
1049
1057
|
});
|
1050
1058
|
|
1051
|
-
describe('#
|
1052
|
-
it('should have a
|
1059
|
+
describe('#iapSuspendAdapter', () => {
|
1060
|
+
it('should have a iapSuspendAdapter function', (done) => {
|
1053
1061
|
try {
|
1054
|
-
assert.equal(true, typeof a.
|
1062
|
+
assert.equal(true, typeof a.iapSuspendAdapter === 'function');
|
1055
1063
|
done();
|
1056
1064
|
} catch (error) {
|
1057
1065
|
log.error(`Test Failure: ${error}`);
|
@@ -1060,10 +1068,10 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1060
1068
|
});
|
1061
1069
|
});
|
1062
1070
|
|
1063
|
-
describe('#
|
1064
|
-
it('should have a
|
1071
|
+
describe('#iapUnsuspendAdapter', () => {
|
1072
|
+
it('should have a iapUnsuspendAdapter function', (done) => {
|
1065
1073
|
try {
|
1066
|
-
assert.equal(true, typeof a.
|
1074
|
+
assert.equal(true, typeof a.iapUnsuspendAdapter === 'function');
|
1067
1075
|
done();
|
1068
1076
|
} catch (error) {
|
1069
1077
|
log.error(`Test Failure: ${error}`);
|
@@ -1072,10 +1080,10 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1072
1080
|
});
|
1073
1081
|
});
|
1074
1082
|
|
1075
|
-
describe('#
|
1076
|
-
it('should have a
|
1083
|
+
describe('#iapGetAdapterQueue', () => {
|
1084
|
+
it('should have a iapGetAdapterQueue function', (done) => {
|
1077
1085
|
try {
|
1078
|
-
assert.equal(true, typeof a.
|
1086
|
+
assert.equal(true, typeof a.iapGetAdapterQueue === 'function');
|
1079
1087
|
done();
|
1080
1088
|
} catch (error) {
|
1081
1089
|
log.error(`Test Failure: ${error}`);
|
@@ -1084,10 +1092,10 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1084
1092
|
});
|
1085
1093
|
});
|
1086
1094
|
|
1087
|
-
describe('#
|
1088
|
-
it('should have a
|
1095
|
+
describe('#iapTroubleshootAdapter', () => {
|
1096
|
+
it('should have a iapTroubleshootAdapter function', (done) => {
|
1089
1097
|
try {
|
1090
|
-
assert.equal(true, typeof a.
|
1098
|
+
assert.equal(true, typeof a.iapTroubleshootAdapter === 'function');
|
1091
1099
|
done();
|
1092
1100
|
} catch (error) {
|
1093
1101
|
log.error(`Test Failure: ${error}`);
|
@@ -1096,10 +1104,10 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1096
1104
|
});
|
1097
1105
|
});
|
1098
1106
|
|
1099
|
-
describe('#
|
1100
|
-
it('should have a
|
1107
|
+
describe('#iapRunAdapterHealthcheck', () => {
|
1108
|
+
it('should have a iapRunAdapterHealthcheck function', (done) => {
|
1101
1109
|
try {
|
1102
|
-
assert.equal(true, typeof a.
|
1110
|
+
assert.equal(true, typeof a.iapRunAdapterHealthcheck === 'function');
|
1103
1111
|
done();
|
1104
1112
|
} catch (error) {
|
1105
1113
|
log.error(`Test Failure: ${error}`);
|
@@ -1108,10 +1116,10 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1108
1116
|
});
|
1109
1117
|
});
|
1110
1118
|
|
1111
|
-
describe('#
|
1112
|
-
it('should have a
|
1119
|
+
describe('#iapRunAdapterConnectivity', () => {
|
1120
|
+
it('should have a iapRunAdapterConnectivity function', (done) => {
|
1113
1121
|
try {
|
1114
|
-
assert.equal(true, typeof a.
|
1122
|
+
assert.equal(true, typeof a.iapRunAdapterConnectivity === 'function');
|
1115
1123
|
done();
|
1116
1124
|
} catch (error) {
|
1117
1125
|
log.error(`Test Failure: ${error}`);
|
@@ -1120,10 +1128,10 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1120
1128
|
});
|
1121
1129
|
});
|
1122
1130
|
|
1123
|
-
describe('#
|
1124
|
-
it('should have a
|
1131
|
+
describe('#iapRunAdapterBasicGet', () => {
|
1132
|
+
it('should have a iapRunAdapterBasicGet function', (done) => {
|
1125
1133
|
try {
|
1126
|
-
assert.equal(true, typeof a.
|
1134
|
+
assert.equal(true, typeof a.iapRunAdapterBasicGet === 'function');
|
1127
1135
|
done();
|
1128
1136
|
} catch (error) {
|
1129
1137
|
log.error(`Test Failure: ${error}`);
|
@@ -1132,10 +1140,10 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1132
1140
|
});
|
1133
1141
|
});
|
1134
1142
|
|
1135
|
-
describe('#
|
1136
|
-
it('should have a
|
1143
|
+
describe('#iapMoveAdapterEntitiesToDB', () => {
|
1144
|
+
it('should have a iapMoveAdapterEntitiesToDB function', (done) => {
|
1137
1145
|
try {
|
1138
|
-
assert.equal(true, typeof a.
|
1146
|
+
assert.equal(true, typeof a.iapMoveAdapterEntitiesToDB === 'function');
|
1139
1147
|
done();
|
1140
1148
|
} catch (error) {
|
1141
1149
|
log.error(`Test Failure: ${error}`);
|
@@ -1229,10 +1237,10 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1229
1237
|
}).timeout(attemptTimeout);
|
1230
1238
|
});
|
1231
1239
|
|
1232
|
-
// describe('#
|
1233
|
-
// it('should have a
|
1240
|
+
// describe('#iapHasAdapterEntity', () => {
|
1241
|
+
// it('should have a iapHasAdapterEntity function', (done) => {
|
1234
1242
|
// try {
|
1235
|
-
// assert.equal(true, typeof a.
|
1243
|
+
// assert.equal(true, typeof a.iapHasAdapterEntity === 'function');
|
1236
1244
|
// done();
|
1237
1245
|
// } catch (error) {
|
1238
1246
|
// log.error(`Test Failure: ${error}`);
|
@@ -1241,7 +1249,7 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1241
1249
|
// });
|
1242
1250
|
// it('should find entity', (done) => {
|
1243
1251
|
// try {
|
1244
|
-
// a.
|
1252
|
+
// a.iapHasAdapterEntity('template_entity', // 'a9e9c33dc61122760072455df62663d2', (data) => {
|
1245
1253
|
// try {
|
1246
1254
|
// assert.equal(true, data[0]);
|
1247
1255
|
// done();
|
@@ -1257,7 +1265,7 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1257
1265
|
// }).timeout(attemptTimeout);
|
1258
1266
|
// it('should not find entity', (done) => {
|
1259
1267
|
// try {
|
1260
|
-
// a.
|
1268
|
+
// a.iapHasAdapterEntity('template_entity', 'blah', (data) => {
|
1261
1269
|
// try {
|
1262
1270
|
// assert.equal(false, data[0]);
|
1263
1271
|
// done();
|
@@ -1285,18 +1293,6 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1285
1293
|
});
|
1286
1294
|
});
|
1287
1295
|
|
1288
|
-
describe('#hasDevices', () => {
|
1289
|
-
it('should have a hasDevices function', (done) => {
|
1290
|
-
try {
|
1291
|
-
assert.equal(true, typeof a.hasDevices === 'function');
|
1292
|
-
done();
|
1293
|
-
} catch (error) {
|
1294
|
-
log.error(`Test Failure: ${error}`);
|
1295
|
-
done(error);
|
1296
|
-
}
|
1297
|
-
});
|
1298
|
-
});
|
1299
|
-
|
1300
1296
|
describe('#getDevice', () => {
|
1301
1297
|
it('should have a getDevice function', (done) => {
|
1302
1298
|
try {
|
@@ -1345,10 +1341,10 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1345
1341
|
});
|
1346
1342
|
});
|
1347
1343
|
|
1348
|
-
describe('#
|
1349
|
-
it('should have a
|
1344
|
+
describe('#iapGetDeviceCount', () => {
|
1345
|
+
it('should have a iapGetDeviceCount function', (done) => {
|
1350
1346
|
try {
|
1351
|
-
assert.equal(true, typeof a.
|
1347
|
+
assert.equal(true, typeof a.iapGetDeviceCount === 'function');
|
1352
1348
|
done();
|
1353
1349
|
} catch (error) {
|
1354
1350
|
log.error(`Test Failure: ${error}`);
|
@@ -0,0 +1,206 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
/* @copyright Itential, LLC 2019 */
|
3
|
+
/* eslint global-require:warn */
|
4
|
+
/* eslint import/no-dynamic-require:warn */
|
5
|
+
/* eslint prefer-destructuring:warn */
|
6
|
+
|
7
|
+
const fs = require('fs-extra');
|
8
|
+
const path = require('path');
|
9
|
+
|
10
|
+
/**
|
11
|
+
* This script will determine the information about the adapter and store
|
12
|
+
* it into a file in the adapter.
|
13
|
+
*/
|
14
|
+
|
15
|
+
/**
|
16
|
+
* get adapter information
|
17
|
+
*/
|
18
|
+
function adapterInfo() {
|
19
|
+
// set the base pase of the adapter - tool shoud be one level up in utils
|
20
|
+
let adaptdir = __dirname;
|
21
|
+
const infoRes = {};
|
22
|
+
|
23
|
+
if (adaptdir.endsWith('/utils')) {
|
24
|
+
adaptdir = adaptdir.substring(0, adaptdir.length - 6);
|
25
|
+
}
|
26
|
+
const pack = require(`${adaptdir}/package.json`);
|
27
|
+
infoRes.version = pack.version;
|
28
|
+
|
29
|
+
let configCount = 0;
|
30
|
+
if (fs.existsSync(`${adaptdir}/pronghorn.json`)) {
|
31
|
+
const cFile = fs.readFileSync(`${adaptdir}/pronghorn.json`, 'utf8');
|
32
|
+
configCount += cFile.split('\n').length;
|
33
|
+
} else {
|
34
|
+
console.log('Missing - pronghorn.json');
|
35
|
+
}
|
36
|
+
if (fs.existsSync(`${adaptdir}/propertiesSchema.json`)) {
|
37
|
+
const cFile = fs.readFileSync(`${adaptdir}/propertiesSchema.json`, 'utf8');
|
38
|
+
configCount += cFile.split('\n').length;
|
39
|
+
} else {
|
40
|
+
console.log('Missing - propertiesSchema.json');
|
41
|
+
}
|
42
|
+
if (fs.existsSync(`${adaptdir}/error.json`)) {
|
43
|
+
const cFile = fs.readFileSync(`${adaptdir}/error.json`, 'utf8');
|
44
|
+
configCount += cFile.split('\n').length;
|
45
|
+
} else {
|
46
|
+
console.log('Missing - error.json');
|
47
|
+
}
|
48
|
+
const entitydir = path.join(adaptdir, '/entities');
|
49
|
+
if (fs.existsSync(entitydir) && fs.statSync(entitydir).isDirectory()) {
|
50
|
+
const entities = fs.readdirSync(entitydir);
|
51
|
+
// need to go through each entity in the entities directory
|
52
|
+
for (let e = 0; e < entities.length; e += 1) {
|
53
|
+
if (fs.statSync(`${entitydir}/${entities[e]}`).isDirectory()) {
|
54
|
+
const cfiles = fs.readdirSync(entitydir);
|
55
|
+
for (let c = 0; c < cfiles.length; c += 1) {
|
56
|
+
if (cfiles[c].endsWith('.json')) {
|
57
|
+
const ccFile = fs.readFileSync(`${entitydir}/${entities[e]}/${cfiles[c]}`, 'utf8');
|
58
|
+
configCount += ccFile.split('\n').length;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
} else {
|
64
|
+
console.log('Could not find the entities directory');
|
65
|
+
}
|
66
|
+
infoRes.configLines = configCount;
|
67
|
+
|
68
|
+
let scodeCount = 0;
|
69
|
+
if (fs.existsSync(`${adaptdir}/utils/artifactize.js`)) {
|
70
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/artifactize.js`, 'utf8');
|
71
|
+
scodeCount += sFile.split('\n').length;
|
72
|
+
} else {
|
73
|
+
console.log('Missing - utils/artifactize.js');
|
74
|
+
}
|
75
|
+
if (fs.existsSync(`${adaptdir}/utils/basicGet.js`)) {
|
76
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/basicGet.js`, 'utf8');
|
77
|
+
scodeCount += sFile.split('\n').length;
|
78
|
+
} else {
|
79
|
+
console.log('Missing - utils/basicGet.js');
|
80
|
+
}
|
81
|
+
if (fs.existsSync(`${adaptdir}/utils/checkMigrate.js`)) {
|
82
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/checkMigrate.js`, 'utf8');
|
83
|
+
scodeCount += sFile.split('\n').length;
|
84
|
+
} else {
|
85
|
+
console.log('Missing - utils/checkMigrate.js');
|
86
|
+
}
|
87
|
+
if (fs.existsSync(`${adaptdir}/utils/findPath.js`)) {
|
88
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/findPath.js`, 'utf8');
|
89
|
+
scodeCount += sFile.split('\n').length;
|
90
|
+
} else {
|
91
|
+
console.log('Missing - utils/findPath.js');
|
92
|
+
}
|
93
|
+
if (fs.existsSync(`${adaptdir}/utils/modify.js`)) {
|
94
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/modify.js`, 'utf8');
|
95
|
+
scodeCount += sFile.split('\n').length;
|
96
|
+
} else {
|
97
|
+
console.log('Missing - utils/modify.js');
|
98
|
+
}
|
99
|
+
if (fs.existsSync(`${adaptdir}/utils/packModificationScript.js`)) {
|
100
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/packModificationScript.js`, 'utf8');
|
101
|
+
scodeCount += sFile.split('\n').length;
|
102
|
+
} else {
|
103
|
+
console.log('Missing - utils/packModificationScript.js');
|
104
|
+
}
|
105
|
+
if (fs.existsSync(`${adaptdir}/utils/setup.js`)) {
|
106
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/setup.js`, 'utf8');
|
107
|
+
scodeCount += sFile.split('\n').length;
|
108
|
+
} else {
|
109
|
+
console.log('Missing - utils/setup.js');
|
110
|
+
}
|
111
|
+
if (fs.existsSync(`${adaptdir}/utils/tbScript.js`)) {
|
112
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/tbScript.js`, 'utf8');
|
113
|
+
scodeCount += sFile.split('\n').length;
|
114
|
+
} else {
|
115
|
+
console.log('Missing - utils/tbScript.js');
|
116
|
+
}
|
117
|
+
if (fs.existsSync(`${adaptdir}/utils/tbUtils.js`)) {
|
118
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/tbUtils.js`, 'utf8');
|
119
|
+
scodeCount += sFile.split('\n').length;
|
120
|
+
} else {
|
121
|
+
console.log('Missing - utils/tbUtils.js');
|
122
|
+
}
|
123
|
+
if (fs.existsSync(`${adaptdir}/utils/testRunner.js`)) {
|
124
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/testRunner.js`, 'utf8');
|
125
|
+
scodeCount += sFile.split('\n').length;
|
126
|
+
} else {
|
127
|
+
console.log('Missing - utils/testRunner.js');
|
128
|
+
}
|
129
|
+
if (fs.existsSync(`${adaptdir}/utils/troubleshootingAdapter.js`)) {
|
130
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/troubleshootingAdapter.js`, 'utf8');
|
131
|
+
scodeCount += sFile.split('\n').length;
|
132
|
+
} else {
|
133
|
+
console.log('Missing - utils/troubleshootingAdapter.js');
|
134
|
+
}
|
135
|
+
infoRes.scriptLines = scodeCount;
|
136
|
+
|
137
|
+
let codeCount = 0;
|
138
|
+
if (fs.existsSync(`${adaptdir}/adapter.js`)) {
|
139
|
+
const aFile = fs.readFileSync(`${adaptdir}/adapter.js`, 'utf8');
|
140
|
+
codeCount += aFile.split('\n').length;
|
141
|
+
} else {
|
142
|
+
console.log('Missing - utils/adapter.js');
|
143
|
+
}
|
144
|
+
if (fs.existsSync(`${adaptdir}/adapterBase.js`)) {
|
145
|
+
const aFile = fs.readFileSync(`${adaptdir}/adapterBase.js`, 'utf8');
|
146
|
+
codeCount += aFile.split('\n').length;
|
147
|
+
} else {
|
148
|
+
console.log('Missing - utils/adapterBase.js');
|
149
|
+
}
|
150
|
+
infoRes.codeLines = codeCount;
|
151
|
+
|
152
|
+
let tcodeCount = 0;
|
153
|
+
let ttestCount = 0;
|
154
|
+
if (fs.existsSync(`${adaptdir}/test/integration/adapterTestBasicGet.js`)) {
|
155
|
+
const tFile = fs.readFileSync(`${adaptdir}/test/integration/adapterTestBasicGet.js`, 'utf8');
|
156
|
+
tcodeCount += tFile.split('\n').length;
|
157
|
+
ttestCount += tFile.split('it(\'').length;
|
158
|
+
} else {
|
159
|
+
console.log('Missing - test/integration/adapterTestBasicGet.js');
|
160
|
+
}
|
161
|
+
if (fs.existsSync(`${adaptdir}/test/integration/adapterTestConnectivity.js`)) {
|
162
|
+
const tFile = fs.readFileSync(`${adaptdir}/test/integration/adapterTestConnectivity.js`, 'utf8');
|
163
|
+
tcodeCount += tFile.split('\n').length;
|
164
|
+
ttestCount += tFile.split('it(\'').length;
|
165
|
+
} else {
|
166
|
+
console.log('Missing - test/integration/adapterTestConnectivity.js');
|
167
|
+
}
|
168
|
+
if (fs.existsSync(`${adaptdir}/test/integration/adapterTestIntegration.js`)) {
|
169
|
+
const tFile = fs.readFileSync(`${adaptdir}/test/integration/adapterTestIntegration.js`, 'utf8');
|
170
|
+
tcodeCount += tFile.split('\n').length;
|
171
|
+
ttestCount += tFile.split('it(\'').length;
|
172
|
+
} else {
|
173
|
+
console.log('Missing - test/integration/adapterTestIntegration.js');
|
174
|
+
}
|
175
|
+
if (fs.existsSync(`${adaptdir}/test/unit/adapterBaseTestUnit.js`)) {
|
176
|
+
const tFile = fs.readFileSync(`${adaptdir}/test/unit/adapterBaseTestUnit.js`, 'utf8');
|
177
|
+
tcodeCount += tFile.split('\n').length;
|
178
|
+
ttestCount += tFile.split('it(\'').length;
|
179
|
+
} else {
|
180
|
+
console.log('Missing - test/unit/adapterBaseTestUnit.js');
|
181
|
+
}
|
182
|
+
if (fs.existsSync(`${adaptdir}/test/unit/adapterTestUnit.js`)) {
|
183
|
+
const tFile = fs.readFileSync(`${adaptdir}/test/unit/adapterTestUnit.js`, 'utf8');
|
184
|
+
tcodeCount += tFile.split('\n').length;
|
185
|
+
ttestCount += tFile.split('it(\'').length;
|
186
|
+
} else {
|
187
|
+
console.log('Missing - test/unit/adapterTestUnit.js');
|
188
|
+
}
|
189
|
+
infoRes.testLines = tcodeCount;
|
190
|
+
infoRes.testCases = ttestCount;
|
191
|
+
infoRes.totalCodeLines = scodeCount + codeCount + tcodeCount;
|
192
|
+
|
193
|
+
if (fs.existsSync(`${adaptdir}/pronghorn.json`)) {
|
194
|
+
// Read the entity schema from the file system
|
195
|
+
const phFile = path.join(adaptdir, '/pronghorn.json');
|
196
|
+
const prong = require(phFile);
|
197
|
+
infoRes.wfTasks = prong.methods.length;
|
198
|
+
} else {
|
199
|
+
console.log('Missing - pronghorn.json');
|
200
|
+
}
|
201
|
+
|
202
|
+
console.log(JSON.stringify(infoRes));
|
203
|
+
fs.writeFileSync(`${adaptdir}/report/adapterInfo.json`, JSON.stringify(infoRes, null, 2));
|
204
|
+
}
|
205
|
+
|
206
|
+
adapterInfo();
|
package/utils/pre-commit.sh
CHANGED
@@ -17,6 +17,9 @@ printf "%b" "Running pre-commit hooks...\\n"
|
|
17
17
|
# verify testing script is stubbed and no credentials
|
18
18
|
node utils/testRunner.js -r
|
19
19
|
|
20
|
+
# update the adapter information file
|
21
|
+
node utils/adapterInfo.js
|
22
|
+
|
20
23
|
# security audit on the code
|
21
24
|
npm audit --registry=https://registry.npmjs.org --audit-level=moderate
|
22
25
|
|