@itentialopensource/adapter-aruba_airwave 0.2.1 → 0.3.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.
Files changed (60) hide show
  1. package/.eslintignore +0 -1
  2. package/.jshintrc +3 -0
  3. package/AUTH.md +39 -0
  4. package/BROKER.md +199 -0
  5. package/CALLS.md +349 -0
  6. package/CHANGELOG.md +8 -0
  7. package/CODE_OF_CONDUCT.md +12 -17
  8. package/CONTRIBUTING.md +3 -148
  9. package/ENHANCE.md +69 -0
  10. package/LICENSE +0 -0
  11. package/PROPERTIES.md +641 -0
  12. package/README.md +240 -438
  13. package/SUMMARY.md +9 -0
  14. package/SYSTEMINFO.md +11 -0
  15. package/TROUBLESHOOT.md +47 -0
  16. package/adapter.js +482 -226
  17. package/adapterBase.js +883 -337
  18. package/changelogs/changelog.md +24 -0
  19. package/entities/.generic/action.json +214 -0
  20. package/entities/.generic/schema.json +28 -0
  21. package/error.json +6 -0
  22. package/metadata.json +47 -0
  23. package/package.json +23 -25
  24. package/pronghorn.json +774 -34
  25. package/propertiesDecorators.json +14 -0
  26. package/propertiesSchema.json +866 -6
  27. package/refs?service=git-upload-pack +0 -0
  28. package/report/adapter-openapi.json +1583 -0
  29. package/report/adapter-openapi.yaml +1300 -0
  30. package/report/adapterInfo.json +10 -0
  31. package/report/updateReport1691507584816.json +120 -0
  32. package/report/updateReport1692202582785.json +120 -0
  33. package/report/updateReport1694461838457.json +120 -0
  34. package/report/updateReport1698420960460.json +120 -0
  35. package/sampleProperties.json +163 -4
  36. package/test/integration/adapterTestBasicGet.js +3 -5
  37. package/test/integration/adapterTestConnectivity.js +91 -42
  38. package/test/integration/adapterTestIntegration.js +157 -98
  39. package/test/unit/adapterBaseTestUnit.js +400 -305
  40. package/test/unit/adapterTestUnit.js +917 -158
  41. package/utils/adapterInfo.js +206 -0
  42. package/utils/addAuth.js +94 -0
  43. package/utils/artifactize.js +1 -1
  44. package/utils/basicGet.js +1 -14
  45. package/utils/checkMigrate.js +63 -0
  46. package/utils/entitiesToDB.js +179 -0
  47. package/utils/findPath.js +74 -0
  48. package/utils/methodDocumentor.js +273 -0
  49. package/utils/modify.js +152 -0
  50. package/utils/packModificationScript.js +1 -1
  51. package/utils/patches2bundledDeps.js +90 -0
  52. package/utils/pre-commit.sh +5 -0
  53. package/utils/removeHooks.js +20 -0
  54. package/utils/setup.js +0 -0
  55. package/utils/taskMover.js +309 -0
  56. package/utils/tbScript.js +129 -53
  57. package/utils/tbUtils.js +152 -35
  58. package/utils/testRunner.js +17 -17
  59. package/utils/troubleshootingAdapter.js +17 -43
  60. package/workflows/README.md +0 -3
@@ -5,9 +5,9 @@
5
5
 
6
6
  // include required items for testing & logging
7
7
  const assert = require('assert');
8
+ const path = require('path');
8
9
  const fs = require('fs-extra');
9
10
  const mocha = require('mocha');
10
- const path = require('path');
11
11
  const winston = require('winston');
12
12
  const { expect } = require('chai');
13
13
  const { use } = require('chai');
@@ -60,11 +60,16 @@ global.pronghornProps = {
60
60
  token_timeout: -1,
61
61
  token_cache: 'local',
62
62
  auth_field: 'header.headers.Authorization',
63
- auth_field_format: 'Basic {b64}{username}:{password}{/b64}'
63
+ auth_field_format: 'Basic {b64}{username}:{password}{/b64}',
64
+ auth_logging: false,
65
+ client_id: '',
66
+ client_secret: '',
67
+ grant_type: ''
64
68
  },
65
69
  healthcheck: {
66
70
  type: 'none',
67
- frequency: 60000
71
+ frequency: 60000,
72
+ query_object: {}
68
73
  },
69
74
  throttle: {
70
75
  throttle_enabled: false,
@@ -95,13 +100,16 @@ global.pronghornProps = {
95
100
  },
96
101
  healthcheck_on_timeout: true,
97
102
  return_raw: true,
98
- archiving: false
103
+ archiving: false,
104
+ return_request: false
99
105
  },
100
106
  proxy: {
101
107
  enabled: false,
102
108
  host: '',
103
109
  port: 1,
104
- protocol: 'http'
110
+ protocol: 'http',
111
+ username: '',
112
+ password: ''
105
113
  },
106
114
  ssl: {
107
115
  ecdhCurve: '',
@@ -297,90 +305,73 @@ describe('[unit] Adapter Base Test', () => {
297
305
  }).timeout(attemptTimeout);
298
306
  });
299
307
 
