@itentialopensource/adapter-vmware_vcenter 0.5.3 → 0.7.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 (38) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +12 -12
  3. package/CHANGELOG.md +32 -0
  4. package/README.md +209 -29
  5. package/adapter.js +1476 -34
  6. package/adapterBase.js +289 -11
  7. package/entities/.generic/action.json +109 -0
  8. package/entities/.generic/schema.json +23 -0
  9. package/entities/.system/action.json +3 -3
  10. package/entities/.system/schemaTokenReq.json +2 -2
  11. package/entities/Vmtemplatelibraryitems/action.json +25 -0
  12. package/entities/Vmtemplatelibraryitems/schema.json +19 -0
  13. package/error.json +6 -0
  14. package/package.json +42 -21
  15. package/pronghorn.json +614 -0
  16. package/propertiesSchema.json +56 -9
  17. package/refs?service=git-upload-pack +0 -0
  18. package/report/updateReport1594310791028.json +95 -0
  19. package/report/updateReport1615860501665.json +95 -0
  20. package/report/updateReport1643047821981.json +95 -0
  21. package/sampleProperties.json +20 -5
  22. package/test/integration/adapterTestBasicGet.js +85 -0
  23. package/test/integration/adapterTestConnectivity.js +93 -0
  24. package/test/integration/adapterTestIntegration.js +59 -6
  25. package/test/unit/adapterBaseTestUnit.js +944 -0
  26. package/test/unit/adapterTestUnit.js +683 -10
  27. package/utils/addAuth.js +94 -0
  28. package/utils/basicGet.js +50 -0
  29. package/utils/checkMigrate.js +63 -0
  30. package/utils/entitiesToDB.js +224 -0
  31. package/utils/findPath.js +74 -0
  32. package/utils/modify.js +154 -0
  33. package/utils/packModificationScript.js +1 -1
  34. package/utils/patches2bundledDeps.js +90 -0
  35. package/utils/removeHooks.js +20 -0
  36. package/utils/tbScript.js +169 -0
  37. package/utils/tbUtils.js +451 -0
  38. package/utils/troubleshootingAdapter.js +190 -0
@@ -23,7 +23,7 @@ const anything = td.matchers.anything();
23
23
  let logLevel = 'none';
24
24
  const stub = true;
25
25
  const isRapidFail = false;
26
- const attemptTimeout = 120000;
26
+ const attemptTimeout = 600000;
27
27
 
28
28
  // these variables can be changed to run in integrated mode so easier to set them here
29
29
  // always check these in with bogus data!!!
