@itentialopensource/adapter-microsoft_graph 1.0.1 → 1.1.0

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