300
- describe('#getAllFunctions', () => {
301
- it('should have a getAllFunctions function', (done) => {
308
+ describe('#connect', () => {
309
+ it('should have a connect function', (done) => {
302
310
  try {
303
- assert.equal(true, typeof a.getAllFunctions === 'function');
311
+ assert.equal(true, typeof a.connect === 'function');
304
312
  done();
305
313
  } catch (error) {
306
314
  log.error(`Test Failure: ${error}`);
307
315
  done(error);
308
316
  }
309
317
  });
310
- it('should return a list of functions', (done) => {
311
- const returnedFunctions = ['addEntityCache', 'capabilityResults', 'checkActionFiles', 'checkProperties', 'connect', 'encryptProperty',
312
- 'entityInList', 'getAllCapabilities', 'getAllFunctions', 'getQueue', 'getWorkflowFunctions', 'healthCheck',
313
- 'refreshProperties', 'runBasicGet', 'runConnectivity', 'runHealthcheck', 'suspend', 'troubleshoot', 'unsuspend', 'updateAdapterConfiguration', 'addListener',
314
- 'emit', 'eventNames', 'getMaxListeners', 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener',
315
- 'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
318
+ it('should get connected - no healthcheck', (done) => {
316
319
  try {
317
- const expectedFunctions = a.getAllFunctions();
320
+ a.healthcheckType = 'none';
321
+ a.connect();
322
+
318
323
  try {
319
- assert.equal(JSON.stringify(expectedFunctions), JSON.stringify(returnedFunctions));
324
+ assert.equal(true, a.alive);
320
325
  done();
321
- } catch (err) {
322
- log.error(`Test Failure: ${err}`);
323
- done(err);
326
+ } catch (error) {
327
+ log.error(`Test Failure: ${error}`);
328
+ done(error);
324
329
  }
325
330
  } catch (error) {
326
331
  log.error(`Adapter Exception: ${error}`);
327
332
  done(error);
328
333
  }
329
- }).timeout(attemptTimeout);
330
- });
331
-
332
- describe('#getWorkflowFunctions', () => {
333
- it('should have a getWorkflowFunctions function', (done) => {
334
- try {
335
- assert.equal(true, typeof a.getWorkflowFunctions === 'function');
336
- done();
337
- } catch (error) {
338
- log.error(`Test Failure: ${error}`);
339
- done(error);
340
- }
341
334
  });
342
- it('should retrieve workflow functions', (done) => {
335
+ it('should get connected - startup healthcheck', (done) => {
343
336
  try {
344
- const expectedFunctions = a.getWorkflowFunctions([]);
337
+ a.healthcheckType = 'startup';
338
+ a.connect();
339
+
345
340
  try {
346
- assert.equal(0, expectedFunctions.length);
341
+ assert.equal(true, a.alive);
347
342
  done();
348
- } catch (err) {
349
- log.error(`Test Failure: ${err}`);
350
- done(err);
343
+ } catch (error) {
344
+ log.error(`Test Failure: ${error}`);
345
+ done(error);
351
346
  }
352
347
  } catch (error) {
353
348
  log.error(`Adapter Exception: ${error}`);
354
349
  done(error);
355
350
  }
356
- }).timeout(attemptTimeout);
351
+ });
357
352
  });
358
353
 
359
- describe('#checkProperties', () => {
360
- it('should have a checkProperties function', (done) => {
354
+ describe('#healthCheck', () => {
355
+ it('should have a healthCheck function', (done) => {
361
356
  try {
362
- assert.equal(true, typeof a.checkProperties === 'function');
357
+ assert.equal(true, typeof a.healthCheck === 'function');
363
358
  done();
364
359
  } catch (error) {
365
360
  log.error(`Test Failure: ${error}`);
366
361
  done(error);
367
362
  }
368
363
  });
369
- it('the sample properties should be good - if failure change the log level', (done) => {
364
+ it('should be healthy', (done) => {
370
365
  try {
371
- const samplePropsJson = require('../../sampleProperties.json');
372
- const clean = a.checkProperties(samplePropsJson.properties);
373
- try {
374
- assert.notEqual(0, Object.keys(clean));
375
- assert.equal(undefined, clean.exception);
376
- assert.notEqual(undefined, clean.host);
377
- assert.notEqual(null, clean.host);
378
- assert.notEqual('', clean.host);
379
- done();
380
- } catch (err) {
381
- log.error(`Test Failure: ${err}`);
382
- done(err);
383
- }
366
+ a.healthCheck(null, (data) => {
367
+ try {
368
+ assert.equal(true, a.healthy);
369
+ done();
370
+ } catch (err) {
371
+ log.error(`Test Failure: ${err}`);
372
+ done(err);
373
+ }
374
+ });
384
375
  } catch (error) {
385
376
  log.error(`Adapter Exception: ${error}`);
386
377
  done(error);
@@ -388,24 +379,28 @@ describe('[unit] Adapter Base Test', () => {
388
379
  }).timeout(attemptTimeout);
389
380
  });
390
381
 
391
- describe('#checkActionFiles', () => {
392
- it('should have a checkActionFiles function', (done) => {
382
+ describe('#getAllFunctions', () => {
383
+ it('should have a getAllFunctions function', (done) => {
393
384
  try {
394
- assert.equal(true, typeof a.checkActionFiles === 'function');
385
+ assert.equal(true, typeof a.getAllFunctions === 'function');
395
386
  done();
396
387
  } catch (error) {
397
388
  log.error(`Test Failure: ${error}`);
398
389
  done(error);
399
390
  }
400
391
  });
401
- it('the action files should be good - if failure change the log level as most issues are warnings', (done) => {
392
+ it('should return a list of functions', (done) => {
393
+ const returnedFunctions = ['checkActionFiles', 'checkProperties', 'connect', 'encryptProperty', 'genericAdapterRequest', 'genericAdapterRequestNoBasePath',
394
+ 'getAllFunctions', 'getConfig', 'getConfigAuth', 'getDevice', 'getDeviceAuth', 'getDevicesFiltered', 'getDevicesFilteredAuth', 'hasEntities', 'hasEntitiesAuth',
395
+ 'healthCheck', 'iapActivateTasks', 'iapDeactivateTasks', 'iapExpandedGenericAdapterRequest', 'iapFindAdapterPath', 'iapGetAdapterInventory', 'iapGetAdapterQueue',
396
+ 'iapGetAdapterWorkflowFunctions', 'iapGetDeviceCount', 'iapGetDeviceCountAuth', 'iapMoveAdapterEntitiesToDB', 'iapPopulateEntityCache', 'iapRetrieveEntitiesCache',
397
+ 'iapRunAdapterBasicGet', 'iapRunAdapterConnectivity', 'iapRunAdapterHealthcheck', 'iapRunAdapterLint', 'iapRunAdapterTests', 'iapSuspendAdapter', 'iapTroubleshootAdapter',
398
+ 'iapUnsuspendAdapter', 'iapUpdateAdapterConfiguration', 'isAlive', 'isAliveAuth', 'refreshProperties', 'addListener', 'emit', 'eventNames', 'getMaxListeners',
399
+ 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener', 'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
402
400
  try {
403
- const clean = a.checkActionFiles();
401
+ const expectedFunctions = a.getAllFunctions();
404
402
  try {
405
- for (let c = 0; c < clean.length; c += 1) {
406
- log.error(clean[c]);
407
- }
408
- assert.equal(0, clean.length);
403
+ assert.equal(JSON.stringify(expectedFunctions), JSON.stringify(returnedFunctions));
409
404
  done();
410
405
  } catch (err) {
411
406
  log.error(`Test Failure: ${err}`);
@@ -418,19 +413,19 @@ describe('[unit] Adapter Base Test', () => {
418
413
  }).timeout(attemptTimeout);
419
414
  });
420
415
 
421
- describe('#getQueue', () => {
422
- it('should have a getQueue function', (done) => {
416
+ describe('#iapGetAdapterWorkflowFunctions', () => {
417
+ it('should have a iapGetAdapterWorkflowFunctions function', (done) => {
423
418
  try {
424
- assert.equal(true, typeof a.getQueue === 'function');
419
+ assert.equal(true, typeof a.iapGetAdapterWorkflowFunctions === 'function');
425
420
  done();
426
421
  } catch (error) {
427
422
  log.error(`Test Failure: ${error}`);
428
423
  done(error);
429
424
  }
430
425
  });
431
- it('should get information for all of the requests currently in the queue', (done) => {
426
+ it('should retrieve workflow functions', (done) => {
432
427
  try {
433
- const expectedFunctions = a.getQueue();
428
+ const expectedFunctions = a.iapGetAdapterWorkflowFunctions([]);
434
429
  try {
435
430
  assert.equal(0, expectedFunctions.length);
436
431
  done();
@@ -445,73 +440,61 @@ describe('[unit] Adapter Base Test', () => {
445
440
  }).timeout(attemptTimeout);
446
441
  });
447
442
 
448
- describe('#connect', () => {
449
- it('should have a connect function', (done) => {
443
+ describe('#checkActionFiles', () => {
444
+ it('should have a checkActionFiles function', (done) => {
450
445
  try {
451
- assert.equal(true, typeof a.connect === 'function');
446
+ assert.equal(true, typeof a.checkActionFiles === 'function');
452
447
  done();
453
448
  } catch (error) {
454
449
  log.error(`Test Failure: ${error}`);
455
450
  done(error);
456
451
  }
457
452
  });
458
- it('should get connected - no healthcheck', (done) => {
459
- try {
460
- a.healthcheckType = 'none';
461
- a.connect();
462
-
463
- try {
464
- assert.equal(true, a.alive);
465
- done();
466
- } catch (error) {
467
- log.error(`Test Failure: ${error}`);
468
- done(error);
469
- }
470
- } catch (error) {
471
- log.error(`Adapter Exception: ${error}`);
472
- done(error);
473
- }
474
- });
475
- it('should get connected - startup healthcheck', (done) => {
453
+ it('the action files should be good - if failure change the log level as most issues are warnings', (done) => {
476
454
  try {
477
- a.healthcheckType = 'startup';
478
- a.connect();
479
-
455
+ const clean = a.checkActionFiles();
480
456
  try {
481
- assert.equal(true, a.alive);
457
+ for (let c = 0; c < clean.length; c += 1) {
458
+ log.error(clean[c]);
459
+ }
460
+ assert.equal(0, clean.length);
482
461
  done();
483
- } catch (error) {
484
- log.error(`Test Failure: ${error}`);
485
- done(error);
462
+ } catch (err) {
463
+ log.error(`Test Failure: ${err}`);
464
+ done(err);
486
465
  }
487
466
  } catch (error) {
488
467
  log.error(`Adapter Exception: ${error}`);
489
468
  done(error);
490
469
  }
491
- });
470
+ }).timeout(attemptTimeout);
492
471
  });
493
472
 
494
- describe('#healthCheck', () => {
495
- it('should have a healthCheck function', (done) => {
473
+ describe('#checkProperties', () => {
474
+ it('should have a checkProperties function', (done) => {
496
475
  try {
497
- assert.equal(true, typeof a.healthCheck === 'function');
476
+ assert.equal(true, typeof a.checkProperties === 'function');
498
477
  done();
499
478
  } catch (error) {
500
479
  log.error(`Test Failure: ${error}`);
501
480
  done(error);
502
481
  }
503
482
  });
504
- it('should be healthy', (done) => {
483
+ it('the sample properties should be good - if failure change the log level', (done) => {
505
484
  try {
506
- a.healthCheck(null, (data) => {
507
- try {
508
- assert.equal(true, a.healthy);
509
- done();
510
- } catch (err) {
511
- log.error(`Test Failure: ${err}`);
512
- done(err);
513
- }
514
- });
485
+ const samplePropsJson = require('../../sampleProperties.json');
486
+ const clean = a.checkProperties(samplePropsJson.properties);
487
+ try {
488
+ assert.notEqual(0, Object.keys(clean));
489
+ assert.equal(undefined, clean.exception);
490
+ assert.notEqual(undefined, clean.host);
491
+ assert.notEqual(null, clean.host);
492
+ assert.notEqual('', clean.host);
493
+ done();
494
+ } catch (err) {
495
+ log.error(`Test Failure: ${err}`);
496
+ done(err);
497
+ }
515
498
  } catch (error) {
516
499
  log.error(`Adapter Exception: ${error}`);
517
500
  done(error);
@@ -573,33 +556,21 @@ describe('[unit] Adapter Base Test', () => {
573
556
  }).timeout(attemptTimeout);
574
557
  });
575
558
 
576
- const entityType = 'mockType';
577
- const entities = {
578
- response: [
579
- {
580
- name: 'Godric Gryffindor'
581
- }, {
582
- name: 'Salazar Slytherin'
583
- }
584
- ]
585
- };
586
- const key = 'name';
587
- describe('#addEntityCache', () => {
588
- it('should have a addEntityCache function', (done) => {
559
+ describe('#iapUpdateAdapterConfiguration', () => {
560
+ it('should have a iapUpdateAdapterConfiguration function', (done) => {
589
561
  try {
590
- assert.equal(true, typeof a.addEntityCache === 'function');
562
+ assert.equal(true, typeof a.iapUpdateAdapterConfiguration === 'function');
591
563
  done();
592
564
  } catch (error) {
593
565
  log.error(`Test Failure: ${error}`);
594
566
  done(error);
595
567
  }
596
568
  });
597
- it('should take the entities and add them to the cache', (done) => {
598
- // Run the promise and verify the results match what we were expecting.
569
+ it('should return no updated if no changes are provided', (done) => {
599
570
  try {
600
- a.addEntityCache(entityType, entities, key, (data, error) => {
571
+ a.iapUpdateAdapterConfiguration(null, null, null, null, null, null, (data, error) => {
601
572
  try {
602
- assert.equal(true, data);
573
+ assert.equal('No configuration updates to make', data.response);
603
574
  done();
604
575
  } catch (err) {
605
576
  log.error(`Test Failure: ${err}`);
@@ -611,87 +582,12 @@ describe('[unit] Adapter Base Test', () => {
611
582
  done(error);
612
583
  }
613
584
  }).timeout(attemptTimeout);
614
- });
615
-
616
- const cache = [
617
- 'Godric Gryffindor',
618
- 'Salazar Slytherin'
619
- ];
620
- describe('#entityInList', () => {
621
- it('should have a entityInList function', (done) => {
622
- try {
623
- assert.equal(true, typeof a.entityInList === 'function');
624
- done();
625
- } catch (error) {
626
- log.error(`Test Failure: ${error}`);
627
- done(error);
628
- }
629
- });
630
- it('should return true if the entity is in the list of entities for this adapter', (done) => {
631
- try {
632
- const entityExist = a.entityInList('Godric Gryffindor', cache);
633
- try {
634
- assert.equal(true, entityExist[0]);
635
- done();
636
- } catch (err) {
637
- log.error(`Test Failure: ${err}`);
638
- done(err);
639
- }
640
- } catch (error) {
641
- log.error(`Adapter Exception: ${error}`);
642
- done(error);
643
- }
644
- }).timeout(attemptTimeout);
645
- it('should return false if the entity is not in the list of entities for this adapter', (done) => {
646
- try {
647
- const entityExist = a.entityInList('XXXX', cache);
648
- try {
649
- assert.equal(false, entityExist[0]);
650
- done();
651
- } catch (err) {
652
- log.error(`Test Failure: ${err}`);
653
- done(err);
654
- }
655
- } catch (error) {
656
- log.error(`Adapter Exception: ${error}`);
657
- done(error);
658
- }
659
- }).timeout(attemptTimeout);
660
- it('should return status of each item if an array is passed', (done) => {
661
- try {
662
- const entityExist = a.entityInList(['Godric Gryffindor', 'XXXX'], cache);
663
- try {
664
- assert.equal(true, entityExist[0]);
665
- assert.equal(false, entityExist[1]);
666
- done();
667
- } catch (err) {
668
- log.error(`Test Failure: ${err}`);
669
- done(err);
670
- }
671
- } catch (error) {
672
- log.error(`Adapter Exception: ${error}`);
673
- done(error);
674
- }
675
- }).timeout(attemptTimeout);
676
- });
677
-
678
- describe('#capabilityResults', () => {
679
- it('should have a capabilityResults function', (done) => {
680
- try {
681
- assert.equal(true, typeof a.capabilityResults === 'function');
682
- done();
683
- } catch (error) {
684
- log.error(`Test Failure: ${error}`);
685
- done(error);
686
- }
687
- });
688
- it('should throw an error if needupdate is passed into the function', (done) => {
585
+ it('should throw an error if missing configuration file', (done) => {
689
586
  try {
690
- const results = ['needupdate'];
691
- a.capabilityResults(results, (data, error) => {
587
+ a.iapUpdateAdapterConfiguration(null, { name: 'fakeChange' }, null, null, null, null, (data, error) => {
692
588
  try {
693
- const displayE = 'Could not load entity: unknown, into cache';
694
- runErrorAsserts(data, error, 'AD.320', 'Test-Base-adapterBase-capabilityResults', displayE);
589
+ const displayE = 'configFile is required';
590
+ runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
695
591
  done();
696
592
  } catch (err) {
697
593
  log.error(`Test Failure: ${err}`);
@@ -703,13 +599,12 @@ describe('[unit] Adapter Base Test', () => {
703
599
  done(error);
704
600
  }
705
601
  }).timeout(attemptTimeout);
706
- it('should throw an error if error is passed into the function', (done) => {
602
+ it('if not package.json, entity is required', (done) => {
707
603
  try {
708
- const results = ['error'];
709
- a.capabilityResults(results, (data, error) => {
604
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, null, null, null, null, (data, error) => {
710
605
  try {
711
- const displayE = 'Could not verify entity in cache';
712
- runErrorAsserts(data, error, 'AD.321', 'Test-Base-adapterBase-capabilityResults', displayE);
606
+ const displayE = 'Unsupported Configuration Change or Missing Entity';
607
+ runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
713
608
  done();
714
609
  } catch (err) {
715
610
  log.error(`Test Failure: ${err}`);
@@ -721,12 +616,12 @@ describe('[unit] Adapter Base Test', () => {
721
616
  done(error);
722
617
  }
723
618
  }).timeout(attemptTimeout);
724
- it('should return null if nothing passed in', (done) => {
619
+ it('if not package.json, type is required', (done) => {
725
620
  try {
726
- const results = null;
727
- a.capabilityResults(results, (data, error) => {
621
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'entity', null, null, null, (data, error) => {
728
622
  try {
729
- assert.equal(null, data);
623
+ const displayE = 'type is required';
624
+ runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
730
625
  done();
731
626
  } catch (err) {
732
627
  log.error(`Test Failure: ${err}`);
@@ -738,12 +633,12 @@ describe('[unit] Adapter Base Test', () => {
738
633
  done(error);
739
634
  }
740
635
  }).timeout(attemptTimeout);
741
- it('should return true if results is not an array and is "found"', (done) => {
636
+ it('if not package.json, entity must be valid', (done) => {
742
637
  try {
743
- const results = 'found';
744
- a.capabilityResults(results, (data, error) => {
638
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'fakeEntity', 'fakeType', null, null, (data, error) => {
745
639
  try {
746
- assert.equal(true, data[0]);
640
+ const displayE = 'Incomplete Configuration Change: Invalid Entity - fakeEntity';
641
+ runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
747
642
  done();
748
643
  } catch (err) {
749
644
  log.error(`Test Failure: ${err}`);
@@ -755,12 +650,25 @@ describe('[unit] Adapter Base Test', () => {
755
650
  done(error);
756
651
  }
757
652
  }).timeout(attemptTimeout);
758
- it('should return false if results is not an array and is not "found"', (done) => {
653
+ });
654
+
655
+ describe('#iapSuspendAdapter', () => {
656
+ it('should have a iapSuspendAdapter function', (done) => {
657
+ try {
658
+ assert.equal(true, typeof a.iapSuspendAdapter === 'function');
659
+ done();
660
+ } catch (error) {
661
+ log.error(`Test Failure: ${error}`);
662
+ done(error);
663
+ }
664
+ });
665
+ it('should successfully suspend the adapter', (done) => {
759
666
  try {
760
- const results = 'notfound';
761
- a.capabilityResults(results, (data, error) => {
667
+ a.iapSuspendAdapter('nopause', (data, error) => {
762
668
  try {
763
- assert.equal(false, data[0]);
669
+ assert.notEqual(null, data);
670
+ assert.notEqual(null, data.suspended);
671
+ assert.equal(true, data.suspended);
764
672
  done();
765
673
  } catch (err) {
766
674
  log.error(`Test Failure: ${err}`);
@@ -772,14 +680,25 @@ describe('[unit] Adapter Base Test', () => {
772
680
  done(error);
773
681
  }
774
682
  }).timeout(attemptTimeout);
775
- it('should process an incoming array and return an array of values', (done) => {
683
+ });
684
+
685
+ describe('#iapUnsuspendAdapter', () => {
686
+ it('should have a iapUnsuspendAdapter function', (done) => {
776
687
  try {
777
- const results = ['found', 'notFound', 'found'];
778
- a.capabilityResults(results, (data, error) => {
688
+ assert.equal(true, typeof a.iapUnsuspendAdapter === 'function');
689
+ done();
690
+ } catch (error) {
691
+ log.error(`Test Failure: ${error}`);
692
+ done(error);
693
+ }
694
+ });
695
+ it('should successfully unsuspend the adapter', (done) => {
696
+ try {
697
+ a.iapUnsuspendAdapter((data, error) => {
779
698
  try {
780
- assert.equal(true, data[0]);
781
- assert.equal(false, data[1]);
782
- assert.equal(true, data[2]);
699
+ assert.notEqual(null, data);
700
+ assert.notEqual(null, data.suspend);
701
+ assert.equal(false, data.suspend);
783
702
  done();
784
703
  } catch (err) {
785
704
  log.error(`Test Failure: ${err}`);
@@ -793,29 +712,21 @@ describe('[unit] Adapter Base Test', () => {
793
712
  }).timeout(attemptTimeout);
794
713
  });
795
714
 
796
- describe('#getAllCapabilities', () => {
797
- it('should have a getAllCapabilities function', (done) => {
715
+ describe('#iapGetAdapterQueue', () => {
716
+ it('should have a iapGetAdapterQueue function', (done) => {
798
717
  try {
799
- assert.equal(true, typeof a.getAllCapabilities === 'function');
718
+ assert.equal(true, typeof a.iapGetAdapterQueue === 'function');
800
719
  done();
801
720
  } catch (error) {
802
721
  log.error(`Test Failure: ${error}`);
803
722
  done(error);
804
723
  }
805
724
  });
806
- it('should have have capabilities returned', (done) => {
725
+ it('should get information for all of the requests currently in the queue', (done) => {
807
726
  try {
808
- const expectedCapabilities = a.getAllCapabilities();
727
+ const expectedFunctions = a.iapGetAdapterQueue();
809
728
  try {
810
- assert.notEqual(0, expectedCapabilities.length);
811
- assert.equal('.system', expectedCapabilities[0].entity);
812
- assert.equal(2, expectedCapabilities[0].actions.length);
813
- assert.equal('getToken', expectedCapabilities[0].actions[0]);
814
- assert.equal('healthcheck', expectedCapabilities[0].actions[1]);
815
- for (let e = 1; e < expectedCapabilities.length; e += 1) {
816
- assert.notEqual('', expectedCapabilities[e].entity);
817
- assert.notEqual(0, expectedCapabilities[e].actions);
818
- }
729
+ assert.equal(0, expectedFunctions.length);
819
730
  done();
820
731
  } catch (err) {
821
732
  log.error(`Test Failure: ${err}`);
@@ -828,23 +739,23 @@ describe('[unit] Adapter Base Test', () => {
828
739
  }).timeout(attemptTimeout);
829
740
  });
830
741
 
831
- // const returnedFunctions = ['updateAdapterConfiguration'];
832
-
833
- describe('#updateAdapterConfiguration', () => {
834
- it('should have a updateAdapterConfiguration function', (done) => {
742
+ describe('#iapFindAdapterPath', () => {
743
+ it('should have a iapFindAdapterPath function', (done) => {
835
744
  try {
836
- assert.equal(true, typeof a.updateAdapterConfiguration === 'function');
745
+ assert.equal(true, typeof a.iapFindAdapterPath === 'function');
837
746
  done();
838
747
  } catch (error) {
839
748
  log.error(`Test Failure: ${error}`);
840
749
  done(error);
841
750
  }
842
751
  });
843
- it('should return no updated if no changes are provided', (done) => {
752
+ it('should fail - missing path', (done) => {
844
753
  try {
845
- a.updateAdapterConfiguration(null, null, null, null, null, (data, error) => {
754
+ a.iapFindAdapterPath(null, (data, error) => {
846
755
  try {
847
- assert.equal('No configuration updates to make', data.response);
756
+ assert.notEqual(null, error);
757
+ assert.notEqual(null, error.message);
758
+ assert.equal('NO PATH PROVIDED!', error.message);
848
759
  done();
849
760
  } catch (err) {
850
761
  log.error(`Test Failure: ${err}`);
@@ -856,74 +767,258 @@ describe('[unit] Adapter Base Test', () => {
856
767
  done(error);
857
768
  }
858
769
  }).timeout(attemptTimeout);
859
- it('should throw an error if missing configuration file', (done) => {
770
+ });
771
+
772
+ describe('#iapTroubleshootAdapter', () => {
773
+ it('should have a iapTroubleshootAdapter function', (done) => {
860
774
  try {
861
- a.updateAdapterConfiguration(null, { name: 'fakeChange' }, null, null, null, (data, error) => {
862
- try {
863
- const displayE = 'configFile is required';
864
- runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
865
- done();
866
- } catch (err) {
867
- log.error(`Test Failure: ${err}`);
868
- done(err);
869
- }
870
- });
775
+ assert.equal(true, typeof a.iapTroubleshootAdapter === 'function');
776
+ done();
871
777
  } catch (error) {
872
- log.error(`Adapter Exception: ${error}`);
778
+ log.error(`Test Failure: ${error}`);
873
779
  done(error);
874
780
  }
875
- }).timeout(attemptTimeout);
876
- it('if not package.json, entity is required', (done) => {
781
+ });
782
+ });
783
+
784
+ describe('#iapRunAdapterHealthcheck', () => {
785
+ it('should have a iapRunAdapterHealthcheck function', (done) => {
877
786
  try {
878
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, null, null, null, (data, error) => {
879
- try {
880
- const displayE = 'Unsupported Configuration Change or Missing Entity';
881
- runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
882
- done();
883
- } catch (err) {
884
- log.error(`Test Failure: ${err}`);
885
- done(err);
886
- }
887
- });
787
+ assert.equal(true, typeof a.iapRunAdapterHealthcheck === 'function');
788
+ done();
888
789
  } catch (error) {
889
- log.error(`Adapter Exception: ${error}`);
790
+ log.error(`Test Failure: ${error}`);
890
791
  done(error);
891
792
  }
892
- }).timeout(attemptTimeout);
893
- it('if not package.json, type is required', (done) => {
793
+ });
794
+ });
795
+
796
+ describe('#iapRunAdapterConnectivity', () => {
797
+ it('should have a iapRunAdapterConnectivity function', (done) => {
894
798
  try {
895
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'entity', null, null, (data, error) => {
896
- try {
897
- const displayE = 'type is required';
898
- runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
899
- done();
900
- } catch (err) {
901
- log.error(`Test Failure: ${err}`);
902
- done(err);
903
- }
904
- });
799
+ assert.equal(true, typeof a.iapRunAdapterConnectivity === 'function');
800
+ done();
905
801
  } catch (error) {
906
- log.error(`Adapter Exception: ${error}`);
802
+ log.error(`Test Failure: ${error}`);
907
803
  done(error);
908
804
  }
909
- }).timeout(attemptTimeout);
910
- it('if not package.json, entity must be valid', (done) => {
805
+ });
806
+ });
807
+
808
+ describe('#iapRunAdapterBasicGet', () => {
809
+ it('should have a iapRunAdapterBasicGet function', (done) => {
911
810
  try {
912
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'fakeEntity', 'fakeType', null, (data, error) => {
913
- try {
914
- const displayE = 'Incomplete Configuration Change: Invalid Entity - fakeEntity';
915
- runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
916
- done();
917
- } catch (err) {
918
- log.error(`Test Failure: ${err}`);
919
- done(err);
920
- }
921
- });
811
+ assert.equal(true, typeof a.iapRunAdapterBasicGet === 'function');
812
+ done();
922
813
  } catch (error) {
923
- log.error(`Adapter Exception: ${error}`);
814
+ log.error(`Test Failure: ${error}`);
924
815
  done(error);
925
816
  }
926
- }).timeout(attemptTimeout);
817
+ });
818
+ });
819
+
820
+ describe('#iapMoveAdapterEntitiesToDB', () => {
821
+ it('should have a iapMoveAdapterEntitiesToDB function', (done) => {
822
+ try {
823
+ assert.equal(true, typeof a.iapMoveAdapterEntitiesToDB === 'function');
824
+ done();
825
+ } catch (error) {
826
+ log.error(`Test Failure: ${error}`);
827
+ done(error);
828
+ }
829
+ });
830
+ });
831
+
832
+ describe('#iapDeactivateTasks', () => {
833
+ it('should have a iapDeactivateTasks function', (done) => {
834
+ try {
835
+ assert.equal(true, typeof a.iapDeactivateTasks === 'function');
836
+ done();
837
+ } catch (error) {
838
+ log.error(`Test Failure: ${error}`);
839
+ done(error);
840
+ }
841
+ });
842
+ });
843
+
844
+ describe('#iapActivateTasks', () => {
845
+ it('should have a iapActivateTasks function', (done) => {
846
+ try {
847
+ assert.equal(true, typeof a.iapActivateTasks === 'function');
848
+ done();
849
+ } catch (error) {
850
+ log.error(`Test Failure: ${error}`);
851
+ done(error);
852
+ }
853
+ });
854
+ });
855
+
856
+ describe('#iapPopulateEntityCache', () => {
857
+ it('should have a iapPopulateEntityCache function', (done) => {
858
+ try {
859
+ assert.equal(true, typeof a.iapPopulateEntityCache === 'function');
860
+ done();
861
+ } catch (error) {
862
+ log.error(`Test Failure: ${error}`);
863
+ done(error);
864
+ }
865
+ });
866
+ });
867
+
868
+ describe('#iapRetrieveEntitiesCache', () => {
869
+ it('should have a iapRetrieveEntitiesCache function', (done) => {
870
+ try {
871
+ assert.equal(true, typeof a.iapRetrieveEntitiesCache === 'function');
872
+ done();
873
+ } catch (error) {
874
+ log.error(`Test Failure: ${error}`);
875
+ done(error);
876
+ }
877
+ });
878
+ });
879
+
880
+ describe('#hasEntities', () => {
881
+ it('should have a hasEntities function', (done) => {
882
+ try {
883
+ assert.equal(true, typeof a.hasEntities === 'function');
884
+ done();
885
+ } catch (error) {
886
+ log.error(`Test Failure: ${error}`);
887
+ done(error);
888
+ }
889
+ });
890
+ });
891
+
892
+ describe('#getDevice', () => {
893
+ it('should have a getDevice function', (done) => {
894
+ try {
895
+ assert.equal(true, typeof a.getDevice === 'function');
896
+ done();
897
+ } catch (error) {
898
+ log.error(`Test Failure: ${error}`);
899
+ done(error);
900
+ }
901
+ });
902
+ });
903
+
904
+ describe('#getDevicesFiltered', () => {
905
+ it('should have a getDevicesFiltered function', (done) => {
906
+ try {
907
+ assert.equal(true, typeof a.getDevicesFiltered === 'function');
908
+ done();
909
+ } catch (error) {
910
+ log.error(`Test Failure: ${error}`);
911
+ done(error);
912
+ }
913
+ });
914
+ });
915
+
916
+ describe('#isAlive', () => {
917
+ it('should have a isAlive function', (done) => {
918
+ try {
919
+ assert.equal(true, typeof a.isAlive === 'function');
920
+ done();
921
+ } catch (error) {
922
+ log.error(`Test Failure: ${error}`);
923
+ done(error);
924
+ }
925
+ });
926
+ });
927
+
928
+ describe('#getConfig', () => {
929
+ it('should have a getConfig function', (done) => {
930
+ try {
931
+ assert.equal(true, typeof a.getConfig === 'function');
932
+ done();
933
+ } catch (error) {
934
+ log.error(`Test Failure: ${error}`);
935
+ done(error);
936
+ }
937
+ });
938
+ });
939
+
940
+ describe('#iapGetDeviceCount', () => {
941
+ it('should have a iapGetDeviceCount function', (done) => {
942
+ try {
943
+ assert.equal(true, typeof a.iapGetDeviceCount === 'function');
944
+ done();
945
+ } catch (error) {
946
+ log.error(`Test Failure: ${error}`);
947
+ done(error);
948
+ }
949
+ });
950
+ });
951
+
952
+ describe('#iapExpandedGenericAdapterRequest', () => {
953
+ it('should have a iapExpandedGenericAdapterRequest function', (done) => {
954
+ try {
955
+ assert.equal(true, typeof a.iapExpandedGenericAdapterRequest === 'function');
956
+ done();
957
+ } catch (error) {
958
+ log.error(`Test Failure: ${error}`);
959
+ done(error);
960
+ }
961
+ });
962
+ });
963
+
964
+ describe('#genericAdapterRequest', () => {
965
+ it('should have a genericAdapterRequest function', (done) => {
966
+ try {
967
+ assert.equal(true, typeof a.genericAdapterRequest === 'function');
968
+ done();
969
+ } catch (error) {
970
+ log.error(`Test Failure: ${error}`);
971
+ done(error);
972
+ }
973
+ });
974
+ });
975
+
976
+ describe('#genericAdapterRequestNoBasePath', () => {
977
+ it('should have a genericAdapterRequestNoBasePath function', (done) => {
978
+ try {
979
+ assert.equal(true, typeof a.genericAdapterRequestNoBasePath === 'function');
980
+ done();
981
+ } catch (error) {
982
+ log.error(`Test Failure: ${error}`);
983
+ done(error);
984
+ }
985
+ });
986
+ });
987
+
988
+ describe('#iapRunAdapterLint', () => {
989
+ it('should have a iapRunAdapterLint function', (done) => {
990
+ try {
991
+ assert.equal(true, typeof a.iapRunAdapterLint === 'function');
992
+ done();
993
+ } catch (error) {
994
+ log.error(`Test Failure: ${error}`);
995
+ done(error);
996
+ }
997
+ });
998
+ });
999
+
1000
+ describe('#iapRunAdapterTests', () => {
1001
+ it('should have a iapRunAdapterTests function', (done) => {
1002
+ try {
1003
+ assert.equal(true, typeof a.iapRunAdapterTests === 'function');
1004
+ done();
1005
+ } catch (error) {
1006
+ log.error(`Test Failure: ${error}`);
1007
+ done(error);
1008
+ }
1009
+ });
1010
+ });
1011
+
1012
+ describe('#iapGetAdapterInventory', () => {
1013
+ it('should have a iapGetAdapterInventory function', (done) => {
1014
+ try {
1015
+ assert.equal(true, typeof a.iapGetAdapterInventory === 'function');
1016
+ done();
1017
+ } catch (error) {
1018
+ log.error(`Test Failure: ${error}`);
1019
+ done(error);
1020
+ }
1021
+ });
927
1022
  });
928
1023
  });
929
1024
  });