@@ -51,6 +51,7 @@ global.pronghornProps = {
51
51
  base_path: '',
52
52
  version: '',
53
53
  cache_location: '',
54
+ encode_pathvars: true,
54
55
  save_metric: false,
55
56
  protocol,
56
57
  stub,
@@ -63,11 +64,16 @@ global.pronghornProps = {
63
64
  token_cache: 'local',
64
65
  invalid_token_error: 401,
65
66
  auth_field: 'header.headers.Authorization',
66
- auth_field_format: 'Basic {b64}{username}:{password}{/b64}'
67
+ auth_field_format: 'Basic {b64}{username}:{password}{/b64}',
68
+ auth_logging: false,
69
+ client_id: '',
70
+ client_secret: '',
71
+ grant_type: ''
67
72
  },
68
73
  healthcheck: {
69
74
  type: 'startup',
70
- frequency: 60000
75
+ frequency: 60000,
76
+ query_object: {}
71
77
  },
72
78
  throttle: {
73
79
  throttle_enabled: false,
@@ -76,7 +82,13 @@ global.pronghornProps = {
76
82
  max_in_queue: 1000,
77
83
  concurrent_max: 1,
78
84
  expire_timeout: 0,
79
- avg_runtime: 200
85
+ avg_runtime: 200,
86
+ priorities: [
87
+ {
88
+ value: 0,
89
+ percent: 100
90
+ }
91
+ ]
80
92
  },
81
93
  request: {
82
94
  number_redirects: 0,
@@ -92,13 +104,16 @@ global.pronghornProps = {
92
104
  },
93
105
  healthcheck_on_timeout: false,
94
106
  return_raw: true,
95
- archiving: false
107
+ archiving: false,
108
+ return_request: false
96
109
  },
97
110
  proxy: {
98
111
  enabled: false,
99
112
  host: '',
100
113
  port: 1,
101
- protocol: 'http'
114
+ protocol: 'http',
115
+ username: '',
116
+ password: ''
102
117
  },
103
118
  ssl: {
104
119
  ecdhCurve: '',
@@ -186,7 +201,7 @@ function runErrorAsserts(data, error, code, origin, displayStr) {
186
201
  }
187
202
 
188
203
  // require the adapter that we are going to be using
189
- const VmwareVCenter = require('../../adapter.js');
204
+ const VmwareVCenter = require('../../adapter');
190
205
 
191
206
  // delete the .DS_Store directory in entities -- otherwise this will cause errors
192
207
  const dirPath = path.join(__dirname, '../../entities/.DS_Store');
@@ -228,6 +243,8 @@ describe('[unit] Vmware_vCenter Adapter Test', () => {
228
243
  try {
229
244
  assert.notEqual(null, a);
230
245
  assert.notEqual(undefined, a);
246
+ const checkId = global.pronghornProps.adapterProps.adapters[0].id;
247
+ assert.equal(checkId, a.id);
231
248
  assert.notEqual(null, a.allProps);
232
249
  const check = global.pronghornProps.adapterProps.adapters[0].properties.healthcheck.type;
233
250
  assert.equal(check, a.healthcheckType);
@@ -257,7 +274,7 @@ describe('[unit] Vmware_vCenter Adapter Test', () => {
257
274
  describe('#getWorkflowFunctions', () => {
258
275
  it('should retrieve workflow functions', (done) => {
259
276
  try {
260
- wffunctions = a.getWorkflowFunctions();
277
+ wffunctions = a.getWorkflowFunctions([]);
261
278
 
262
279
  try {
263
280
  assert.notEqual(0, wffunctions.length);
@@ -309,13 +326,103 @@ describe('[unit] Vmware_vCenter Adapter Test', () => {
309
326
  done(error);
310
327
  }
311
328
  });
312
- it('package.json should be customized', (done) => {
329
+ it('package.json standard fields should be customized', (done) => {
313
330
  try {
314
331
  const packageDotJson = require('../../package.json');
315
332
  assert.notEqual(-1, packageDotJson.name.indexOf('vmware_vcenter'));
316
333
  assert.notEqual(undefined, packageDotJson.version);
317
334
  assert.notEqual(null, packageDotJson.version);
318
335
  assert.notEqual('', packageDotJson.version);
336
+ assert.notEqual(undefined, packageDotJson.description);
337
+ assert.notEqual(null, packageDotJson.description);
338
+ assert.notEqual('', packageDotJson.description);
339
+ assert.equal('adapter.js', packageDotJson.main);
340
+ assert.notEqual(undefined, packageDotJson.wizardVersion);
341
+ assert.notEqual(null, packageDotJson.wizardVersion);
342
+ assert.notEqual('', packageDotJson.wizardVersion);
343
+ assert.notEqual(undefined, packageDotJson.engineVersion);
344
+ assert.notEqual(null, packageDotJson.engineVersion);
345
+ assert.notEqual('', packageDotJson.engineVersion);
346
+ assert.equal('http', packageDotJson.adapterType);
347
+ done();
348
+ } catch (error) {
349
+ log.error(`Test Failure: ${error}`);
350
+ done(error);
351
+ }
352
+ });
353
+ it('package.json proper scripts should be provided', (done) => {
354
+ try {
355
+ const packageDotJson = require('../../package.json');
356
+ assert.notEqual(undefined, packageDotJson.scripts);
357
+ assert.notEqual(null, packageDotJson.scripts);
358
+ assert.notEqual('', packageDotJson.scripts);
359
+ assert.equal('node utils/setup.js && npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions', packageDotJson.scripts.preinstall);
360
+ assert.equal('node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js', packageDotJson.scripts.lint);
361
+ assert.equal('node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js --quiet', packageDotJson.scripts['lint:errors']);
362
+ assert.equal('mocha test/unit/adapterBaseTestUnit.js --LOG=error', packageDotJson.scripts['test:baseunit']);
363
+ assert.equal('mocha test/unit/adapterTestUnit.js --LOG=error', packageDotJson.scripts['test:unit']);
364
+ assert.equal('mocha test/integration/adapterTestIntegration.js --LOG=error', packageDotJson.scripts['test:integration']);
365
+ assert.equal('nyc --reporter html --reporter text mocha --reporter dot test/*', packageDotJson.scripts['test:cover']);
366
+ assert.equal('npm run test:baseunit && npm run test:unit && npm run test:integration', packageDotJson.scripts.test);
367
+ assert.equal('npm publish --registry=https://registry.npmjs.org --access=public', packageDotJson.scripts.deploy);
368
+ assert.equal('npm run deploy', packageDotJson.scripts.build);
369
+ done();
370
+ } catch (error) {
371
+ log.error(`Test Failure: ${error}`);
372
+ done(error);
373
+ }
374
+ });
375
+ it('package.json proper directories should be provided', (done) => {
376
+ try {
377
+ const packageDotJson = require('../../package.json');
378
+ assert.notEqual(undefined, packageDotJson.repository);
379
+ assert.notEqual(null, packageDotJson.repository);
380
+ assert.notEqual('', packageDotJson.repository);
381
+ assert.equal('git', packageDotJson.repository.type);
382
+ assert.equal('git@gitlab.com:itentialopensource/adapters/', packageDotJson.repository.url.substring(0, 43));
383
+ assert.equal('https://gitlab.com/itentialopensource/adapters/', packageDotJson.homepage.substring(0, 47));
384
+ done();
385
+ } catch (error) {
386
+ log.error(`Test Failure: ${error}`);
387
+ done(error);
388
+ }
389
+ });
390
+ it('package.json proper dependencies should be provided', (done) => {
391
+ try {
392
+ const packageDotJson = require('../../package.json');
393
+ assert.notEqual(undefined, packageDotJson.dependencies);
394
+ assert.notEqual(null, packageDotJson.dependencies);
395
+ assert.notEqual('', packageDotJson.dependencies);
396
+ assert.equal('^6.12.0', packageDotJson.dependencies.ajv);
397
+ assert.equal('^0.21.0', packageDotJson.dependencies.axios);
398
+ assert.equal('^2.20.0', packageDotJson.dependencies.commander);
399
+ assert.equal('^8.1.0', packageDotJson.dependencies['fs-extra']);
400
+ assert.equal('^9.0.1', packageDotJson.dependencies.mocha);
401
+ assert.equal('^2.0.1', packageDotJson.dependencies['mocha-param']);
402
+ assert.equal('^0.5.3', packageDotJson.dependencies['network-diagnostics']);
403
+ assert.equal('^15.1.0', packageDotJson.dependencies.nyc);
404
+ assert.equal('^1.4.10', packageDotJson.dependencies['readline-sync']);
405
+ assert.equal('^7.3.2', packageDotJson.dependencies.semver);
406
+ assert.equal('^3.3.3', packageDotJson.dependencies.winston);
407
+ done();
408
+ } catch (error) {
409
+ log.error(`Test Failure: ${error}`);
410
+ done(error);
411
+ }
412
+ });
413
+ it('package.json proper dev dependencies should be provided', (done) => {
414
+ try {
415
+ const packageDotJson = require('../../package.json');
416
+ assert.notEqual(undefined, packageDotJson.devDependencies);
417
+ assert.notEqual(null, packageDotJson.devDependencies);
418
+ assert.notEqual('', packageDotJson.devDependencies);
419
+ assert.equal('^4.3.4', packageDotJson.devDependencies.chai);
420
+ assert.equal('^7.29.0', packageDotJson.devDependencies.eslint);
421
+ assert.equal('^14.2.1', packageDotJson.devDependencies['eslint-config-airbnb-base']);
422
+ assert.equal('^2.23.4', packageDotJson.devDependencies['eslint-plugin-import']);
423
+ assert.equal('^3.0.0', packageDotJson.devDependencies['eslint-plugin-json']);
424
+ assert.equal('^0.6.3', packageDotJson.devDependencies['package-json-validator']);
425
+ assert.equal('^3.16.1', packageDotJson.devDependencies.testdouble);
319
426
  done();
320
427
  } catch (error) {
321
428
  log.error(`Test Failure: ${error}`);
@@ -340,8 +447,34 @@ describe('[unit] Vmware_vCenter Adapter Test', () => {
340
447
  try {
341
448
  const pronghornDotJson = require('../../pronghorn.json');
342
449
  assert.notEqual(-1, pronghornDotJson.id.indexOf('vmware_vcenter'));
450
+ assert.equal('Adapter', pronghornDotJson.type);
343
451
  assert.equal('VmwareVCenter', pronghornDotJson.export);
344
452
  assert.equal('Vmware_vCenter', pronghornDotJson.title);
453
+ assert.equal('adapter.js', pronghornDotJson.src);
454
+ done();
455
+ } catch (error) {
456
+ log.error(`Test Failure: ${error}`);
457
+ done(error);
458
+ }
459
+ });
460
+ it('pronghorn.json should contain generic adapter methods', (done) => {
461
+ try {
462
+ const pronghornDotJson = require('../../pronghorn.json');
463
+ assert.notEqual(undefined, pronghornDotJson.methods);
464
+ assert.notEqual(null, pronghornDotJson.methods);
465
+ assert.notEqual('', pronghornDotJson.methods);
466
+ assert.equal(true, Array.isArray(pronghornDotJson.methods));
467
+ assert.notEqual(0, pronghornDotJson.methods.length);
468
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'updateAdapterConfiguration'));
469
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'findPath'));
470
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'troubleshoot'));
471
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'runHealthcheck'));
472
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'runConnectivity'));
473
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'runBasicGet'));
474
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'suspend'));
475
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'unsuspend'));
476
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'getQueue'));
477
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'genericAdapterRequest'));
345
478
  done();
346
479
  } catch (error) {
347
480
  log.error(`Test Failure: ${error}`);
@@ -363,7 +496,7 @@ describe('[unit] Vmware_vCenter Adapter Test', () => {
363
496
  let wfparams = [];
364
497
 
365
498
  if (methLine && methLine.indexOf('(') >= 0 && methLine.indexOf(')') >= 0) {
366
- const temp = methLine.substring(methLine.indexOf('(') + 1, methLine.indexOf(')'));
499
+ const temp = methLine.substring(methLine.indexOf('(') + 1, methLine.lastIndexOf(')'));
367
500
  wfparams = temp.split(',');
368
501
 
369
502
  for (let t = 0; t < wfparams.length; t += 1) {
@@ -480,6 +613,117 @@ describe('[unit] Vmware_vCenter Adapter Test', () => {
480
613
  try {
481
614
  const propertiesDotJson = require('../../propertiesSchema.json');
482
615
  assert.equal('adapter-vmware_vcenter', propertiesDotJson.$id);
616
+ assert.equal('object', propertiesDotJson.type);
617
+ assert.equal('http://json-schema.org/draft-07/schema#', propertiesDotJson.$schema);
618
+ done();
619
+ } catch (error) {
620
+ log.error(`Test Failure: ${error}`);
621
+ done(error);
622
+ }
623
+ });
624
+ it('propertiesSchema.json should contain generic adapter properties', (done) => {
625
+ try {
626
+ const propertiesDotJson = require('../../propertiesSchema.json');
627
+ assert.notEqual(undefined, propertiesDotJson.properties);
628
+ assert.notEqual(null, propertiesDotJson.properties);
629
+ assert.notEqual('', propertiesDotJson.properties);
630
+ assert.equal('string', propertiesDotJson.properties.host.type);
631
+ assert.equal('integer', propertiesDotJson.properties.port.type);
632
+ assert.equal('boolean', propertiesDotJson.properties.stub.type);
633
+ assert.notEqual(undefined, propertiesDotJson.definitions.authentication);
634
+ assert.notEqual(null, propertiesDotJson.definitions.authentication);
635
+ assert.notEqual('', propertiesDotJson.definitions.authentication);
636
+ assert.equal('string', propertiesDotJson.definitions.authentication.properties.auth_method.type);
637
+ assert.equal('string', propertiesDotJson.definitions.authentication.properties.username.type);
638
+ assert.equal('string', propertiesDotJson.definitions.authentication.properties.password.type);
639
+ assert.equal('string', propertiesDotJson.definitions.authentication.properties.token.type);
640
+ assert.equal('integer', propertiesDotJson.definitions.authentication.properties.invalid_token_error.type);
641
+ assert.equal('integer', propertiesDotJson.definitions.authentication.properties.token_timeout.type);
642
+ assert.equal('string', propertiesDotJson.definitions.authentication.properties.token_cache.type);
643
+ assert.equal(true, Array.isArray(propertiesDotJson.definitions.authentication.properties.auth_field.type));
644
+ assert.equal(true, Array.isArray(propertiesDotJson.definitions.authentication.properties.auth_field_format.type));
645
+ assert.equal('boolean', propertiesDotJson.definitions.authentication.properties.auth_logging.type);
646
+ assert.equal('string', propertiesDotJson.definitions.authentication.properties.client_id.type);
647
+ assert.equal('string', propertiesDotJson.definitions.authentication.properties.client_secret.type);
648
+ assert.equal('string', propertiesDotJson.definitions.authentication.properties.grant_type.type);
649
+ assert.notEqual('', propertiesDotJson.definitions.ssl);
650
+ assert.equal('string', propertiesDotJson.definitions.ssl.properties.ecdhCurve.type);
651
+ assert.equal('boolean', propertiesDotJson.definitions.ssl.properties.enabled.type);
652
+ assert.equal('boolean', propertiesDotJson.definitions.ssl.properties.accept_invalid_cert.type);
653
+ assert.equal('string', propertiesDotJson.definitions.ssl.properties.ca_file.type);
654
+ assert.equal('string', propertiesDotJson.definitions.ssl.properties.key_file.type);
655
+ assert.equal('string', propertiesDotJson.definitions.ssl.properties.cert_file.type);
656
+ assert.equal('string', propertiesDotJson.definitions.ssl.properties.secure_protocol.type);
657
+ assert.equal('string', propertiesDotJson.definitions.ssl.properties.ciphers.type);
658
+ assert.equal('string', propertiesDotJson.properties.base_path.type);
659
+ assert.equal('string', propertiesDotJson.properties.version.type);
660
+ assert.equal('string', propertiesDotJson.properties.cache_location.type);
661
+ assert.equal('boolean', propertiesDotJson.properties.encode_pathvars.type);
662
+ assert.equal(true, Array.isArray(propertiesDotJson.properties.save_metric.type));
663
+ assert.equal('string', propertiesDotJson.properties.protocol.type);
664
+ assert.notEqual(undefined, propertiesDotJson.definitions);
665
+ assert.notEqual(null, propertiesDotJson.definitions);
666
+ assert.notEqual('', propertiesDotJson.definitions);
667
+ assert.notEqual(undefined, propertiesDotJson.definitions.healthcheck);
668
+ assert.notEqual(null, propertiesDotJson.definitions.healthcheck);
669
+ assert.notEqual('', propertiesDotJson.definitions.healthcheck);
670
+ assert.equal('string', propertiesDotJson.definitions.healthcheck.properties.type.type);
671
+ assert.equal('integer', propertiesDotJson.definitions.healthcheck.properties.frequency.type);
672
+ assert.equal('object', propertiesDotJson.definitions.healthcheck.properties.query_object.type);
673
+ assert.notEqual(undefined, propertiesDotJson.definitions.throttle);
674
+ assert.notEqual(null, propertiesDotJson.definitions.throttle);
675
+ assert.notEqual('', propertiesDotJson.definitions.throttle);
676
+ assert.equal('boolean', propertiesDotJson.definitions.throttle.properties.throttle_enabled.type);
677
+ assert.equal('integer', propertiesDotJson.definitions.throttle.properties.number_pronghorns.type);
678
+ assert.equal('string', propertiesDotJson.definitions.throttle.properties.sync_async.type);
679
+ assert.equal('integer', propertiesDotJson.definitions.throttle.properties.max_in_queue.type);
680
+ assert.equal('integer', propertiesDotJson.definitions.throttle.properties.concurrent_max.type);
681
+ assert.equal('integer', propertiesDotJson.definitions.throttle.properties.expire_timeout.type);
682
+ assert.equal('integer', propertiesDotJson.definitions.throttle.properties.avg_runtime.type);
683
+ assert.equal('array', propertiesDotJson.definitions.throttle.properties.priorities.type);
684
+ assert.notEqual(undefined, propertiesDotJson.definitions.request);
685
+ assert.notEqual(null, propertiesDotJson.definitions.request);
686
+ assert.notEqual('', propertiesDotJson.definitions.request);
687
+ assert.equal('integer', propertiesDotJson.definitions.request.properties.number_redirects.type);
688
+ assert.equal('integer', propertiesDotJson.definitions.request.properties.number_retries.type);
689
+ assert.equal(true, Array.isArray(propertiesDotJson.definitions.request.properties.limit_retry_error.type));
690
+ assert.equal('array', propertiesDotJson.definitions.request.properties.failover_codes.type);
691
+ assert.equal('integer', propertiesDotJson.definitions.request.properties.attempt_timeout.type);
692
+ assert.equal('object', propertiesDotJson.definitions.request.properties.global_request.type);
693
+ assert.equal('object', propertiesDotJson.definitions.request.properties.global_request.properties.payload.type);
694
+ assert.equal('object', propertiesDotJson.definitions.request.properties.global_request.properties.uriOptions.type);
695
+ assert.equal('object', propertiesDotJson.definitions.request.properties.global_request.properties.addlHeaders.type);
696
+ assert.equal('object', propertiesDotJson.definitions.request.properties.global_request.properties.authData.type);
697
+ assert.equal('boolean', propertiesDotJson.definitions.request.properties.healthcheck_on_timeout.type);
698
+ assert.equal('boolean', propertiesDotJson.definitions.request.properties.return_raw.type);
699
+ assert.equal('boolean', propertiesDotJson.definitions.request.properties.archiving.type);
700
+ assert.equal('boolean', propertiesDotJson.definitions.request.properties.return_request.type);
701
+ assert.notEqual(undefined, propertiesDotJson.definitions.proxy);
702
+ assert.notEqual(null, propertiesDotJson.definitions.proxy);
703
+ assert.notEqual('', propertiesDotJson.definitions.proxy);
704
+ assert.equal('boolean', propertiesDotJson.definitions.proxy.properties.enabled.type);
705
+ assert.equal('string', propertiesDotJson.definitions.proxy.properties.host.type);
706
+ assert.equal('integer', propertiesDotJson.definitions.proxy.properties.port.type);
707
+ assert.equal('string', propertiesDotJson.definitions.proxy.properties.protocol.type);
708
+ assert.equal('string', propertiesDotJson.definitions.proxy.properties.username.type);
709
+ assert.equal('string', propertiesDotJson.definitions.proxy.properties.password.type);
710
+ assert.notEqual(undefined, propertiesDotJson.definitions.ssl);
711
+ assert.notEqual(null, propertiesDotJson.definitions.ssl);
712
+ assert.notEqual(undefined, propertiesDotJson.definitions.mongo);
713
+ assert.notEqual(null, propertiesDotJson.definitions.mongo);
714
+ assert.notEqual('', propertiesDotJson.definitions.mongo);
715
+ assert.equal('string', propertiesDotJson.definitions.mongo.properties.host.type);
716
+ assert.equal('integer', propertiesDotJson.definitions.mongo.properties.port.type);
717
+ assert.equal('string', propertiesDotJson.definitions.mongo.properties.database.type);
718
+ assert.equal('string', propertiesDotJson.definitions.mongo.properties.username.type);
719
+ assert.equal('string', propertiesDotJson.definitions.mongo.properties.password.type);
720
+ assert.equal('string', propertiesDotJson.definitions.mongo.properties.replSet.type);
721
+ assert.equal('object', propertiesDotJson.definitions.mongo.properties.db_ssl.type);
722
+ assert.equal('boolean', propertiesDotJson.definitions.mongo.properties.db_ssl.properties.enabled.type);
723
+ assert.equal('boolean', propertiesDotJson.definitions.mongo.properties.db_ssl.properties.accept_invalid_cert.type);
724
+ assert.equal('string', propertiesDotJson.definitions.mongo.properties.db_ssl.properties.ca_file.type);
725
+ assert.equal('string', propertiesDotJson.definitions.mongo.properties.db_ssl.properties.key_file.type);
726
+ assert.equal('string', propertiesDotJson.definitions.mongo.properties.db_ssl.properties.cert_file.type);
483
727
  done();
484
728
  } catch (error) {
485
729
  log.error(`Test Failure: ${error}`);
@@ -500,6 +744,50 @@ describe('[unit] Vmware_vCenter Adapter Test', () => {
500
744
  done(error);
501
745
  }
502
746
  });
747
+ it('error.json should have standard adapter errors', (done) => {
748
+ try {
749
+ const errorDotJson = require('../../error.json');
750
+ assert.notEqual(undefined, errorDotJson.errors);
751
+ assert.notEqual(null, errorDotJson.errors);
752
+ assert.notEqual('', errorDotJson.errors);
753
+ assert.equal(true, Array.isArray(errorDotJson.errors));
754
+ assert.notEqual(0, errorDotJson.errors.length);
755
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.100'));
756
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.101'));
757
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.102'));
758
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.110'));
759
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.111'));
760
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.112'));
761
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.113'));
762
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.114'));
763
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.115'));
764
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.116'));
765
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.300'));
766
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.301'));
767
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.302'));
768
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.303'));
769
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.304'));
770
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.305'));
771
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.310'));
772
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.311'));
773
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.312'));
774
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.320'));
775
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.321'));
776
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.400'));
777
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.401'));
778
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.402'));
779
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.500'));
780
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.501'));
781
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.502'));
782
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.503'));
783
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.600'));
784
+ assert.notEqual(undefined, errorDotJson.errors.find((e) => e.icode === 'AD.900'));
785
+ done();
786
+ } catch (error) {
787
+ log.error(`Test Failure: ${error}`);
788
+ done(error);
789
+ }
790
+ });
503
791
  });
504
792
 
505
793
  describe('sampleProperties.json', () => {
@@ -514,6 +802,119 @@ describe('[unit] Vmware_vCenter Adapter Test', () => {
514
802
  done(error);
515
803
  }
516
804
  });
805
+ it('sampleProperties.json should contain generic adapter properties', (done) => {
806
+ try {
807
+ const sampleDotJson = require('../../sampleProperties.json');
808
+ assert.notEqual(-1, sampleDotJson.id.indexOf('vmware_vcenter'));
809
+ assert.equal('VmwareVCenter', sampleDotJson.type);
810
+ assert.notEqual(undefined, sampleDotJson.properties);
811
+ assert.notEqual(null, sampleDotJson.properties);
812
+ assert.notEqual('', sampleDotJson.properties);
813
+ assert.notEqual(undefined, sampleDotJson.properties.host);
814
+ assert.notEqual(undefined, sampleDotJson.properties.port);
815
+ assert.notEqual(undefined, sampleDotJson.properties.stub);
816
+ assert.notEqual(undefined, sampleDotJson.properties.authentication);
817
+ assert.notEqual(null, sampleDotJson.properties.authentication);
818
+ assert.notEqual('', sampleDotJson.properties.authentication);
819
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.auth_method);
820
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.username);
821
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.password);
822
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.token);
823
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.invalid_token_error);
824
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.token_timeout);
825
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.token_cache);
826
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.auth_field);
827
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.auth_field_format);
828
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.auth_logging);
829
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.client_id);
830
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.client_secret);
831
+ assert.notEqual(undefined, sampleDotJson.properties.authentication.grant_type);
832
+ assert.notEqual(undefined, sampleDotJson.properties.ssl);
833
+ assert.notEqual(null, sampleDotJson.properties.ssl);
834
+ assert.notEqual('', sampleDotJson.properties.ssl);
835
+ assert.notEqual(undefined, sampleDotJson.properties.ssl.ecdhCurve);
836
+ assert.notEqual(undefined, sampleDotJson.properties.ssl.enabled);
837
+ assert.notEqual(undefined, sampleDotJson.properties.ssl.accept_invalid_cert);
838
+ assert.notEqual(undefined, sampleDotJson.properties.ssl.ca_file);
839
+ assert.notEqual(undefined, sampleDotJson.properties.ssl.key_file);
840
+ assert.notEqual(undefined, sampleDotJson.properties.ssl.cert_file);
841
+ assert.notEqual(undefined, sampleDotJson.properties.ssl.secure_protocol);
842
+ assert.notEqual(undefined, sampleDotJson.properties.ssl.ciphers);
843
+
844
+ assert.notEqual(undefined, sampleDotJson.properties.base_path);
845
+ assert.notEqual(undefined, sampleDotJson.properties.version);
846
+ assert.notEqual(undefined, sampleDotJson.properties.cache_location);
847
+ assert.notEqual(undefined, sampleDotJson.properties.encode_pathvars);
848
+ assert.notEqual(undefined, sampleDotJson.properties.save_metric);
849
+ assert.notEqual(undefined, sampleDotJson.properties.protocol);
850
+ assert.notEqual(undefined, sampleDotJson.properties.stub);
851
+ assert.notEqual(undefined, sampleDotJson.properties.stub);
852
+ assert.notEqual(undefined, sampleDotJson.properties.stub);
853
+ assert.notEqual(undefined, sampleDotJson.properties.stub);
854
+ assert.notEqual(undefined, sampleDotJson.properties.healthcheck);
855
+ assert.notEqual(null, sampleDotJson.properties.healthcheck);
856
+ assert.notEqual('', sampleDotJson.properties.healthcheck);
857
+ assert.notEqual(undefined, sampleDotJson.properties.healthcheck.type);
858
+ assert.notEqual(undefined, sampleDotJson.properties.healthcheck.frequency);
859
+ assert.notEqual(undefined, sampleDotJson.properties.healthcheck.query_object);
860
+ assert.notEqual(undefined, sampleDotJson.properties.throttle);
861
+ assert.notEqual(null, sampleDotJson.properties.throttle);
862
+ assert.notEqual('', sampleDotJson.properties.throttle);
863
+ assert.notEqual(undefined, sampleDotJson.properties.throttle.throttle_enabled);
864
+ assert.notEqual(undefined, sampleDotJson.properties.throttle.number_pronghorns);
865
+ assert.notEqual(undefined, sampleDotJson.properties.throttle.sync_async);
866
+ assert.notEqual(undefined, sampleDotJson.properties.throttle.max_in_queue);
867
+ assert.notEqual(undefined, sampleDotJson.properties.throttle.concurrent_max);
868
+ assert.notEqual(undefined, sampleDotJson.properties.throttle.expire_timeout);
869
+ assert.notEqual(undefined, sampleDotJson.properties.throttle.avg_runtime);
870
+ assert.notEqual(undefined, sampleDotJson.properties.throttle.priorities);
871
+ assert.notEqual(undefined, sampleDotJson.properties.request);
872
+ assert.notEqual(null, sampleDotJson.properties.request);
873
+ assert.notEqual('', sampleDotJson.properties.request);
874
+ assert.notEqual(undefined, sampleDotJson.properties.request.number_redirects);
875
+ assert.notEqual(undefined, sampleDotJson.properties.request.number_retries);
876
+ assert.notEqual(undefined, sampleDotJson.properties.request.limit_retry_error);
877
+ assert.notEqual(undefined, sampleDotJson.properties.request.failover_codes);
878
+ assert.notEqual(undefined, sampleDotJson.properties.request.attempt_timeout);
879
+ assert.notEqual(undefined, sampleDotJson.properties.request.global_request);
880
+ assert.notEqual(undefined, sampleDotJson.properties.request.global_request.payload);
881
+ assert.notEqual(undefined, sampleDotJson.properties.request.global_request.uriOptions);
882
+ assert.notEqual(undefined, sampleDotJson.properties.request.global_request.addlHeaders);
883
+ assert.notEqual(undefined, sampleDotJson.properties.request.global_request.authData);
884
+ assert.notEqual(undefined, sampleDotJson.properties.request.healthcheck_on_timeout);
885
+ assert.notEqual(undefined, sampleDotJson.properties.request.return_raw);
886
+ assert.notEqual(undefined, sampleDotJson.properties.request.archiving);
887
+ assert.notEqual(undefined, sampleDotJson.properties.request.return_request);
888
+ assert.notEqual(undefined, sampleDotJson.properties.proxy);
889
+ assert.notEqual(null, sampleDotJson.properties.proxy);
890
+ assert.notEqual('', sampleDotJson.properties.proxy);
891
+ assert.notEqual(undefined, sampleDotJson.properties.proxy.enabled);
892
+ assert.notEqual(undefined, sampleDotJson.properties.proxy.host);
893
+ assert.notEqual(undefined, sampleDotJson.properties.proxy.port);
894
+ assert.notEqual(undefined, sampleDotJson.properties.proxy.protocol);
895
+ assert.notEqual(undefined, sampleDotJson.properties.proxy.username);
896
+ assert.notEqual(undefined, sampleDotJson.properties.proxy.password);
897
+ assert.notEqual(undefined, sampleDotJson.properties.mongo);
898
+ assert.notEqual(null, sampleDotJson.properties.mongo);
899
+ assert.notEqual('', sampleDotJson.properties.mongo);
900
+ assert.notEqual(undefined, sampleDotJson.properties.mongo.host);
901
+ assert.notEqual(undefined, sampleDotJson.properties.mongo.port);
902
+ assert.notEqual(undefined, sampleDotJson.properties.mongo.database);
903
+ assert.notEqual(undefined, sampleDotJson.properties.mongo.username);
904
+ assert.notEqual(undefined, sampleDotJson.properties.mongo.password);
905
+ assert.notEqual(undefined, sampleDotJson.properties.mongo.replSet);
906
+ assert.notEqual(undefined, sampleDotJson.properties.mongo.db_ssl);
907
+ assert.notEqual(undefined, sampleDotJson.properties.mongo.db_ssl.enabled);
908
+ assert.notEqual(undefined, sampleDotJson.properties.mongo.db_ssl.accept_invalid_cert);
909
+ assert.notEqual(undefined, sampleDotJson.properties.mongo.db_ssl.ca_file);
910
+ assert.notEqual(undefined, sampleDotJson.properties.mongo.db_ssl.key_file);
911
+ assert.notEqual(undefined, sampleDotJson.properties.mongo.db_ssl.cert_file);
912
+ done();
913
+ } catch (error) {
914
+ log.error(`Test Failure: ${error}`);
915
+ done(error);
916
+ }
917
+ });
517
918
  });
