@itentialopensource/adapter-netbox 0.8.0 → 0.11.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 +9 -15
- package/CALLS.md +2447 -22
- package/CHANGELOG.md +24 -0
- package/CONTRIBUTING.md +1 -160
- package/ENHANCE.md +2 -2
- package/README.md +32 -23
- package/SYSTEMINFO.md +12 -3
- package/adapter.js +2483 -1839
- package/adapterBase.js +549 -879
- package/changelogs/changelog.md +181 -0
- package/entities/Dcim/action.json +182 -0
- package/entities/Dcim/mockdatafiles/getDcimLocations-default.json +688 -0
- package/entities/Dcim/schema.json +82 -19
- package/metadata.json +69 -0
- package/package.json +24 -24
- package/pronghorn.json +15221 -12889
- package/propertiesSchema.json +422 -31
- package/refs?service=git-upload-pack +0 -0
- package/report/adapter-openapi.json +52536 -0
- package/report/adapter-openapi.yaml +37346 -0
- package/report/adapterInfo.json +8 -8
- package/report/updateReport1691508495299.json +120 -0
- package/report/updateReport1692202980865.json +120 -0
- package/report/updateReport1694466470665.json +120 -0
- package/sampleProperties.json +65 -4
- package/test/integration/adapterTestBasicGet.js +2 -4
- package/test/integration/adapterTestConnectivity.js +91 -42
- package/test/integration/adapterTestIntegration.js +383 -2
- package/test/unit/adapterBaseTestUnit.js +388 -313
- package/test/unit/adapterTestUnit.js +599 -112
- 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 +260 -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
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
// include required items for testing & logging
|
|
10
10
|
const assert = require('assert');
|
|
11
11
|
const fs = require('fs');
|
|
12
|
-
const mocha = require('mocha');
|
|
13
12
|
const path = require('path');
|
|
13
|
+
const util = require('util');
|
|
14
|
+
const mocha = require('mocha');
|
|
14
15
|
const winston = require('winston');
|
|
15
16
|
const { expect } = require('chai');
|
|
16
17
|
const { use } = require('chai');
|
|
17
18
|
const td = require('testdouble');
|
|
18
|
-
const util = require('util');
|
|
19
19
|
|
|
20
20
|
const anything = td.matchers.anything();
|
|
21
21
|
|
|
@@ -335,6 +335,134 @@ describe('[integration] Netbox Adapter Test', () => {
|
|
|
335
335
|
}).timeout(attemptTimeout);
|
|
336
336
|
});
|
|
337
337
|
|
|
338
|
+
// broker tests
|
|
339
|
+
describe('#getDevicesFiltered - errors', () => {
|
|
340
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
341
|
+
try {
|
|
342
|
+
const opts = {
|
|
343
|
+
filter: {
|
|
344
|
+
name: 'deviceName'
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
a.getDevicesFiltered(opts, (data, error) => {
|
|
348
|
+
try {
|
|
349
|
+
if (stub) {
|
|
350
|
+
if (samProps.devicebroker.getDevicesFiltered[0].handleFailure === 'ignore') {
|
|
351
|
+
assert.equal(null, error);
|
|
352
|
+
assert.notEqual(undefined, data);
|
|
353
|
+
assert.notEqual(null, data);
|
|
354
|
+
assert.equal(0, data.total);
|
|
355
|
+
assert.equal(0, data.list.length);
|
|
356
|
+
} else {
|
|
357
|
+
const displayE = 'Error 400 received on request';
|
|
358
|
+
runErrorAsserts(data, error, 'AD.500', 'Test-netbox-connectorRest-handleEndResponse', displayE);
|
|
359
|
+
}
|
|
360
|
+
} else {
|
|
361
|
+
runCommonAsserts(data, error);
|
|
362
|
+
}
|
|
363
|
+
done();
|
|
364
|
+
} catch (err) {
|
|
365
|
+
log.error(`Test Failure: ${err}`);
|
|
366
|
+
done(err);
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
} catch (error) {
|
|
370
|
+
log.error(`Adapter Exception: ${error}`);
|
|
371
|
+
done(error);
|
|
372
|
+
}
|
|
373
|
+
}).timeout(attemptTimeout);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
describe('#iapGetDeviceCount - errors', () => {
|
|
377
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
378
|
+
try {
|
|
379
|
+
const opts = {
|
|
380
|
+
filter: {
|
|
381
|
+
name: 'deviceName'
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
a.iapGetDeviceCount((data, error) => {
|
|
385
|
+
try {
|
|
386
|
+
if (stub) {
|
|
387
|
+
if (samProps.devicebroker.getDevicesFiltered[0].handleFailure === 'ignore') {
|
|
388
|
+
assert.equal(null, error);
|
|
389
|
+
assert.notEqual(undefined, data);
|
|
390
|
+
assert.notEqual(null, data);
|
|
391
|
+
assert.equal(0, data.count);
|
|
392
|
+
} else {
|
|
393
|
+
const displayE = 'Error 400 received on request';
|
|
394
|
+
runErrorAsserts(data, error, 'AD.500', 'Test-netbox-connectorRest-handleEndResponse', displayE);
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
runCommonAsserts(data, error);
|
|
398
|
+
}
|
|
399
|
+
done();
|
|
400
|
+
} catch (err) {
|
|
401
|
+
log.error(`Test Failure: ${err}`);
|
|
402
|
+
done(err);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
} catch (error) {
|
|
406
|
+
log.error(`Adapter Exception: ${error}`);
|
|
407
|
+
done(error);
|
|
408
|
+
}
|
|
409
|
+
}).timeout(attemptTimeout);
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// exposed cache tests
|
|
413
|
+
describe('#iapPopulateEntityCache - errors', () => {
|
|
414
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
415
|
+
try {
|
|
416
|
+
a.iapPopulateEntityCache('Device', (data, error) => {
|
|
417
|
+
try {
|
|
418
|
+
if (stub) {
|
|
419
|
+
assert.equal(null, data);
|
|
420
|
+
assert.notEqual(undefined, error);
|
|
421
|
+
assert.notEqual(null, error);
|
|
422
|
+
done();
|
|
423
|
+
} else {
|
|
424
|
+
assert.equal(undefined, error);
|
|
425
|
+
assert.equal('success', data[0]);
|
|
426
|
+
done();
|
|
427
|
+
}
|
|
428
|
+
} catch (err) {
|
|
429
|
+
log.error(`Test Failure: ${err}`);
|
|
430
|
+
done(err);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
} catch (error) {
|
|
434
|
+
log.error(`Adapter Exception: ${error}`);
|
|
435
|
+
done(error);
|
|
436
|
+
}
|
|
437
|
+
}).timeout(attemptTimeout);
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
describe('#iapRetrieveEntitiesCache - errors', () => {
|
|
441
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
442
|
+
try {
|
|
443
|
+
a.iapRetrieveEntitiesCache('Device', {}, (data, error) => {
|
|
444
|
+
try {
|
|
445
|
+
if (stub) {
|
|
446
|
+
assert.equal(null, data);
|
|
447
|
+
assert.notEqual(null, error);
|
|
448
|
+
assert.notEqual(undefined, error);
|
|
449
|
+
} else {
|
|
450
|
+
assert.equal(undefined, error);
|
|
451
|
+
assert.notEqual(null, data);
|
|
452
|
+
assert.notEqual(undefined, data);
|
|
453
|
+
}
|
|
454
|
+
done();
|
|
455
|
+
} catch (err) {
|
|
456
|
+
log.error(`Test Failure: ${err}`);
|
|
457
|
+
done(err);
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
} catch (error) {
|
|
461
|
+
log.error(`Adapter Exception: ${error}`);
|
|
462
|
+
done(error);
|
|
463
|
+
}
|
|
464
|
+
}).timeout(attemptTimeout);
|
|
465
|
+
});
|
|
338
466
|
/*
|
|
339
467
|
-----------------------------------------------------------------------
|
|
340
468
|
-----------------------------------------------------------------------
|
|
@@ -12250,5 +12378,258 @@ describe('[integration] Netbox Adapter Test', () => {
|
|
|
12250
12378
|
}
|
|
12251
12379
|
}).timeout(attemptTimeout);
|
|
12252
12380
|
});
|
|
12381
|
+
|
|
12382
|
+
describe('#getDcimLocations - errors', () => {
|
|
12383
|
+
it('should work if integrated or standalone with mockdata', (done) => {
|
|
12384
|
+
try {
|
|
12385
|
+
a.getDcimLocations(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, (data, error) => {
|
|
12386
|
+
try {
|
|
12387
|
+
if (stub) {
|
|
12388
|
+
runCommonAsserts(data, error);
|
|
12389
|
+
assert.equal(1, data.response.count);
|
|
12390
|
+
assert.equal('string', data.response.next);
|
|
12391
|
+
assert.equal('string', data.response.previous);
|
|
12392
|
+
assert.equal(true, Array.isArray(data.response.results));
|
|
12393
|
+
} else {
|
|
12394
|
+
runCommonAsserts(data, error);
|
|
12395
|
+
}
|
|
12396
|
+
saveMockData('Dcim', 'getDcimLocations', 'default', data);
|
|
12397
|
+
done();
|
|
12398
|
+
} catch (err) {
|
|
12399
|
+
log.error(`Test Failure: ${err}`);
|
|
12400
|
+
done(err);
|
|
12401
|
+
}
|
|
12402
|
+
});
|
|
12403
|
+
} catch (error) {
|
|
12404
|
+
log.error(`Adapter Exception: ${error}`);
|
|
12405
|
+
done(error);
|
|
12406
|
+
}
|
|
12407
|
+
}).timeout(attemptTimeout);
|
|
12408
|
+
});
|
|
12409
|
+
|
|
12410
|
+
const dcimPostDcimLocationsBodyParam = {
|
|
12411
|
+
name: 'string',
|
|
12412
|
+
slug: 'string',
|
|
12413
|
+
site: 1
|
|
12414
|
+
};
|
|
12415
|
+
describe('#postDcimLocations - errors', () => {
|
|
12416
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
12417
|
+
try {
|
|
12418
|
+
a.postDcimLocations(dcimPostDcimLocationsBodyParam, (data, error) => {
|
|
12419
|
+
try {
|
|
12420
|
+
if (stub) {
|
|
12421
|
+
const displayE = 'Error 400 received on request';
|
|
12422
|
+
runErrorAsserts(data, error, 'AD.500', 'Test-netbox-connectorRest-handleEndResponse', displayE);
|
|
12423
|
+
} else {
|
|
12424
|
+
runCommonAsserts(data, error);
|
|
12425
|
+
}
|
|
12426
|
+
saveMockData('Dcim', 'postDcimLocations', 'default', data);
|
|
12427
|
+
done();
|
|
12428
|
+
} catch (err) {
|
|
12429
|
+
log.error(`Test Failure: ${err}`);
|
|
12430
|
+
done(err);
|
|
12431
|
+
}
|
|
12432
|
+
});
|
|
12433
|
+
} catch (error) {
|
|
12434
|
+
log.error(`Adapter Exception: ${error}`);
|
|
12435
|
+
done(error);
|
|
12436
|
+
}
|
|
12437
|
+
}).timeout(attemptTimeout);
|
|
12438
|
+
});
|
|
12439
|
+
|
|
12440
|
+
const dcimPutDcimLocationsBodyParam = {
|
|
12441
|
+
name: 'string',
|
|
12442
|
+
slug: 'string',
|
|
12443
|
+
site: 6
|
|
12444
|
+
};
|
|
12445
|
+
describe('#putDcimLocations - errors', () => {
|
|
12446
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
12447
|
+
try {
|
|
12448
|
+
a.putDcimLocations(dcimPutDcimLocationsBodyParam, (data, error) => {
|
|
12449
|
+
try {
|
|
12450
|
+
if (stub) {
|
|
12451
|
+
const displayE = 'Error 400 received on request';
|
|
12452
|
+
runErrorAsserts(data, error, 'AD.500', 'Test-netbox-connectorRest-handleEndResponse', displayE);
|
|
12453
|
+
} else {
|
|
12454
|
+
runCommonAsserts(data, error);
|
|
12455
|
+
}
|
|
12456
|
+
saveMockData('Dcim', 'putDcimLocations', 'default', data);
|
|
12457
|
+
done();
|
|
12458
|
+
} catch (err) {
|
|
12459
|
+
log.error(`Test Failure: ${err}`);
|
|
12460
|
+
done(err);
|
|
12461
|
+
}
|
|
12462
|
+
});
|
|
12463
|
+
} catch (error) {
|
|
12464
|
+
log.error(`Adapter Exception: ${error}`);
|
|
12465
|
+
done(error);
|
|
12466
|
+
}
|
|
12467
|
+
}).timeout(attemptTimeout);
|
|
12468
|
+
});
|
|
12469
|
+
|
|
12470
|
+
const dcimPatchDcimLocationsBodyParam = {
|
|
12471
|
+
name: 'string',
|
|
12472
|
+
slug: 'string',
|
|
12473
|
+
site: 7
|
|
12474
|
+
};
|
|
12475
|
+
describe('#patchDcimLocations - errors', () => {
|
|
12476
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
12477
|
+
try {
|
|
12478
|
+
a.patchDcimLocations(dcimPatchDcimLocationsBodyParam, (data, error) => {
|
|
12479
|
+
try {
|
|
12480
|
+
if (stub) {
|
|
12481
|
+
const displayE = 'Error 400 received on request';
|
|
12482
|
+
runErrorAsserts(data, error, 'AD.500', 'Test-netbox-connectorRest-handleEndResponse', displayE);
|
|
12483
|
+
} else {
|
|
12484
|
+
runCommonAsserts(data, error);
|
|
12485
|
+
}
|
|
12486
|
+
saveMockData('Dcim', 'patchDcimLocations', 'default', data);
|
|
12487
|
+
done();
|
|
12488
|
+
} catch (err) {
|
|
12489
|
+
log.error(`Test Failure: ${err}`);
|
|
12490
|
+
done(err);
|
|
12491
|
+
}
|
|
12492
|
+
});
|
|
12493
|
+
} catch (error) {
|
|
12494
|
+
log.error(`Adapter Exception: ${error}`);
|
|
12495
|
+
done(error);
|
|
12496
|
+
}
|
|
12497
|
+
}).timeout(attemptTimeout);
|
|
12498
|
+
});
|
|
12499
|
+
|
|
12500
|
+
describe('#deleteDcimLocations - errors', () => {
|
|
12501
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
12502
|
+
try {
|
|
12503
|
+
a.deleteDcimLocations((data, error) => {
|
|
12504
|
+
try {
|
|
12505
|
+
if (stub) {
|
|
12506
|
+
const displayE = 'Error 400 received on request';
|
|
12507
|
+
runErrorAsserts(data, error, 'AD.500', 'Test-netbox-connectorRest-handleEndResponse', displayE);
|
|
12508
|
+
} else {
|
|
12509
|
+
runCommonAsserts(data, error);
|
|
12510
|
+
}
|
|
12511
|
+
saveMockData('Dcim', 'deleteDcimLocations', 'default', data);
|
|
12512
|
+
done();
|
|
12513
|
+
} catch (err) {
|
|
12514
|
+
log.error(`Test Failure: ${err}`);
|
|
12515
|
+
done(err);
|
|
12516
|
+
}
|
|
12517
|
+
});
|
|
12518
|
+
} catch (error) {
|
|
12519
|
+
log.error(`Adapter Exception: ${error}`);
|
|
12520
|
+
done(error);
|
|
12521
|
+
}
|
|
12522
|
+
}).timeout(attemptTimeout);
|
|
12523
|
+
});
|
|
12524
|
+
|
|
12525
|
+
describe('#getDcimLocationsId - errors', () => {
|
|
12526
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
12527
|
+
try {
|
|
12528
|
+
a.getDcimLocationsId(555, (data, error) => {
|
|
12529
|
+
try {
|
|
12530
|
+
if (stub) {
|
|
12531
|
+
const displayE = 'Error 400 received on request';
|
|
12532
|
+
runErrorAsserts(data, error, 'AD.500', 'Test-netbox-connectorRest-handleEndResponse', displayE);
|
|
12533
|
+
} else {
|
|
12534
|
+
runCommonAsserts(data, error);
|
|
12535
|
+
}
|
|
12536
|
+
saveMockData('Dcim', 'getDcimLocationsId', 'default', data);
|
|
12537
|
+
done();
|
|
12538
|
+
} catch (err) {
|
|
12539
|
+
log.error(`Test Failure: ${err}`);
|
|
12540
|
+
done(err);
|
|
12541
|
+
}
|
|
12542
|
+
});
|
|
12543
|
+
} catch (error) {
|
|
12544
|
+
log.error(`Adapter Exception: ${error}`);
|
|
12545
|
+
done(error);
|
|
12546
|
+
}
|
|
12547
|
+
}).timeout(attemptTimeout);
|
|
12548
|
+
});
|
|
12549
|
+
|
|
12550
|
+
const dcimPutDcimLocationsIdBodyParam = {
|
|
12551
|
+
name: 'string',
|
|
12552
|
+
slug: 'string',
|
|
12553
|
+
site: 2
|
|
12554
|
+
};
|
|
12555
|
+
describe('#putDcimLocationsId - errors', () => {
|
|
12556
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
12557
|
+
try {
|
|
12558
|
+
a.putDcimLocationsId(555, dcimPutDcimLocationsIdBodyParam, (data, error) => {
|
|
12559
|
+
try {
|
|
12560
|
+
if (stub) {
|
|
12561
|
+
const displayE = 'Error 400 received on request';
|
|
12562
|
+
runErrorAsserts(data, error, 'AD.500', 'Test-netbox-connectorRest-handleEndResponse', displayE);
|
|
12563
|
+
} else {
|
|
12564
|
+
runCommonAsserts(data, error);
|
|
12565
|
+
}
|
|
12566
|
+
saveMockData('Dcim', 'putDcimLocationsId', 'default', data);
|
|
12567
|
+
done();
|
|
12568
|
+
} catch (err) {
|
|
12569
|
+
log.error(`Test Failure: ${err}`);
|
|
12570
|
+
done(err);
|
|
12571
|
+
}
|
|
12572
|
+
});
|
|
12573
|
+
} catch (error) {
|
|
12574
|
+
log.error(`Adapter Exception: ${error}`);
|
|
12575
|
+
done(error);
|
|
12576
|
+
}
|
|
12577
|
+
}).timeout(attemptTimeout);
|
|
12578
|
+
});
|
|
12579
|
+
|
|
12580
|
+
const dcimPatchDcimLocationsIdBodyParam = {
|
|
12581
|
+
name: 'string',
|
|
12582
|
+
slug: 'string',
|
|
12583
|
+
site: 9
|
|
12584
|
+
};
|
|
12585
|
+
describe('#patchDcimLocationsId - errors', () => {
|
|
12586
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
12587
|
+
try {
|
|
12588
|
+
a.patchDcimLocationsId(555, dcimPatchDcimLocationsIdBodyParam, (data, error) => {
|
|
12589
|
+
try {
|
|
12590
|
+
if (stub) {
|
|
12591
|
+
const displayE = 'Error 400 received on request';
|
|
12592
|
+
runErrorAsserts(data, error, 'AD.500', 'Test-netbox-connectorRest-handleEndResponse', displayE);
|
|
12593
|
+
} else {
|
|
12594
|
+
runCommonAsserts(data, error);
|
|
12595
|
+
}
|
|
12596
|
+
saveMockData('Dcim', 'patchDcimLocationsId', 'default', data);
|
|
12597
|
+
done();
|
|
12598
|
+
} catch (err) {
|
|
12599
|
+
log.error(`Test Failure: ${err}`);
|
|
12600
|
+
done(err);
|
|
12601
|
+
}
|
|
12602
|
+
});
|
|
12603
|
+
} catch (error) {
|
|
12604
|
+
log.error(`Adapter Exception: ${error}`);
|
|
12605
|
+
done(error);
|
|
12606
|
+
}
|
|
12607
|
+
}).timeout(attemptTimeout);
|
|
12608
|
+
});
|
|
12609
|
+
|
|
12610
|
+
describe('#deleteDcimLocationsId - errors', () => {
|
|
12611
|
+
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
|
|
12612
|
+
try {
|
|
12613
|
+
a.deleteDcimLocationsId(555, (data, error) => {
|
|
12614
|
+
try {
|
|
12615
|
+
if (stub) {
|
|
12616
|
+
const displayE = 'Error 400 received on request';
|
|
12617
|
+
runErrorAsserts(data, error, 'AD.500', 'Test-netbox-connectorRest-handleEndResponse', displayE);
|
|
12618
|
+
} else {
|
|
12619
|
+
runCommonAsserts(data, error);
|
|
12620
|
+
}
|
|
12621
|
+
saveMockData('Dcim', 'deleteDcimLocationsId', 'default', data);
|
|
12622
|
+
done();
|
|
12623
|
+
} catch (err) {
|
|
12624
|
+
log.error(`Test Failure: ${err}`);
|
|
12625
|
+
done(err);
|
|
12626
|
+
}
|
|
12627
|
+
});
|
|
12628
|
+
} catch (error) {
|
|
12629
|
+
log.error(`Adapter Exception: ${error}`);
|
|
12630
|
+
done(error);
|
|
12631
|
+
}
|
|
12632
|
+
}).timeout(attemptTimeout);
|
|
12633
|
+
});
|
|
12253
12634
|
});
|
|
12254
12635
|
});
|