@itentialopensource/adapter-openstack_neutron 3.0.3 → 3.1.0

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