518
919
 
519
920
  describe('#checkProperties', () => {
@@ -601,6 +1002,148 @@ describe('[unit] Vmware_vCenter Adapter Test', () => {
601
1002
  });
602
1003
  });
603
1004
 
1005
+ describe('#updateAdapterConfiguration', () => {
1006
+ it('should have a updateAdapterConfiguration function', (done) => {
1007
+ try {
1008
+ assert.equal(true, typeof a.updateAdapterConfiguration === 'function');
1009
+ done();
1010
+ } catch (error) {
1011
+ log.error(`Test Failure: ${error}`);
1012
+ done(error);
1013
+ }
1014
+ });
1015
+ });
1016
+
1017
+ describe('#findPath', () => {
1018
+ it('should have a findPath function', (done) => {
1019
+ try {
1020
+ assert.equal(true, typeof a.findPath === 'function');
1021
+ done();
1022
+ } catch (error) {
1023
+ log.error(`Test Failure: ${error}`);
1024
+ done(error);
1025
+ }
1026
+ });
1027
+ it('findPath should find atleast one path that matches', (done) => {
1028
+ try {
1029
+ a.findPath('{base_path}/{version}', (data, error) => {
1030
+ try {
1031
+ assert.equal(undefined, error);
1032
+ assert.notEqual(undefined, data);
1033
+ assert.notEqual(null, data);
1034
+ assert.equal(true, data.found);
1035
+ assert.notEqual(undefined, data.foundIn);
1036
+ assert.notEqual(null, data.foundIn);
1037
+ assert.notEqual(0, data.foundIn.length);
1038
+ done();
1039
+ } catch (err) {
1040
+ log.error(`Test Failure: ${err}`);
1041
+ done(err);
1042
+ }
1043
+ });
1044
+ } catch (error) {
1045
+ log.error(`Adapter Exception: ${error}`);
1046
+ done(error);
1047
+ }
1048
+ }).timeout(attemptTimeout);
1049
+ });
1050
+
1051
+ describe('#suspend', () => {
1052
+ it('should have a suspend function', (done) => {
1053
+ try {
1054
+ assert.equal(true, typeof a.suspend === 'function');
1055
+ done();
1056
+ } catch (error) {
1057
+ log.error(`Test Failure: ${error}`);
1058
+ done(error);
1059
+ }
1060
+ });
1061
+ });
1062
+
1063
+ describe('#unsuspend', () => {
1064
+ it('should have a unsuspend function', (done) => {
1065
+ try {
1066
+ assert.equal(true, typeof a.unsuspend === 'function');
1067
+ done();
1068
+ } catch (error) {
1069
+ log.error(`Test Failure: ${error}`);
1070
+ done(error);
1071
+ }
1072
+ });
1073
+ });
1074
+
1075
+ describe('#getQueue', () => {
1076
+ it('should have a getQueue function', (done) => {
1077
+ try {
1078
+ assert.equal(true, typeof a.getQueue === 'function');
1079
+ done();
1080
+ } catch (error) {
1081
+ log.error(`Test Failure: ${error}`);
1082
+ done(error);
1083
+ }
1084
+ });
1085
+ });
1086
+
1087
+ describe('#troubleshoot', () => {
1088
+ it('should have a troubleshoot function', (done) => {
1089
+ try {
1090
+ assert.equal(true, typeof a.troubleshoot === 'function');
1091
+ done();
1092
+ } catch (error) {
1093
+ log.error(`Test Failure: ${error}`);
1094
+ done(error);
1095
+ }
1096
+ });
1097
+ });
1098
+
1099
+ describe('#runHealthcheck', () => {
1100
+ it('should have a runHealthcheck function', (done) => {
1101
+ try {
1102
+ assert.equal(true, typeof a.runHealthcheck === 'function');
1103
+ done();
1104
+ } catch (error) {
1105
+ log.error(`Test Failure: ${error}`);
1106
+ done(error);
1107
+ }
1108
+ });
1109
+ });
1110
+
1111
+ describe('#runConnectivity', () => {
1112
+ it('should have a runConnectivity function', (done) => {
1113
+ try {
1114
+ assert.equal(true, typeof a.runConnectivity === 'function');
1115
+ done();
1116
+ } catch (error) {
1117
+ log.error(`Test Failure: ${error}`);
1118
+ done(error);
1119
+ }
1120
+ });
1121
+ });
1122
+
1123
+ describe('#runBasicGet', () => {
1124
+ it('should have a runBasicGet function', (done) => {
1125
+ try {
1126
+ assert.equal(true, typeof a.runBasicGet === 'function');
1127
+ done();
1128
+ } catch (error) {
1129
+ log.error(`Test Failure: ${error}`);
1130
+ done(error);
1131
+ }
1132
+ });
1133
+ });
1134
+
1135
+ describe('#moveEntitiesToDB', () => {
1136
+ it('should have a moveEntitiesToDB function', (done) => {
1137
+ try {
1138
+ assert.equal(true, typeof a.moveEntitiesToDB === 'function');
1139
+ done();
1140
+ } catch (error) {
1141
+ log.error(`Test Failure: ${error}`);
1142
+ done(error);
1143
+ }
1144
+ });
1145
+ });
1146
+
604
1147
  describe('#checkActionFiles', () => {
605
1148
  it('should have a checkActionFiles function', (done) => {
606
1149
  try {
@@ -730,6 +1273,90 @@ describe('[unit] Vmware_vCenter Adapter Test', () => {
730
1273
  // }).timeout(attemptTimeout);
731
1274
  // });
732
1275
 
1276
+ describe('#hasEntities', () => {
1277
+ it('should have a hasEntities function', (done) => {
1278
+ try {
1279
+ assert.equal(true, typeof a.hasEntities === 'function');
1280
+ done();
1281
+ } catch (error) {
1282
+ log.error(`Test Failure: ${error}`);
1283
+ done(error);
1284
+ }
1285
+ });
1286
+ });
1287
+
1288
+ describe('#hasDevices', () => {
1289
+ it('should have a hasDevices function', (done) => {
1290
+ try {
1291
+ assert.equal(true, typeof a.hasDevices === 'function');
1292
+ done();
1293
+ } catch (error) {
1294
+ log.error(`Test Failure: ${error}`);
1295
+ done(error);
1296
+ }
1297
+ });
1298
+ });
1299
+
1300
+ describe('#getDevice', () => {
1301
+ it('should have a getDevice function', (done) => {
1302
+ try {
1303
+ assert.equal(true, typeof a.getDevice === 'function');
1304
+ done();
1305
+ } catch (error) {
1306
+ log.error(`Test Failure: ${error}`);
1307
+ done(error);
1308
+ }
1309
+ });
1310
+ });
1311
+
1312
+ describe('#getDevicesFiltered', () => {
1313
+ it('should have a getDevicesFiltered function', (done) => {
1314
+ try {
1315
+ assert.equal(true, typeof a.getDevicesFiltered === 'function');
1316
+ done();
1317
+ } catch (error) {
1318
+ log.error(`Test Failure: ${error}`);
1319
+ done(error);
1320
+ }
1321
+ });
1322
+ });
1323
+
1324
+ describe('#isAlive', () => {
1325
+ it('should have a isAlive function', (done) => {
1326
+ try {
1327
+ assert.equal(true, typeof a.isAlive === 'function');
1328
+ done();
1329
+ } catch (error) {
1330
+ log.error(`Test Failure: ${error}`);
1331
+ done(error);
1332
+ }
1333
+ });
1334
+ });
1335
+
1336
+ describe('#getConfig', () => {
1337
+ it('should have a getConfig function', (done) => {
1338
+ try {
1339
+ assert.equal(true, typeof a.getConfig === 'function');
1340
+ done();
1341
+ } catch (error) {
1342
+ log.error(`Test Failure: ${error}`);
1343
+ done(error);
1344
+ }
1345
+ });
1346
+ });
1347
+
1348
+ describe('#getCount', () => {
1349
+ it('should have a getCount function', (done) => {
1350
+ try {
1351
+ assert.equal(true, typeof a.getCount === 'function');
1352
+ done();
1353
+ } catch (error) {
1354
+ log.error(`Test Failure: ${error}`);
1355
+ done(error);
1356
+ }
1357
+ });
1358
+ });
1359
+
733
1360
  /*
734
1361
  -----------------------------------------------------------------------
735
1362
  -----------------------------------------------------------------------
@@ -4224,5 +4851,51 @@ describe('[unit] Vmware_vCenter Adapter Test', () => {
4224
4851
  }
4225
4852
  }).timeout(attemptTimeout);
4226
4853
  });
4854
+
4855
+ describe('#postVcentervmtemplatedeploy - errors', () => {
4856
+ it('should have a postVcentervmtemplatedeploy function', (done) => {
4857
+ try {
4858
+ assert.equal(true, typeof a.postVcentervmtemplatedeploy === 'function');
4859
+ done();
4860
+ } catch (error) {
4861
+ log.error(`Test Failure: ${error}`);
4862
+ done(error);
4863
+ }
4864
+ }).timeout(attemptTimeout);
4865
+ it('should error if - missing item', (done) => {
4866
+ try {
4867
+ a.postVcentervmtemplatedeploy(null, null, (data, error) => {
4868
+ try {
4869
+ const displayE = 'item is required';
4870
+ runErrorAsserts(data, error, 'AD.300', 'Test-vmware_vcenter-adapter-postVcentervmtemplatedeploy', displayE);
4871
+ done();
4872
+ } catch (err) {
4873
+ log.error(`Test Failure: ${err}`);
4874
+ done(err);
4875
+ }
4876
+ });
4877
+ } catch (error) {
4878
+ log.error(`Adapter Exception: ${error}`);
4879
+ done(error);
4880
+ }
4881
+ }).timeout(attemptTimeout);
4882
+ it('should error if - missing requestBody', (done) => {
4883
+ try {
4884
+ a.postVcentervmtemplatedeploy('fakedata', null, (data, error) => {
4885
+ try {
4886
+ const displayE = 'requestBody is required';
4887
+ runErrorAsserts(data, error, 'AD.300', 'Test-vmware_vcenter-adapter-postVcentervmtemplatedeploy', displayE);
4888
+ done();
4889
+ } catch (err) {
4890
+ log.error(`Test Failure: ${err}`);
4891
+ done(err);
4892
+ }
4893
+ });
4894
+ } catch (error) {
4895
+ log.error(`Adapter Exception: ${error}`);
4896
+ done(error);
4897
+ }
4898
+ }).timeout(attemptTimeout);
4899
+ });
4227
4900
  });
4228
4901
  });