UNPKG

@itentialopensource/adapter-hashicorp_vault

Version:

This adapter integrates with system described as: hashicorp_vault.

1,501 lines (1,427 loc) 838 kB
/* @copyright Itential, LLC 2019 (pre-modifications) */ // Set globals /* global describe it log pronghornProps */ /* eslint no-unused-vars: warn */ /* eslint no-underscore-dangle: warn */ /* eslint import/no-dynamic-require:warn */ // include required items for testing & logging const assert = require('assert'); const fs = require('fs'); const path = require('path'); const util = require('util'); const mocha = require('mocha'); const winston = require('winston'); const { expect } = require('chai'); const { use } = require('chai'); const td = require('testdouble'); const anything = td.matchers.anything(); // stub and attemptTimeout are used throughout the code so set them here let logLevel = 'none'; const isRapidFail = false; const isSaveMockData = false; // read in the properties from the sampleProperties files let adaptdir = __dirname; if (adaptdir.endsWith('/test/integration')) { adaptdir = adaptdir.substring(0, adaptdir.length - 17); } else if (adaptdir.endsWith('/test/unit')) { adaptdir = adaptdir.substring(0, adaptdir.length - 10); } const samProps = require(`${adaptdir}/sampleProperties.json`).properties; // these variables can be changed to run in integrated mode so easier to set them here // always check these in with bogus data!!! samProps.stub = true; // uncomment if connecting // samProps.host = 'replace.hostorip.here'; // samProps.authentication.username = 'username'; // samProps.authentication.password = 'password'; // samProps.authentication.token = 'password'; // samProps.protocol = 'http'; // samProps.port = 80; // samProps.ssl.enabled = false; // samProps.ssl.accept_invalid_cert = false; if (samProps.request.attempt_timeout < 30000) { samProps.request.attempt_timeout = 30000; } samProps.devicebroker.enabled = true; const attemptTimeout = samProps.request.attempt_timeout; const { stub } = samProps; // these are the adapter properties. You generally should not need to alter // any of these after they are initially set up global.pronghornProps = { pathProps: { encrypted: false }, adapterProps: { adapters: [{ id: 'Test-hashicorp_vault', type: 'HashiCorpVault', properties: samProps }] } }; global.$HOME = `${__dirname}/../..`; // set the log levels that Pronghorn uses, spam and trace are not defaulted in so without // this you may error on log.trace calls. const myCustomLevels = { levels: { spam: 6, trace: 5, debug: 4, info: 3, warn: 2, error: 1, none: 0 } }; // need to see if there is a log level passed in process.argv.forEach((val) => { // is there a log level defined to be passed in? if (val.indexOf('--LOG') === 0) { // get the desired log level const inputVal = val.split('=')[1]; // validate the log level is supported, if so set it if (Object.hasOwnProperty.call(myCustomLevels.levels, inputVal)) { logLevel = inputVal; } } }); // need to set global logging global.log = winston.createLogger({ level: logLevel, levels: myCustomLevels.levels, transports: [ new winston.transports.Console() ] }); /** * Runs the common asserts for test */ function runCommonAsserts(data, error) { assert.equal(undefined, error); assert.notEqual(undefined, data); assert.notEqual(null, data); assert.notEqual(undefined, data.response); assert.notEqual(null, data.response); } /** * Runs the error asserts for the test */ function runErrorAsserts(data, error, code, origin, displayStr) { assert.equal(null, data); assert.notEqual(undefined, error); assert.notEqual(null, error); assert.notEqual(undefined, error.IAPerror); assert.notEqual(null, error.IAPerror); assert.notEqual(undefined, error.IAPerror.displayString); assert.notEqual(null, error.IAPerror.displayString); assert.equal(code, error.icode); assert.equal(origin, error.IAPerror.origin); assert.equal(displayStr, error.IAPerror.displayString); } /** * @function saveMockData * Attempts to take data from responses and place them in MockDataFiles to help create Mockdata. * Note, this was built based on entity file structure for Adapter-Engine 1.6.x * @param {string} entityName - Name of the entity saving mock data for * @param {string} actionName - Name of the action saving mock data for * @param {string} descriptor - Something to describe this test (used as a type) * @param {string or object} responseData - The data to put in the mock file. */ function saveMockData(entityName, actionName, descriptor, responseData) { // do not need to save mockdata if we are running in stub mode (already has mock data) or if told not to save if (stub || !isSaveMockData) { return false; } // must have a response in order to store the response if (responseData && responseData.response) { let data = responseData.response; // if there was a raw response that one is better as it is untranslated if (responseData.raw) { data = responseData.raw; try { const temp = JSON.parse(data); data = temp; } catch (pex) { // do not care if it did not parse as we will just use data } } try { const base = path.join(__dirname, `../../entities/${entityName}/`); const mockdatafolder = 'mockdatafiles'; const filename = `mockdatafiles/${actionName}-${descriptor}.json`; if (!fs.existsSync(base + mockdatafolder)) { fs.mkdirSync(base + mockdatafolder); } // write the data we retrieved fs.writeFile(base + filename, JSON.stringify(data, null, 2), 'utf8', (errWritingMock) => { if (errWritingMock) throw errWritingMock; // update the action file to reflect the changes. Note: We're replacing the default object for now! fs.readFile(`${base}action.json`, (errRead, content) => { if (errRead) throw errRead; // parse the action file into JSON const parsedJson = JSON.parse(content); // The object update we'll write in. const responseObj = { type: descriptor, key: '', mockFile: filename }; // get the object for method we're trying to change. const currentMethodAction = parsedJson.actions.find((obj) => obj.name === actionName); // if the method was not found - should never happen but... if (!currentMethodAction) { throw Error('Can\'t find an action for this method in the provided entity.'); } // if there is a response object, we want to replace the Response object. Otherwise we'll create one. const actionResponseObj = currentMethodAction.responseObjects.find((obj) => obj.type === descriptor); // Add the action responseObj back into the array of response objects. if (!actionResponseObj) { // if there is a default response object, we want to get the key. const defaultResponseObj = currentMethodAction.responseObjects.find((obj) => obj.type === 'default'); // save the default key into the new response object if (defaultResponseObj) { responseObj.key = defaultResponseObj.key; } // save the new response object currentMethodAction.responseObjects = [responseObj]; } else { // update the location of the mock data file actionResponseObj.mockFile = responseObj.mockFile; } // Save results fs.writeFile(`${base}action.json`, JSON.stringify(parsedJson, null, 2), (err) => { if (err) throw err; }); }); }); } catch (e) { log.debug(`Failed to save mock data for ${actionName}. ${e.message}`); return false; } } // no response to save log.debug(`No data passed to save into mockdata for ${actionName}`); return false; } // require the adapter that we are going to be using const HashiCorpVault = require('../../adapter'); // begin the testing - these should be pretty well defined between the describe and the it! describe('[integration] HashiCorpVault Adapter Test', () => { describe('HashiCorpVault Class Tests', () => { const a = new HashiCorpVault( pronghornProps.adapterProps.adapters[0].id, pronghornProps.adapterProps.adapters[0].properties ); if (isRapidFail) { const state = {}; state.passed = true; mocha.afterEach(function x() { state.passed = state.passed && (this.currentTest.state === 'passed'); }); mocha.beforeEach(function x() { if (!state.passed) { return this.currentTest.skip(); } return true; }); } describe('#class instance created', () => { it('should be a class with properties', (done) => { try { assert.notEqual(null, a); assert.notEqual(undefined, a); const checkId = global.pronghornProps.adapterProps.adapters[0].id; assert.equal(checkId, a.id); assert.notEqual(null, a.allProps); const check = global.pronghornProps.adapterProps.adapters[0].properties.healthcheck.type; assert.equal(check, a.healthcheckType); done(); } catch (error) { log.error(`Test Failure: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#connect', () => { it('should get connected - no healthcheck', (done) => { try { a.healthcheckType = 'none'; a.connect(); try { assert.equal(true, a.alive); done(); } catch (error) { log.error(`Test Failure: ${error}`); done(error); } } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }); it('should get connected - startup healthcheck', (done) => { try { a.healthcheckType = 'startup'; a.connect(); try { assert.equal(true, a.alive); done(); } catch (error) { log.error(`Test Failure: ${error}`); done(error); } } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }); }); describe('#healthCheck', () => { it('should be healthy', (done) => { try { a.healthCheck(null, (data) => { try { assert.equal(true, a.healthy); saveMockData('system', 'healthcheck', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); // broker tests describe('#getDevicesFiltered - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { const opts = { filter: { name: 'deviceName' } }; a.getDevicesFiltered(opts, (data, error) => { try { if (stub) { if (samProps.devicebroker.getDevicesFiltered[0].handleFailure === 'ignore') { assert.equal(null, error); assert.notEqual(undefined, data); assert.notEqual(null, data); assert.equal(0, data.total); assert.equal(0, data.list.length); } else { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } } else { runCommonAsserts(data, error); } done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#iapGetDeviceCount - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { const opts = { filter: { name: 'deviceName' } }; a.iapGetDeviceCount((data, error) => { try { if (stub) { if (samProps.devicebroker.getDevicesFiltered[0].handleFailure === 'ignore') { assert.equal(null, error); assert.notEqual(undefined, data); assert.notEqual(null, data); assert.equal(0, data.count); } else { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } } else { runCommonAsserts(data, error); } done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); // exposed cache tests describe('#iapPopulateEntityCache - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.iapPopulateEntityCache('Device', (data, error) => { try { if (stub) { assert.equal(null, data); assert.notEqual(undefined, error); assert.notEqual(null, error); done(); } else { assert.equal(undefined, error); assert.equal('success', data[0]); done(); } } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#iapRetrieveEntitiesCache - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.iapRetrieveEntitiesCache('Device', {}, (data, error) => { try { if (stub) { assert.equal(null, data); assert.notEqual(null, error); assert.notEqual(undefined, error); } else { assert.equal(undefined, error); assert.notEqual(null, data); assert.notEqual(undefined, data); } done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); /* ----------------------------------------------------------------------- ----------------------------------------------------------------------- *** All code above this comment will be replaced during a migration *** ******************* DO NOT REMOVE THIS COMMENT BLOCK ****************** ----------------------------------------------------------------------- ----------------------------------------------------------------------- */ const secretsPostSecretConfigBodyParam = { cas_required: true, delete_version_after: 6, max_versions: 8 }; describe('#postKvSecretConfig - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postKvSecretConfig('namespace', 'mount', secretsPostSecretConfigBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postKvSecretConfig', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPathParam = 'fakedata'; const secretsPostSecretDataPathBodyParam = { data: {}, options: {}, version: 2 }; describe('#postKvSecretDataPath - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postKvSecretDataPath('namespace', 'mount', secretsPathParam, secretsPostSecretDataPathBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postKvSecretDataPath', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretDeletePathBodyParam = { versions: [ 3 ] }; describe('#postKvSecretDeletePath - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postKvSecretDeletePath('namespace', 'mount', secretsPathParam, secretsPostSecretDeletePathBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postKvSecretDeletePath', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretDestroyPathBodyParam = { versions: [ 6 ] }; describe('#postKvSecretDestroyPath - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postKvSecretDestroyPath('namespace', 'mount', secretsPathParam, secretsPostSecretDestroyPathBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postKvSecretDestroyPath', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretMetadataPathBodyParam = { cas_required: false, delete_version_after: 9, max_versions: 6 }; describe('#postKvSecretMetadataPath - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postKvSecretMetadataPath('namespace', 'mount', secretsPathParam, secretsPostSecretMetadataPathBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postKvSecretMetadataPath', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretUndeletePathBodyParam = { versions: [ 8 ] }; describe('#postKvSecretUndeletePath - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postKvSecretUndeletePath('namespace', 'mount', secretsPathParam, secretsPostSecretUndeletePathBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postKvSecretUndeletePath', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#postCubbyholeSecretPath - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postCubbyholeSecretPath('namespace', 'mount', secretsPathParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postCubbyholeSecretPath', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretConfigCaBodyParam = { pem_bundle: 'string' }; describe('#postPkiSecretConfigCa - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretConfigCa('namespace', 'mount', secretsPostSecretConfigCaBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretConfigCa', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretConfigCrlBodyParam = { disable: false, expiry: '72h' }; describe('#postPkiSecretConfigCrl - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretConfigCrl('namespace', 'mount', secretsPostSecretConfigCrlBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretConfigCrl', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretConfigUrlsBodyParam = { crl_distribution_points: [ 'string' ], issuing_certificates: [ 'string' ], ocsp_servers: [ 'string' ] }; describe('#postPkiSecretConfigUrls - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretConfigUrls('namespace', 'mount', secretsPostSecretConfigUrlsBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretConfigUrls', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsExported = 'fakedata'; const secretsPostSecretIntermediateGenerateExportedBodyParam = { add_basic_constraints: true, alt_names: 'string', common_name: 'string', country: [ 'string' ], exclude_cn_from_sans: false, format: 'pem', ip_sans: [ 'string' ], key_bits: 2048, key_type: 'rsa', locality: [ 'string' ], organization: [ 'string' ], other_sans: [ 'string' ], ou: [ 'string' ], postal_code: [ 'string' ], private_key_format: 'der', province: [ 'string' ], serial_number: 'string', street_address: [ 'string' ], ttl: 10, uri_sans: [ 'string' ] }; describe('#postPkiSecretGenerateIntermediate - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretGenerateIntermediate('namespace', 'mount', secretsExported, secretsPostSecretIntermediateGenerateExportedBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretGenerateIntermediate', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretIntermediateSetSignedBodyParam = { certificate: 'string' }; describe('#postPkiSecretSetSignedIntermediate - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretSetSignedIntermediate('namespace', 'mount', secretsPostSecretIntermediateSetSignedBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretSetSignedIntermediate', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsRole = 'fakedata'; const secretsPostSecretIssueRoleBodyParam = { alt_names: 'string', common_name: 'string', exclude_cn_from_sans: false, format: 'pem', ip_sans: [ 'string' ], other_sans: [ 'string' ], private_key_format: 'der', serial_number: 'string', ttl: 3, uri_sans: [ 'string' ] }; describe('#postPkiSecretIssueCert - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretIssueCert('namespace', 'mount', secretsRole, secretsPostSecretIssueRoleBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretIssueCert', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretRevokeBodyParam = { serial_number: 'string' }; describe('#postPkiSecretRevokeCert - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretRevokeCert('namespace', 'mount', secretsPostSecretRevokeBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretRevokeCert', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsName = 'fakedata'; const secretsPostSecretRolesNameBodyParam = { allow_any_name: true, allow_bare_domains: false, allow_glob_domains: true, allow_ip_sans: true, allow_localhost: true, allow_subdomains: true, allowed_domains: [ 'string' ], allowed_domains_template: false, allowed_other_sans: [ 'string' ], allowed_serial_numbers: [ 'string' ], allowed_uri_sans: [ 'string' ], backend: 'string', basic_constraints_valid_for_non_ca: false, client_flag: true, code_signing_flag: false, country: [ 'string' ], email_protection_flag: true, enforce_hostnames: true, ext_key_usage: [], ext_key_usage_oids: [ 'string' ], generate_lease: true, key_bits: 2048, key_type: 'rsa', key_usage: [ 'DigitalSignature', 'KeyAgreement', 'KeyEncipherment' ], locality: [ 'string' ], max_ttl: 5, no_store: false, not_before_duration: 30, organization: [ 'string' ], ou: [ 'string' ], policy_identifiers: [ 'string' ], postal_code: [ 'string' ], province: [ 'string' ], require_cn: true, server_flag: true, street_address: [ 'string' ], ttl: 7, use_csr_common_name: true, use_csr_sans: true }; describe('#postPkiSecretRolesName - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretRolesName('namespace', 'mount', secretsName, secretsPostSecretRolesNameBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretRolesName', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretRootGenerateExportedBodyParam = { alt_names: 'string', common_name: 'string', country: [ 'string' ], exclude_cn_from_sans: true, format: 'pem', ip_sans: [ 'string' ], key_bits: 2048, key_type: 'rsa', locality: [ 'string' ], max_path_length: -1, organization: [ 'string' ], other_sans: [ 'string' ], ou: [ 'string' ], permitted_dns_domains: [ 'string' ], postal_code: [ 'string' ], private_key_format: 'der', province: [ 'string' ], serial_number: 'string', street_address: [ 'string' ], ttl: 6, uri_sans: [ 'string' ] }; describe('#postPkiSecretGenerateRoot - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretGenerateRoot('namespace', 'mount', secretsExported, secretsPostSecretRootGenerateExportedBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretGenerateRoot', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretRootSignIntermediateBodyParam = { alt_names: 'string', common_name: 'string', country: [ 'string' ], csr: 'string', exclude_cn_from_sans: true, format: 'pem', ip_sans: [ 'string' ], locality: [ 'string' ], max_path_length: -1, organization: [ 'string' ], other_sans: [ 'string' ], ou: [ 'string' ], permitted_dns_domains: [ 'string' ], postal_code: [ 'string' ], private_key_format: 'der', province: [ 'string' ], serial_number: 'string', street_address: [ 'string' ], ttl: 1, uri_sans: [ 'string' ], use_csr_values: false }; describe('#postPkiSecretSignIntermediateRoot - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretSignIntermediateRoot('namespace', 'mount', secretsPostSecretRootSignIntermediateBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretSignIntermediateRoot', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretRootSignSelfIssuedBodyParam = { certificate: 'string' }; describe('#postPkiSecretRootSignSelfIssued - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretRootSignSelfIssued('namespace', 'mount', secretsPostSecretRootSignSelfIssuedBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretRootSignSelfIssued', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretSignVerbatimBodyParam = { alt_names: 'string', common_name: 'string', csr: 'string', exclude_cn_from_sans: false, ext_key_usage: [], ext_key_usage_oids: [ 'string' ], format: 'pem', ip_sans: [ 'string' ], key_usage: [ 'DigitalSignature', 'KeyAgreement', 'KeyEncipherment' ], other_sans: [ 'string' ], private_key_format: 'der', role: 'string', serial_number: 'string', ttl: 4, uri_sans: [ 'string' ] }; describe('#postPkiSecretSignVerbatim - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretSignVerbatim('namespace', 'mount', secretsPostSecretSignVerbatimBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretSignVerbatim', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretSignVerbatimRoleBodyParam = { alt_names: 'string', common_name: 'string', csr: 'string', exclude_cn_from_sans: false, ext_key_usage: [], ext_key_usage_oids: [ 'string' ], format: 'pem', ip_sans: [ 'string' ], key_usage: [ 'DigitalSignature', 'KeyAgreement', 'KeyEncipherment' ], other_sans: [ 'string' ], private_key_format: 'der', serial_number: 'string', ttl: 8, uri_sans: [ 'string' ] }; describe('#postPkiSecretSignVerbatimName - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretSignVerbatimName('namespace', 'mount', secretsRole, secretsPostSecretSignVerbatimRoleBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretSignVerbatimName', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretSignRoleBodyParam = { alt_names: 'string', common_name: 'string', csr: 'string', exclude_cn_from_sans: false, format: 'pem', ip_sans: [ 'string' ], other_sans: [ 'string' ], private_key_format: 'der', serial_number: 'string', ttl: 4, uri_sans: [ 'string' ] }; describe('#postPkiSecretSignRole - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretSignRole('namespace', 'mount', secretsRole, secretsPostSecretSignRoleBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretSignRole', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const secretsPostSecretTidyBodyParam = { safety_buffer: 259200, tidy_cert_store: false, tidy_revocation_list: false, tidy_revoked_certs: false }; describe('#postPkiSecretTidy - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.postPkiSecretTidy('namespace', 'mount', secretsPostSecretTidyBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'postPkiSecretTidy', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getKvSecretConfig - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getKvSecretConfig('namespace', 'mount', (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'getKvSecretConfig', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getKvSecretDataPath - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getKvSecretDataPath('namespace', 'mount', secretsPathParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'getKvSecretDataPath', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getKvSecretMetadataPath - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getKvSecretMetadataPath('namespace', 'mount', secretsPathParam, null, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'getKvSecretMetadataPath', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getCubbyholeSecretPath - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getCubbyholeSecretPath('namespace', 'mount', secretsPathParam, null, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-hashicorp_vault-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Secrets', 'getCubbyholeSecretPath', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getPkiSecretCa - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getPkiSecretCa('namespace', 'mount', (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAss