@itentialopensource/adapter-efficientip_solidserver 0.1.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 (57) hide show
  1. package/AUTH.md +39 -0
  2. package/BROKER.md +199 -0
  3. package/CALLS.md +1465 -0
  4. package/CHANGELOG.md +17 -2
  5. package/CODE_OF_CONDUCT.md +12 -17
  6. package/CONTRIBUTING.md +3 -148
  7. package/ENHANCE.md +69 -0
  8. package/PROPERTIES.md +641 -0
  9. package/README.md +235 -576
  10. package/SUMMARY.md +9 -0
  11. package/SYSTEMINFO.md +11 -0
  12. package/TROUBLESHOOT.md +47 -0
  13. package/adapter.js +383 -263
  14. package/adapterBase.js +854 -408
  15. package/changelogs/changelog.md +16 -0
  16. package/entities/.generic/action.json +110 -5
  17. package/entities/.generic/schema.json +6 -1
  18. package/error.json +6 -0
  19. package/metadata.json +49 -0
  20. package/package.json +27 -22
  21. package/pronghorn.json +691 -88
  22. package/propertiesDecorators.json +14 -0
  23. package/propertiesSchema.json +828 -7
  24. package/refs?service=git-upload-pack +0 -0
  25. package/report/adapter-openapi.json +41906 -0
  26. package/report/adapter-openapi.yaml +23138 -0
  27. package/report/adapterInfo.json +10 -0
  28. package/report/updateReport1653233995404.json +120 -0
  29. package/report/updateReport1691508450223.json +120 -0
  30. package/report/updateReport1692202927301.json +120 -0
  31. package/report/updateReport1694465845842.json +120 -0
  32. package/report/updateReport1698421858198.json +120 -0
  33. package/sampleProperties.json +153 -3
  34. package/test/integration/adapterTestBasicGet.js +3 -5
  35. package/test/integration/adapterTestConnectivity.js +91 -42
  36. package/test/integration/adapterTestIntegration.js +155 -106
  37. package/test/unit/adapterBaseTestUnit.js +388 -308
  38. package/test/unit/adapterTestUnit.js +484 -243
  39. package/utils/adapterInfo.js +206 -0
  40. package/utils/addAuth.js +94 -0
  41. package/utils/artifactize.js +1 -1
  42. package/utils/basicGet.js +1 -14
  43. package/utils/checkMigrate.js +1 -1
  44. package/utils/entitiesToDB.js +179 -0
  45. package/utils/findPath.js +1 -1
  46. package/utils/methodDocumentor.js +273 -0
  47. package/utils/modify.js +14 -16
  48. package/utils/packModificationScript.js +1 -1
  49. package/utils/patches2bundledDeps.js +90 -0
  50. package/utils/pre-commit.sh +5 -0
  51. package/utils/removeHooks.js +20 -0
  52. package/utils/taskMover.js +309 -0
  53. package/utils/tbScript.js +129 -53
  54. package/utils/tbUtils.js +125 -25
  55. package/utils/testRunner.js +17 -17
  56. package/utils/troubleshootingAdapter.js +10 -31
  57. 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');
@@ -305,90 +305,73 @@ describe('[unit] Adapter Base Test', () => {
305
305
  }).timeout(attemptTimeout);
306
306
  });
307
307
 
308
- describe('#getAllFunctions', () => {
309
- it('should have a getAllFunctions function', (done) => {
308
+ describe('#connect', () => {
309
+ it('should have a connect function', (done) => {
310
310
  try {
311
- assert.equal(true, typeof a.getAllFunctions === 'function');
311
+ assert.equal(true, typeof a.connect === 'function');
312
312
  done();
313
313
  } catch (error) {
314
314
  log.error(`Test Failure: ${error}`);
315
315
  done(error);
316
316
  }
317
317
  });
318
- it('should return a list of functions', (done) => {
319
- const returnedFunctions = ['addEntityCache', 'capabilityResults', 'checkActionFiles', 'checkProperties', 'connect', 'encryptProperty',
320
- 'entityInList', 'findPath', 'getAllCapabilities', 'getAllFunctions', 'getQueue', 'getWorkflowFunctions', 'healthCheck',
321
- 'refreshProperties', 'runBasicGet', 'runConnectivity', 'runHealthcheck', 'suspend', 'troubleshoot', 'unsuspend', 'updateAdapterConfiguration', 'addListener',
322
- 'emit', 'eventNames', 'getMaxListeners', 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener',
323
- 'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
318
+ it('should get connected - no healthcheck', (done) => {
324
319
  try {
325
- const expectedFunctions = a.getAllFunctions();
320
+ a.healthcheckType = 'none';
321
+ a.connect();
322
+
326
323
  try {
327
- assert.equal(JSON.stringify(expectedFunctions), JSON.stringify(returnedFunctions));
324
+ assert.equal(true, a.alive);
328
325
  done();
329
- } catch (err) {
330
- log.error(`Test Failure: ${err}`);
331
- done(err);
326
+ } catch (error) {
327
+ log.error(`Test Failure: ${error}`);
328
+ done(error);
332
329
  }
333
330
  } catch (error) {
334
331
  log.error(`Adapter Exception: ${error}`);
335
332
  done(error);
336
333
  }
337
- }).timeout(attemptTimeout);
338
- });
339
-
340
- describe('#getWorkflowFunctions', () => {
341
- it('should have a getWorkflowFunctions function', (done) => {
342
- try {
343
- assert.equal(true, typeof a.getWorkflowFunctions === 'function');
344
- done();
345
- } catch (error) {
346
- log.error(`Test Failure: ${error}`);
347
- done(error);
348
- }
349
334
  });
350
- it('should retrieve workflow functions', (done) => {
335
+ it('should get connected - startup healthcheck', (done) => {
351
336
  try {
352
- const expectedFunctions = a.getWorkflowFunctions([]);
337
+ a.healthcheckType = 'startup';
338
+ a.connect();
339
+
353
340
  try {
354
- assert.equal(0, expectedFunctions.length);
341
+ assert.equal(true, a.alive);
355
342
  done();
356
- } catch (err) {
357
- log.error(`Test Failure: ${err}`);
358
- done(err);
343
+ } catch (error) {
344
+ log.error(`Test Failure: ${error}`);
345
+ done(error);
359
346
  }
360
347
  } catch (error) {
361
348
  log.error(`Adapter Exception: ${error}`);
362
349
  done(error);
363
350
  }
364
- }).timeout(attemptTimeout);
351
+ });
365
352
  });
366
353
 
367
- describe('#checkProperties', () => {
368
- it('should have a checkProperties function', (done) => {
354
+ describe('#healthCheck', () => {
355
+ it('should have a healthCheck function', (done) => {
369
356
  try {
370
- assert.equal(true, typeof a.checkProperties === 'function');
357
+ assert.equal(true, typeof a.healthCheck === 'function');
371
358
  done();
372
359
  } catch (error) {
373
360
  log.error(`Test Failure: ${error}`);
374
361
  done(error);
375
362
  }
376
363
  });
377
- it('the sample properties should be good - if failure change the log level', (done) => {
364
+ it('should be healthy', (done) => {
378
365
  try {
379
- const samplePropsJson = require('../../sampleProperties.json');
380
- const clean = a.checkProperties(samplePropsJson.properties);
381
- try {
382
- assert.notEqual(0, Object.keys(clean));
383
- assert.equal(undefined, clean.exception);
384
- assert.notEqual(undefined, clean.host);
385
- assert.notEqual(null, clean.host);
386
- assert.notEqual('', clean.host);
387
- done();
388
- } catch (err) {
389
- log.error(`Test Failure: ${err}`);
390
- done(err);
391
- }
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
+ });
392
375
  } catch (error) {
393
376
  log.error(`Adapter Exception: ${error}`);
394
377
  done(error);
@@ -396,24 +379,28 @@ describe('[unit] Adapter Base Test', () => {
396
379
  }).timeout(attemptTimeout);
397
380
  });
398
381
 
399
- describe('#checkActionFiles', () => {
400
- it('should have a checkActionFiles function', (done) => {
382
+ describe('#getAllFunctions', () => {
383
+ it('should have a getAllFunctions function', (done) => {
401
384
  try {
402
- assert.equal(true, typeof a.checkActionFiles === 'function');
385
+ assert.equal(true, typeof a.getAllFunctions === 'function');
403
386
  done();
404
387
  } catch (error) {
405
388
  log.error(`Test Failure: ${error}`);
406
389
  done(error);
407
390
  }
408
391
  });
409
- 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'];
410
400
  try {
411
- const clean = a.checkActionFiles();
401
+ const expectedFunctions = a.getAllFunctions();
412
402
  try {
413
- for (let c = 0; c < clean.length; c += 1) {
414
- log.error(clean[c]);
415
- }
416
- assert.equal(0, clean.length);
403
+ assert.equal(JSON.stringify(expectedFunctions), JSON.stringify(returnedFunctions));
417
404
  done();
418
405
  } catch (err) {
419
406
  log.error(`Test Failure: ${err}`);
@@ -426,19 +413,19 @@ describe('[unit] Adapter Base Test', () => {
426
413
  }).timeout(attemptTimeout);
427
414
  });
428
415
 
429
- describe('#getQueue', () => {
430
- it('should have a getQueue function', (done) => {
416
+ describe('#iapGetAdapterWorkflowFunctions', () => {
417
+ it('should have a iapGetAdapterWorkflowFunctions function', (done) => {
431
418
  try {
432
- assert.equal(true, typeof a.getQueue === 'function');
419
+ assert.equal(true, typeof a.iapGetAdapterWorkflowFunctions === 'function');
433
420
  done();
434
421
  } catch (error) {
435
422
  log.error(`Test Failure: ${error}`);
436
423
  done(error);
437
424
  }
438
425
  });
439
- it('should get information for all of the requests currently in the queue', (done) => {
426
+ it('should retrieve workflow functions', (done) => {
440
427
  try {
441
- const expectedFunctions = a.getQueue();
428
+ const expectedFunctions = a.iapGetAdapterWorkflowFunctions([]);
442
429
  try {
443
430
  assert.equal(0, expectedFunctions.length);
444
431
  done();
@@ -453,73 +440,61 @@ describe('[unit] Adapter Base Test', () => {
453
440
  }).timeout(attemptTimeout);
454
441
  });
455
442
 
456
- describe('#connect', () => {
457
- it('should have a connect function', (done) => {
443
+ describe('#checkActionFiles', () => {
444
+ it('should have a checkActionFiles function', (done) => {
458
445
  try {
459
- assert.equal(true, typeof a.connect === 'function');
446
+ assert.equal(true, typeof a.checkActionFiles === 'function');
460
447
  done();
461
448
  } catch (error) {
462
449
  log.error(`Test Failure: ${error}`);
463
450
  done(error);
464
451
  }
465
452
  });
466
- it('should get connected - no healthcheck', (done) => {
467
- try {
468
- a.healthcheckType = 'none';
469
- a.connect();
470
-
471
- try {
472
- assert.equal(true, a.alive);
473
- done();
474
- } catch (error) {
475
- log.error(`Test Failure: ${error}`);
476
- done(error);
477
- }
478
- } catch (error) {
479
- log.error(`Adapter Exception: ${error}`);
480
- done(error);
481
- }
482
- });
483
- 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) => {
484
454
  try {
485
- a.healthcheckType = 'startup';
486
- a.connect();
487
-
455
+ const clean = a.checkActionFiles();
488
456
  try {
489
- 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);
490
461
  done();
491
- } catch (error) {
492
- log.error(`Test Failure: ${error}`);
493
- done(error);
462
+ } catch (err) {
463
+ log.error(`Test Failure: ${err}`);
464
+ done(err);
494
465
  }
495
466
  } catch (error) {
496
467
  log.error(`Adapter Exception: ${error}`);
497
468
  done(error);
498
469
  }
499
- });
470
+ }).timeout(attemptTimeout);
500
471
  });
501
472
 
502
- describe('#healthCheck', () => {
503
- it('should have a healthCheck function', (done) => {
473
+ describe('#checkProperties', () => {
474
+ it('should have a checkProperties function', (done) => {
504
475
  try {
505
- assert.equal(true, typeof a.healthCheck === 'function');
476
+ assert.equal(true, typeof a.checkProperties === 'function');
506
477
  done();
507
478
  } catch (error) {
508
479
  log.error(`Test Failure: ${error}`);
509
480
  done(error);
510
481
  }
511
482
  });
512
- it('should be healthy', (done) => {
483
+ it('the sample properties should be good - if failure change the log level', (done) => {
513
484
  try {
514
- a.healthCheck(null, (data) => {
515
- try {
516
- assert.equal(true, a.healthy);
517
- done();
518
- } catch (err) {
519
- log.error(`Test Failure: ${err}`);
520
- done(err);
521
- }
522
- });
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
+ }
523
498
  } catch (error) {
524
499
  log.error(`Adapter Exception: ${error}`);
525
500
  done(error);
@@ -581,33 +556,21 @@ describe('[unit] Adapter Base Test', () => {
581
556
  }).timeout(attemptTimeout);
582
557
  });
583
558
 
584
- const entityType = 'mockType';
585
- const entities = {
586
- response: [
587
- {
588
- name: 'Godric Gryffindor'
589
- }, {
590
- name: 'Salazar Slytherin'
591
- }
592
- ]
593
- };
594
- const key = 'name';
595
- describe('#addEntityCache', () => {
596
- it('should have a addEntityCache function', (done) => {
559
+ describe('#iapUpdateAdapterConfiguration', () => {
560
+ it('should have a iapUpdateAdapterConfiguration function', (done) => {
597
561
  try {
598
- assert.equal(true, typeof a.addEntityCache === 'function');
562
+ assert.equal(true, typeof a.iapUpdateAdapterConfiguration === 'function');
599
563
  done();
600
564
  } catch (error) {
601
565
  log.error(`Test Failure: ${error}`);
602
566
  done(error);
603
567
  }
604
568
  });
605
- it('should take the entities and add them to the cache', (done) => {
606
- // Run the promise and verify the results match what we were expecting.
569
+ it('should return no updated if no changes are provided', (done) => {
607
570
  try {
608
- a.addEntityCache(entityType, entities, key, (data, error) => {
571
+ a.iapUpdateAdapterConfiguration(null, null, null, null, null, null, (data, error) => {
609
572
  try {
610
- assert.equal(true, data);
573
+ assert.equal('No configuration updates to make', data.response);
611
574
  done();
612
575
  } catch (err) {
613
576
  log.error(`Test Failure: ${err}`);
@@ -619,87 +582,12 @@ describe('[unit] Adapter Base Test', () => {
619
582
  done(error);
620
583
  }
621
584
  }).timeout(attemptTimeout);
622
- });
623
-
624
- const cache = [
625
- 'Godric Gryffindor',
626
- 'Salazar Slytherin'
627
- ];
628
- describe('#entityInList', () => {
629
- it('should have a entityInList function', (done) => {
630
- try {
631
- assert.equal(true, typeof a.entityInList === 'function');
632
- done();
633
- } catch (error) {
634
- log.error(`Test Failure: ${error}`);
635
- done(error);
636
- }
637
- });
638
- it('should return true if the entity is in the list of entities for this adapter', (done) => {
639
- try {
640
- const entityExist = a.entityInList('Godric Gryffindor', cache);
641
- try {
642
- assert.equal(true, entityExist[0]);
643
- done();
644
- } catch (err) {
645
- log.error(`Test Failure: ${err}`);
646
- done(err);
647
- }
648
- } catch (error) {
649
- log.error(`Adapter Exception: ${error}`);
650
- done(error);
651
- }
652
- }).timeout(attemptTimeout);
653
- it('should return false if the entity is not in the list of entities for this adapter', (done) => {
654
- try {
655
- const entityExist = a.entityInList('XXXX', cache);
656
- try {
657
- assert.equal(false, entityExist[0]);
658
- done();
659
- } catch (err) {
660
- log.error(`Test Failure: ${err}`);
661
- done(err);
662
- }
663
- } catch (error) {
664
- log.error(`Adapter Exception: ${error}`);
665
- done(error);
666
- }
667
- }).timeout(attemptTimeout);
668
- it('should return status of each item if an array is passed', (done) => {
669
- try {
670
- const entityExist = a.entityInList(['Godric Gryffindor', 'XXXX'], cache);
671
- try {
672
- assert.equal(true, entityExist[0]);
673
- assert.equal(false, entityExist[1]);
674
- done();
675
- } catch (err) {
676
- log.error(`Test Failure: ${err}`);
677
- done(err);
678
- }
679
- } catch (error) {
680
- log.error(`Adapter Exception: ${error}`);
681
- done(error);
682
- }
683
- }).timeout(attemptTimeout);
684
- });
685
-
686
- describe('#capabilityResults', () => {
687
- it('should have a capabilityResults function', (done) => {
688
- try {
689
- assert.equal(true, typeof a.capabilityResults === 'function');
690
- done();
691
- } catch (error) {
692
- log.error(`Test Failure: ${error}`);
693
- done(error);
694
- }
695
- });
696
- it('should throw an error if needupdate is passed into the function', (done) => {
585
+ it('should throw an error if missing configuration file', (done) => {
697
586
  try {
698
- const results = ['needupdate'];
699
- a.capabilityResults(results, (data, error) => {
587
+ a.iapUpdateAdapterConfiguration(null, { name: 'fakeChange' }, null, null, null, null, (data, error) => {
700
588
  try {
701
- const displayE = 'Could not load entity: unknown, into cache';
702
- 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);
703
591
  done();
704
592
  } catch (err) {
705
593
  log.error(`Test Failure: ${err}`);
@@ -711,13 +599,12 @@ describe('[unit] Adapter Base Test', () => {
711
599
  done(error);
712
600
  }
713
601
  }).timeout(attemptTimeout);
714
- it('should throw an error if error is passed into the function', (done) => {
602
+ it('if not package.json, entity is required', (done) => {
715
603
  try {
716
- const results = ['error'];
717
- a.capabilityResults(results, (data, error) => {
604
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, null, null, null, null, (data, error) => {
718
605
  try {
719
- const displayE = 'Could not verify entity in cache';
720
- 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);
721
608
  done();
722
609
  } catch (err) {
723
610
  log.error(`Test Failure: ${err}`);
@@ -729,12 +616,12 @@ describe('[unit] Adapter Base Test', () => {
729
616
  done(error);
730
617
  }
731
618
  }).timeout(attemptTimeout);
732
- it('should return null if nothing passed in', (done) => {
619
+ it('if not package.json, type is required', (done) => {
733
620
  try {
734
- const results = null;
735
- a.capabilityResults(results, (data, error) => {
621
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'entity', null, null, null, (data, error) => {
736
622
  try {
737
- assert.equal(null, data);
623
+ const displayE = 'type is required';
624
+ runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
738
625
  done();
739
626
  } catch (err) {
740
627
  log.error(`Test Failure: ${err}`);
@@ -746,12 +633,12 @@ describe('[unit] Adapter Base Test', () => {
746
633
  done(error);
747
634
  }
748
635
  }).timeout(attemptTimeout);
749
- 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) => {
750
637
  try {
751
- const results = 'found';
752
- a.capabilityResults(results, (data, error) => {
638
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'fakeEntity', 'fakeType', null, null, (data, error) => {
753
639
  try {
754
- 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);
755
642
  done();
756
643
  } catch (err) {
757
644
  log.error(`Test Failure: ${err}`);
@@ -763,12 +650,25 @@ describe('[unit] Adapter Base Test', () => {
763
650
  done(error);
764
651
  }
765
652
  }).timeout(attemptTimeout);
766
- 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) => {
767
657
  try {
768
- const results = 'notfound';
769
- a.capabilityResults(results, (data, error) => {
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) => {
666
+ try {
667
+ a.iapSuspendAdapter('nopause', (data, error) => {
770
668
  try {
771
- assert.equal(false, data[0]);
669
+ assert.notEqual(null, data);
670
+ assert.notEqual(null, data.suspended);
671
+ assert.equal(true, data.suspended);
772
672
  done();
773
673
  } catch (err) {
774
674
  log.error(`Test Failure: ${err}`);
@@ -780,14 +680,25 @@ describe('[unit] Adapter Base Test', () => {
780
680
  done(error);
781
681
  }
782
682
  }).timeout(attemptTimeout);
783
- 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) => {
784
687
  try {
785
- const results = ['found', 'notFound', 'found'];
786
- 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) => {
787
698
  try {
788
- assert.equal(true, data[0]);
789
- assert.equal(false, data[1]);
790
- assert.equal(true, data[2]);
699
+ assert.notEqual(null, data);
700
+ assert.notEqual(null, data.suspend);
701
+ assert.equal(false, data.suspend);
791
702
  done();
792
703
  } catch (err) {
793
704
  log.error(`Test Failure: ${err}`);
@@ -801,36 +712,21 @@ describe('[unit] Adapter Base Test', () => {
801
712
  }).timeout(attemptTimeout);
802
713
  });
803
714
 
804
- describe('#getAllCapabilities', () => {
805
- it('should have a getAllCapabilities function', (done) => {
715
+ describe('#iapGetAdapterQueue', () => {
716
+ it('should have a iapGetAdapterQueue function', (done) => {
806
717
  try {
807
- assert.equal(true, typeof a.getAllCapabilities === 'function');
718
+ assert.equal(true, typeof a.iapGetAdapterQueue === 'function');
808
719
  done();
809
720
  } catch (error) {
810
721
  log.error(`Test Failure: ${error}`);
811
722
  done(error);
812
723
  }
813
724
  });
814
- it('should have capabilities returned', (done) => {
725
+ it('should get information for all of the requests currently in the queue', (done) => {
815
726
  try {
816
- const expectedCapabilities = a.getAllCapabilities();
727
+ const expectedFunctions = a.iapGetAdapterQueue();
817
728
  try {
818
- assert.notEqual(0, expectedCapabilities.length);
819
- assert.equal('.generic', expectedCapabilities[0].entity);
820
- assert.equal(5, expectedCapabilities[0].actions.length);
821
- assert.equal('getGenerics', expectedCapabilities[0].actions[0]);
822
- assert.equal('createGeneric', expectedCapabilities[0].actions[1]);
823
- assert.equal('updateGeneric', expectedCapabilities[0].actions[2]);
824
- assert.equal('patchGeneric', expectedCapabilities[0].actions[3]);
825
- assert.equal('deleteGeneric', expectedCapabilities[0].actions[4]);
826
- assert.equal('.system', expectedCapabilities[1].entity);
827
- assert.equal(2, expectedCapabilities[1].actions.length);
828
- assert.equal('getToken', expectedCapabilities[1].actions[0]);
829
- assert.equal('healthcheck', expectedCapabilities[1].actions[1]);
830
- for (let e = 1; e < expectedCapabilities.length; e += 1) {
831
- assert.notEqual('', expectedCapabilities[e].entity);
832
- assert.notEqual(null, expectedCapabilities[e].actions);
833
- }
729
+ assert.equal(0, expectedFunctions.length);
834
730
  done();
835
731
  } catch (err) {
836
732
  log.error(`Test Failure: ${err}`);
@@ -843,23 +739,23 @@ describe('[unit] Adapter Base Test', () => {
843
739
  }).timeout(attemptTimeout);
844
740
  });
845
741
 
846
- // const returnedFunctions = ['updateAdapterConfiguration'];
847
-
848
- describe('#updateAdapterConfiguration', () => {
849
- it('should have a updateAdapterConfiguration function', (done) => {
742
+ describe('#iapFindAdapterPath', () => {
743
+ it('should have a iapFindAdapterPath function', (done) => {
850
744
  try {
851
- assert.equal(true, typeof a.updateAdapterConfiguration === 'function');
745
+ assert.equal(true, typeof a.iapFindAdapterPath === 'function');
852
746
  done();
853
747
  } catch (error) {
854
748
  log.error(`Test Failure: ${error}`);
855
749
  done(error);
856
750
  }
857
751
  });
858
- it('should return no updated if no changes are provided', (done) => {
752
+ it('should fail - missing path', (done) => {
859
753
  try {
860
- a.updateAdapterConfiguration(null, null, null, null, null, (data, error) => {
754
+ a.iapFindAdapterPath(null, (data, error) => {
861
755
  try {
862
- 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);
863
759
  done();
864
760
  } catch (err) {
865
761
  log.error(`Test Failure: ${err}`);
@@ -871,74 +767,258 @@ describe('[unit] Adapter Base Test', () => {
871
767
  done(error);
872
768
  }
873
769
  }).timeout(attemptTimeout);
874
- it('should throw an error if missing configuration file', (done) => {
770
+ });
771
+
772
+ describe('#iapTroubleshootAdapter', () => {
773
+ it('should have a iapTroubleshootAdapter function', (done) => {
875
774
  try {
876
- a.updateAdapterConfiguration(null, { name: 'fakeChange' }, null, null, null, (data, error) => {
877
- try {
878
- const displayE = 'configFile is required';
879
- runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
880
- done();
881
- } catch (err) {
882
- log.error(`Test Failure: ${err}`);
883
- done(err);
884
- }
885
- });
775
+ assert.equal(true, typeof a.iapTroubleshootAdapter === 'function');
776
+ done();
886
777
  } catch (error) {
887
- log.error(`Adapter Exception: ${error}`);
778
+ log.error(`Test Failure: ${error}`);
888
779
  done(error);
889
780
  }
890
- }).timeout(attemptTimeout);
891
- it('if not package.json, entity is required', (done) => {
781
+ });
782
+ });
783
+
784
+ describe('#iapRunAdapterHealthcheck', () => {
785
+ it('should have a iapRunAdapterHealthcheck function', (done) => {
892
786
  try {
893
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, null, null, null, (data, error) => {
894
- try {
895
- const displayE = 'Unsupported Configuration Change or Missing Entity';
896
- runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
897
- done();
898
- } catch (err) {
899
- log.error(`Test Failure: ${err}`);
900
- done(err);
901
- }
902
- });
787
+ assert.equal(true, typeof a.iapRunAdapterHealthcheck === 'function');
788
+ done();
903
789
  } catch (error) {
904
- log.error(`Adapter Exception: ${error}`);
790
+ log.error(`Test Failure: ${error}`);
905
791
  done(error);
906
792
  }
907
- }).timeout(attemptTimeout);
908
- it('if not package.json, type is required', (done) => {
793
+ });
794
+ });
795
+
796
+ describe('#iapRunAdapterConnectivity', () => {
797
+ it('should have a iapRunAdapterConnectivity function', (done) => {
909
798
  try {
910
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'entity', null, null, (data, error) => {
911
- try {
912
- const displayE = 'type is required';
913
- runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
914
- done();
915
- } catch (err) {
916
- log.error(`Test Failure: ${err}`);
917
- done(err);
918
- }
919
- });
799
+ assert.equal(true, typeof a.iapRunAdapterConnectivity === 'function');
800
+ done();
920
801
  } catch (error) {
921
- log.error(`Adapter Exception: ${error}`);
802
+ log.error(`Test Failure: ${error}`);
922
803
  done(error);
923
804
  }
924
- }).timeout(attemptTimeout);
925
- it('if not package.json, entity must be valid', (done) => {
805
+ });
806
+ });
807
+
808
+ describe('#iapRunAdapterBasicGet', () => {
809
+ it('should have a iapRunAdapterBasicGet function', (done) => {
926
810
  try {
927
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'fakeEntity', 'fakeType', null, (data, error) => {
928
- try {
929
- const displayE = 'Incomplete Configuration Change: Invalid Entity - fakeEntity';
930
- runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
931
- done();
932
- } catch (err) {
933
- log.error(`Test Failure: ${err}`);
934
- done(err);
935
- }
936
- });
811
+ assert.equal(true, typeof a.iapRunAdapterBasicGet === 'function');
812
+ done();
937
813
  } catch (error) {
938
- log.error(`Adapter Exception: ${error}`);
814
+ log.error(`Test Failure: ${error}`);
939
815
  done(error);
940
816
  }
941
- }).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
+ });
942
1022
  });
943
1023
  });
944
1024
  });