@itentialopensource/adapter-meraki 1.0.4 → 1.1.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/AUTH.md +14 -18
- package/CALLS.md +4264 -0
- package/CHANGELOG.md +8 -0
- package/CONTRIBUTING.md +1 -160
- package/ENHANCE.md +2 -2
- package/README.md +23 -18
- package/SYSTEMINFO.md +15 -2
- package/adapter.js +164 -335
- package/adapterBase.js +409 -911
- package/changelogs/changelog.md +198 -0
- package/metadata.json +61 -0
- package/package.json +24 -24
- package/pronghorn.json +470 -138
- package/propertiesSchema.json +358 -31
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +8 -8
- package/report/updateReport1690417926405.json +119 -0
- package/sampleProperties.json +74 -27
- package/test/integration/adapterTestBasicGet.js +1 -3
- package/test/integration/adapterTestConnectivity.js +90 -41
- package/test/integration/adapterTestIntegration.js +129 -1
- package/test/unit/adapterBaseTestUnit.js +387 -312
- package/test/unit/adapterTestUnit.js +330 -110
- package/utils/entitiesToDB.js +2 -2
- package/utils/methodDocumentor.js +225 -0
- package/utils/modify.js +12 -14
- 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/troubleshootingAdapter.js +9 -6
- package/versions.json +0 -542
- 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 execute = require('child_process').execSync;
|
12
11
|
const path = require('path');
|
13
12
|
const util = require('util');
|
13
|
+
const execute = require('child_process').execSync;
|
14
14
|
const fs = require('fs-extra');
|
15
15
|
const mocha = require('mocha');
|
16
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,7 +43,7 @@ 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
49
|
|
@@ -220,19 +222,24 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
220
222
|
it('package.json should be validated', (done) => {
|
221
223
|
try {
|
222
224
|
const packageDotJson = require('../../package.json');
|
223
|
-
|
224
|
-
const
|
225
|
-
|
226
|
-
|
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']
|
227
234
|
};
|
228
|
-
const
|
235
|
+
const validate = ajv.compile(packageJsonSchema);
|
236
|
+
const isValid = validate(packageDotJson);
|
229
237
|
|
230
|
-
if (
|
231
|
-
log.error('The package.json contains
|
232
|
-
|
233
|
-
assert.equal(true, results.valid);
|
238
|
+
if (isValid === false) {
|
239
|
+
log.error('The package.json contains errors');
|
240
|
+
assert.equal(true, isValid);
|
234
241
|
} else {
|
235
|
-
assert.equal(true,
|
242
|
+
assert.equal(true, isValid);
|
236
243
|
}
|
237
244
|
|
238
245
|
done();
|
@@ -271,7 +278,7 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
271
278
|
assert.notEqual(undefined, packageDotJson.scripts);
|
272
279
|
assert.notEqual(null, packageDotJson.scripts);
|
273
280
|
assert.notEqual('', packageDotJson.scripts);
|
274
|
-
assert.equal('node utils/setup.js
|
281
|
+
assert.equal('node utils/setup.js', packageDotJson.scripts.preinstall);
|
275
282
|
assert.equal('node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js', packageDotJson.scripts.lint);
|
276
283
|
assert.equal('node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js --quiet', packageDotJson.scripts['lint:errors']);
|
277
284
|
assert.equal('mocha test/unit/adapterBaseTestUnit.js --LOG=error', packageDotJson.scripts['test:baseunit']);
|
@@ -308,17 +315,17 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
308
315
|
assert.notEqual(undefined, packageDotJson.dependencies);
|
309
316
|
assert.notEqual(null, packageDotJson.dependencies);
|
310
317
|
assert.notEqual('', packageDotJson.dependencies);
|
311
|
-
assert.equal('^
|
312
|
-
assert.equal('^
|
313
|
-
assert.equal('^
|
314
|
-
assert.equal('^
|
315
|
-
assert.equal('^
|
318
|
+
assert.equal('^8.12.0', packageDotJson.dependencies.ajv);
|
319
|
+
assert.equal('^1.4.0', 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);
|
316
323
|
assert.equal('^2.0.1', packageDotJson.dependencies['mocha-param']);
|
317
|
-
assert.equal('^0.5.3', packageDotJson.dependencies['network-diagnostics']);
|
318
324
|
assert.equal('^15.1.0', packageDotJson.dependencies.nyc);
|
325
|
+
assert.equal('^0.4.4', packageDotJson.dependencies.ping);
|
319
326
|
assert.equal('^1.4.10', packageDotJson.dependencies['readline-sync']);
|
320
|
-
assert.equal('^7.3
|
321
|
-
assert.equal('^3.
|
327
|
+
assert.equal('^7.5.3', packageDotJson.dependencies.semver);
|
328
|
+
assert.equal('^3.9.0', packageDotJson.dependencies.winston);
|
322
329
|
done();
|
323
330
|
} catch (error) {
|
324
331
|
log.error(`Test Failure: ${error}`);
|
@@ -331,13 +338,12 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
331
338
|
assert.notEqual(undefined, packageDotJson.devDependencies);
|
332
339
|
assert.notEqual(null, packageDotJson.devDependencies);
|
333
340
|
assert.notEqual('', packageDotJson.devDependencies);
|
334
|
-
assert.equal('^4.3.
|
335
|
-
assert.equal('^
|
336
|
-
assert.equal('^
|
337
|
-
assert.equal('^2.
|
338
|
-
assert.equal('^3.
|
339
|
-
assert.equal('^
|
340
|
-
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);
|
341
347
|
done();
|
342
348
|
} catch (error) {
|
343
349
|
log.error(`Test Failure: ${error}`);
|
@@ -381,16 +387,30 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
381
387
|
assert.equal(true, Array.isArray(pronghornDotJson.methods));
|
382
388
|
assert.notEqual(0, pronghornDotJson.methods.length);
|
383
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'));
|
384
393
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapFindAdapterPath'));
|
385
394
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapTroubleshootAdapter'));
|
386
395
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterHealthcheck'));
|
387
396
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterConnectivity'));
|
388
397
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterBasicGet'));
|
389
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
390
|
-
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === '
|
391
|
-
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'));
|
392
409
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'genericAdapterRequest'));
|
393
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'));
|
394
414
|
done();
|
395
415
|
} catch (error) {
|
396
416
|
log.error(`Test Failure: ${error}`);
|
@@ -511,6 +531,39 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
511
531
|
done(error);
|
512
532
|
}
|
513
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
|
+
});
|
514
567
|
});
|
515
568
|
|
516
569
|
describe('propertiesSchema.json', () => {
|
@@ -546,6 +599,7 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
546
599
|
assert.equal('string', propertiesDotJson.properties.host.type);
|
547
600
|
assert.equal('integer', propertiesDotJson.properties.port.type);
|
548
601
|
assert.equal('boolean', propertiesDotJson.properties.stub.type);
|
602
|
+
assert.equal('string', propertiesDotJson.properties.protocol.type);
|
549
603
|
assert.notEqual(undefined, propertiesDotJson.definitions.authentication);
|
550
604
|
assert.notEqual(null, propertiesDotJson.definitions.authentication);
|
551
605
|
assert.notEqual('', propertiesDotJson.definitions.authentication);
|
@@ -579,7 +633,6 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
579
633
|
assert.equal('boolean', propertiesDotJson.properties.encode_pathvars.type);
|
580
634
|
assert.equal('boolean', propertiesDotJson.properties.encode_queryvars.type);
|
581
635
|
assert.equal(true, Array.isArray(propertiesDotJson.properties.save_metric.type));
|
582
|
-
assert.equal('string', propertiesDotJson.properties.protocol.type);
|
583
636
|
assert.notEqual(undefined, propertiesDotJson.definitions);
|
584
637
|
assert.notEqual(null, propertiesDotJson.definitions);
|
585
638
|
assert.notEqual('', propertiesDotJson.definitions);
|
@@ -736,6 +789,7 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
736
789
|
assert.notEqual(undefined, sampleDotJson.properties.host);
|
737
790
|
assert.notEqual(undefined, sampleDotJson.properties.port);
|
738
791
|
assert.notEqual(undefined, sampleDotJson.properties.stub);
|
792
|
+
assert.notEqual(undefined, sampleDotJson.properties.protocol);
|
739
793
|
assert.notEqual(undefined, sampleDotJson.properties.authentication);
|
740
794
|
assert.notEqual(null, sampleDotJson.properties.authentication);
|
741
795
|
assert.notEqual('', sampleDotJson.properties.authentication);
|
@@ -769,7 +823,6 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
769
823
|
assert.notEqual(undefined, sampleDotJson.properties.encode_pathvars);
|
770
824
|
assert.notEqual(undefined, sampleDotJson.properties.encode_queryvars);
|
771
825
|
assert.notEqual(undefined, sampleDotJson.properties.save_metric);
|
772
|
-
assert.notEqual(undefined, sampleDotJson.properties.protocol);
|
773
826
|
assert.notEqual(undefined, sampleDotJson.properties.healthcheck);
|
774
827
|
assert.notEqual(null, sampleDotJson.properties.healthcheck);
|
775
828
|
assert.notEqual('', sampleDotJson.properties.healthcheck);
|
@@ -939,40 +992,6 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
939
992
|
});
|
940
993
|
});
|
941
994
|
|
942
|
-
describe('#iapFindAdapterPath', () => {
|
943
|
-
it('should have a iapFindAdapterPath function', (done) => {
|
944
|
-
try {
|
945
|
-
assert.equal(true, typeof a.iapFindAdapterPath === 'function');
|
946
|
-
done();
|
947
|
-
} catch (error) {
|
948
|
-
log.error(`Test Failure: ${error}`);
|
949
|
-
done(error);
|
950
|
-
}
|
951
|
-
});
|
952
|
-
it('iapFindAdapterPath should find atleast one path that matches', (done) => {
|
953
|
-
try {
|
954
|
-
a.iapFindAdapterPath('{base_path}/{version}', (data, error) => {
|
955
|
-
try {
|
956
|
-
assert.equal(undefined, error);
|
957
|
-
assert.notEqual(undefined, data);
|
958
|
-
assert.notEqual(null, data);
|
959
|
-
assert.equal(true, data.found);
|
960
|
-
assert.notEqual(undefined, data.foundIn);
|
961
|
-
assert.notEqual(null, data.foundIn);
|
962
|
-
assert.notEqual(0, data.foundIn.length);
|
963
|
-
done();
|
964
|
-
} catch (err) {
|
965
|
-
log.error(`Test Failure: ${err}`);
|
966
|
-
done(err);
|
967
|
-
}
|
968
|
-
});
|
969
|
-
} catch (error) {
|
970
|
-
log.error(`Adapter Exception: ${error}`);
|
971
|
-
done(error);
|
972
|
-
}
|
973
|
-
}).timeout(attemptTimeout);
|
974
|
-
});
|
975
|
-
|
976
995
|
describe('#iapSuspendAdapter', () => {
|
977
996
|
it('should have a iapSuspendAdapter function', (done) => {
|
978
997
|
try {
|
@@ -1009,6 +1028,40 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1009
1028
|
});
|
1010
1029
|
});
|
1011
1030
|
|
1031
|
+
describe('#iapFindAdapterPath', () => {
|
1032
|
+
it('should have a iapFindAdapterPath function', (done) => {
|
1033
|
+
try {
|
1034
|
+
assert.equal(true, typeof a.iapFindAdapterPath === 'function');
|
1035
|
+
done();
|
1036
|
+
} catch (error) {
|
1037
|
+
log.error(`Test Failure: ${error}`);
|
1038
|
+
done(error);
|
1039
|
+
}
|
1040
|
+
});
|
1041
|
+
it('iapFindAdapterPath should find atleast one path that matches', (done) => {
|
1042
|
+
try {
|
1043
|
+
a.iapFindAdapterPath('{base_path}/{version}', (data, error) => {
|
1044
|
+
try {
|
1045
|
+
assert.equal(undefined, error);
|
1046
|
+
assert.notEqual(undefined, data);
|
1047
|
+
assert.notEqual(null, data);
|
1048
|
+
assert.equal(true, data.found);
|
1049
|
+
assert.notEqual(undefined, data.foundIn);
|
1050
|
+
assert.notEqual(null, data.foundIn);
|
1051
|
+
assert.notEqual(0, data.foundIn.length);
|
1052
|
+
done();
|
1053
|
+
} catch (err) {
|
1054
|
+
log.error(`Test Failure: ${err}`);
|
1055
|
+
done(err);
|
1056
|
+
}
|
1057
|
+
});
|
1058
|
+
} catch (error) {
|
1059
|
+
log.error(`Adapter Exception: ${error}`);
|
1060
|
+
done(error);
|
1061
|
+
}
|
1062
|
+
}).timeout(attemptTimeout);
|
1063
|
+
});
|
1064
|
+
|
1012
1065
|
describe('#iapTroubleshootAdapter', () => {
|
1013
1066
|
it('should have a iapTroubleshootAdapter function', (done) => {
|
1014
1067
|
try {
|
@@ -1154,49 +1207,53 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1154
1207
|
}).timeout(attemptTimeout);
|
1155
1208
|
});
|
1156
1209
|
|
1157
|
-
|
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
|
-
|
1210
|
+
describe('#iapDeactivateTasks', () => {
|
1211
|
+
it('should have a iapDeactivateTasks function', (done) => {
|
1212
|
+
try {
|
1213
|
+
assert.equal(true, typeof a.iapDeactivateTasks === 'function');
|
1214
|
+
done();
|
1215
|
+
} catch (error) {
|
1216
|
+
log.error(`Test Failure: ${error}`);
|
1217
|
+
done(error);
|
1218
|
+
}
|
1219
|
+
});
|
1220
|
+
});
|
1221
|
+
|
1222
|
+
describe('#iapActivateTasks', () => {
|
1223
|
+
it('should have a iapActivateTasks function', (done) => {
|
1224
|
+
try {
|
1225
|
+
assert.equal(true, typeof a.iapActivateTasks === 'function');
|
1226
|
+
done();
|
1227
|
+
} catch (error) {
|
1228
|
+
log.error(`Test Failure: ${error}`);
|
1229
|
+
done(error);
|
1230
|
+
}
|
1231
|
+
});
|
1232
|
+
});
|
1233
|
+
|
1234
|
+
describe('#iapPopulateEntityCache', () => {
|
1235
|
+
it('should have a iapPopulateEntityCache function', (done) => {
|
1236
|
+
try {
|
1237
|
+
assert.equal(true, typeof a.iapPopulateEntityCache === 'function');
|
1238
|
+
done();
|
1239
|
+
} catch (error) {
|
1240
|
+
log.error(`Test Failure: ${error}`);
|
1241
|
+
done(error);
|
1242
|
+
}
|
1243
|
+
});
|
1244
|
+
});
|
1245
|
+
|
1246
|
+
describe('#iapRetrieveEntitiesCache', () => {
|
1247
|
+
it('should have a iapRetrieveEntitiesCache function', (done) => {
|
1248
|
+
try {
|
1249
|
+
assert.equal(true, typeof a.iapRetrieveEntitiesCache === 'function');
|
1250
|
+
done();
|
1251
|
+
} catch (error) {
|
1252
|
+
log.error(`Test Failure: ${error}`);
|
1253
|
+
done(error);
|
1254
|
+
}
|
1255
|
+
});
|
1256
|
+
});
|
1200
1257
|
|
1201
1258
|
describe('#hasEntities', () => {
|
1202
1259
|
it('should have a hasEntities function', (done) => {
|
@@ -1270,6 +1327,169 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1270
1327
|
});
|
1271
1328
|
});
|
1272
1329
|
|
1330
|
+
describe('#iapExpandedGenericAdapterRequest', () => {
|
1331
|
+
it('should have a iapExpandedGenericAdapterRequest function', (done) => {
|
1332
|
+
try {
|
1333
|
+
assert.equal(true, typeof a.iapExpandedGenericAdapterRequest === 'function');
|
1334
|
+
done();
|
1335
|
+
} catch (error) {
|
1336
|
+
log.error(`Test Failure: ${error}`);
|
1337
|
+
done(error);
|
1338
|
+
}
|
1339
|
+
});
|
1340
|
+
});
|
1341
|
+
|
1342
|
+
describe('#genericAdapterRequest', () => {
|
1343
|
+
it('should have a genericAdapterRequest function', (done) => {
|
1344
|
+
try {
|
1345
|
+
assert.equal(true, typeof a.genericAdapterRequest === 'function');
|
1346
|
+
done();
|
1347
|
+
} catch (error) {
|
1348
|
+
log.error(`Test Failure: ${error}`);
|
1349
|
+
done(error);
|
1350
|
+
}
|
1351
|
+
});
|
1352
|
+
});
|
1353
|
+
|
1354
|
+
describe('#genericAdapterRequestNoBasePath', () => {
|
1355
|
+
it('should have a genericAdapterRequestNoBasePath function', (done) => {
|
1356
|
+
try {
|
1357
|
+
assert.equal(true, typeof a.genericAdapterRequestNoBasePath === 'function');
|
1358
|
+
done();
|
1359
|
+
} catch (error) {
|
1360
|
+
log.error(`Test Failure: ${error}`);
|
1361
|
+
done(error);
|
1362
|
+
}
|
1363
|
+
});
|
1364
|
+
});
|
1365
|
+
|
1366
|
+
describe('#iapRunAdapterLint', () => {
|
1367
|
+
it('should have a iapRunAdapterLint function', (done) => {
|
1368
|
+
try {
|
1369
|
+
assert.equal(true, typeof a.iapRunAdapterLint === 'function');
|
1370
|
+
done();
|
1371
|
+
} catch (error) {
|
1372
|
+
log.error(`Test Failure: ${error}`);
|
1373
|
+
done(error);
|
1374
|
+
}
|
1375
|
+
});
|
1376
|
+
it('retrieve the lint results', (done) => {
|
1377
|
+
try {
|
1378
|
+
a.iapRunAdapterLint((data, error) => {
|
1379
|
+
try {
|
1380
|
+
assert.equal(undefined, error);
|
1381
|
+
assert.notEqual(undefined, data);
|
1382
|
+
assert.notEqual(null, data);
|
1383
|
+
assert.notEqual(undefined, data.status);
|
1384
|
+
assert.notEqual(null, data.status);
|
1385
|
+
assert.equal('SUCCESS', data.status);
|
1386
|
+
done();
|
1387
|
+
} catch (err) {
|
1388
|
+
log.error(`Test Failure: ${err}`);
|
1389
|
+
done(err);
|
1390
|
+
}
|
1391
|
+
});
|
1392
|
+
} catch (error) {
|
1393
|
+
log.error(`Adapter Exception: ${error}`);
|
1394
|
+
done(error);
|
1395
|
+
}
|
1396
|
+
}).timeout(attemptTimeout);
|
1397
|
+
});
|
1398
|
+
|
1399
|
+
describe('#iapRunAdapterTests', () => {
|
1400
|
+
it('should have a iapRunAdapterTests function', (done) => {
|
1401
|
+
try {
|
1402
|
+
assert.equal(true, typeof a.iapRunAdapterTests === 'function');
|
1403
|
+
done();
|
1404
|
+
} catch (error) {
|
1405
|
+
log.error(`Test Failure: ${error}`);
|
1406
|
+
done(error);
|
1407
|
+
}
|
1408
|
+
});
|
1409
|
+
});
|
1410
|
+
|
1411
|
+
describe('#iapGetAdapterInventory', () => {
|
1412
|
+
it('should have a iapGetAdapterInventory function', (done) => {
|
1413
|
+
try {
|
1414
|
+
assert.equal(true, typeof a.iapGetAdapterInventory === 'function');
|
1415
|
+
done();
|
1416
|
+
} catch (error) {
|
1417
|
+
log.error(`Test Failure: ${error}`);
|
1418
|
+
done(error);
|
1419
|
+
}
|
1420
|
+
});
|
1421
|
+
it('retrieve the inventory', (done) => {
|
1422
|
+
try {
|
1423
|
+
a.iapGetAdapterInventory((data, error) => {
|
1424
|
+
try {
|
1425
|
+
assert.equal(undefined, error);
|
1426
|
+
assert.notEqual(undefined, data);
|
1427
|
+
assert.notEqual(null, data);
|
1428
|
+
done();
|
1429
|
+
} catch (err) {
|
1430
|
+
log.error(`Test Failure: ${err}`);
|
1431
|
+
done(err);
|
1432
|
+
}
|
1433
|
+
});
|
1434
|
+
} catch (error) {
|
1435
|
+
log.error(`Adapter Exception: ${error}`);
|
1436
|
+
done(error);
|
1437
|
+
}
|
1438
|
+
}).timeout(attemptTimeout);
|
1439
|
+
});
|
1440
|
+
describe('metadata.json', () => {
|
1441
|
+
it('should have a metadata.json', (done) => {
|
1442
|
+
try {
|
1443
|
+
fs.exists('metadata.json', (val) => {
|
1444
|
+
assert.equal(true, val);
|
1445
|
+
done();
|
1446
|
+
});
|
1447
|
+
} catch (error) {
|
1448
|
+
log.error(`Test Failure: ${error}`);
|
1449
|
+
done(error);
|
1450
|
+
}
|
1451
|
+
});
|
1452
|
+
it('metadata.json is customized', (done) => {
|
1453
|
+
try {
|
1454
|
+
const metadataDotJson = require('../../metadata.json');
|
1455
|
+
assert.equal('adapter-meraki', metadataDotJson.name);
|
1456
|
+
done();
|
1457
|
+
} catch (error) {
|
1458
|
+
log.error(`Test Failure: ${error}`);
|
1459
|
+
done(error);
|
1460
|
+
}
|
1461
|
+
});
|
1462
|
+
it('metadata.json contains accurate documentation', (done) => {
|
1463
|
+
try {
|
1464
|
+
const metadataDotJson = require('../../metadata.json');
|
1465
|
+
assert.notEqual(undefined, metadataDotJson.documentation);
|
1466
|
+
assert.equal('https://www.npmjs.com/package/@itentialopensource/adapter-meraki', metadataDotJson.documentation.npmLink);
|
1467
|
+
assert.equal('https://docs.itential.com/opensource/docs/troubleshooting-an-adapter', metadataDotJson.documentation.faqLink);
|
1468
|
+
assert.equal('https://gitlab.com/itentialopensource/adapters/contributing-guide', metadataDotJson.documentation.contributeLink);
|
1469
|
+
assert.equal('https://itential.atlassian.net/servicedesk/customer/portals', metadataDotJson.documentation.issueLink);
|
1470
|
+
done();
|
1471
|
+
} catch (error) {
|
1472
|
+
log.error(`Test Failure: ${error}`);
|
1473
|
+
done(error);
|
1474
|
+
}
|
1475
|
+
});
|
1476
|
+
it('metadata.json has related items', (done) => {
|
1477
|
+
try {
|
1478
|
+
const metadataDotJson = require('../../metadata.json');
|
1479
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems);
|
1480
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems.adapters);
|
1481
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems.integrations);
|
1482
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems.ecosystemApplications);
|
1483
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems.automations);
|
1484
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems.transformations);
|
1485
|
+
assert.notEqual(undefined, metadataDotJson.relatedItems.useCases);
|
1486
|
+
done();
|
1487
|
+
} catch (error) {
|
1488
|
+
log.error(`Test Failure: ${error}`);
|
1489
|
+
done(error);
|
1490
|
+
}
|
1491
|
+
});
|
1492
|
+
});
|
1273
1493
|
/*
|
1274
1494
|
-----------------------------------------------------------------------
|
1275
1495
|
-----------------------------------------------------------------------
|
package/utils/entitiesToDB.js
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
/* eslint global-require: warn */
|
8
8
|
/* eslint no-unused-vars: warn */
|
9
9
|
/* eslint import/no-unresolved: warn */
|
10
|
+
/* eslint no-promise-executor-return: warn */
|
10
11
|
|
11
12
|
/**
|
12
13
|
* This script is used to read through an adapter's entities files
|
@@ -164,8 +165,7 @@ const moveEntitiesToDB = async (targetPath, options) => {
|
|
164
165
|
});
|
165
166
|
|
166
167
|
// Upload documents to db collection
|
167
|
-
const
|
168
|
-
const db = await utils.connect(iapDir, currentProps).catch((err) => { console.error(err); throw err; });
|
168
|
+
const db = await utils.connect(currentProps).catch((err) => { console.error(err); throw err; });
|
169
169
|
if (!db) {
|
170
170
|
console.error('Error occured when connectiong to database', currentProps);
|
171
171
|
throw new Error('Database not found');
|