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