UNPKG

@itentialopensource/adapter-aws_ec2

Version:

This adapter integrates with system described as: Aws_Ec2.

1,325 lines (1,248 loc) 432 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 log = require('../../utils/logger'); const anything = td.matchers.anything(); // stub and attemptTimeout are used throughout the code so set them here 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-aws_ec2', type: 'Awsec2', properties: samProps }] } }; global.$HOME = `${__dirname}/../..`; /** * 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 Awsec2 = require('../../adapter'); // begin the testing - these should be pretty well defined between the describe and the it! describe('[integration] Awsec2 Adapter Test', () => { describe('Awsec2 Class Tests', () => { const a = new Awsec2( 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-aws_ec2-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-aws_ec2-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 actionAcceptReservedInstancesExchangeQuoteReservedInstanceId = []; describe('#acceptReservedInstancesExchangeQuote - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.acceptReservedInstancesExchangeQuote(null, actionAcceptReservedInstancesExchangeQuoteReservedInstanceId, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAcceptReservedInstancesExchangeQuote', 'acceptReservedInstancesExchangeQuote', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAcceptTransitGatewayVpcAttachmentTransitGatewayAttachmentId = 'fakedata'; describe('#acceptTransitGatewayVpcAttachment - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.acceptTransitGatewayVpcAttachment(actionAcceptTransitGatewayVpcAttachmentTransitGatewayAttachmentId, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAcceptTransitGatewayVpcAttachment', 'acceptTransitGatewayVpcAttachment', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAcceptVpcEndpointConnectionsServiceId = 'fakedata'; const actionAcceptVpcEndpointConnectionsVpcEndpointId = []; describe('#acceptVpcEndpointConnections - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.acceptVpcEndpointConnections(null, actionAcceptVpcEndpointConnectionsServiceId, actionAcceptVpcEndpointConnectionsVpcEndpointId, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAcceptVpcEndpointConnections', 'acceptVpcEndpointConnections', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#acceptVpcPeeringConnection - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.acceptVpcPeeringConnection(null, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAcceptVpcPeeringConnection', 'acceptVpcPeeringConnection', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAdvertiseByoipCidrCidr = 'fakedata'; describe('#advertiseByoipCidr - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.advertiseByoipCidr(actionAdvertiseByoipCidrCidr, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAdvertiseByoipCidr', 'advertiseByoipCidr', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#allocateAddress - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.allocateAddress(null, null, null, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAllocateAddress', 'allocateAddress', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAllocateHostsAvailabilityZone = 'fakedata'; const actionAllocateHostsInstanceType = 'fakedata'; const actionAllocateHostsQuantity = 555; describe('#allocateHosts - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.allocateHosts(null, actionAllocateHostsAvailabilityZone, null, actionAllocateHostsInstanceType, actionAllocateHostsQuantity, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAllocateHosts', 'allocateHosts', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionApplySecurityGroupsToClientVpnTargetNetworkClientVpnEndpointId = 'fakedata'; const actionApplySecurityGroupsToClientVpnTargetNetworkVpcId = 'fakedata'; const actionApplySecurityGroupsToClientVpnTargetNetworkSecurityGroupId = []; describe('#applySecurityGroupsToClientVpnTargetNetwork - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.applySecurityGroupsToClientVpnTargetNetwork(actionApplySecurityGroupsToClientVpnTargetNetworkClientVpnEndpointId, actionApplySecurityGroupsToClientVpnTargetNetworkVpcId, actionApplySecurityGroupsToClientVpnTargetNetworkSecurityGroupId, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionApplySecurityGroupsToClientVpnTargetNetwork', 'applySecurityGroupsToClientVpnTargetNetwork', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAssignIpv6AddressesNetworkInterfaceId = 'fakedata'; describe('#assignIpv6Addresses - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.assignIpv6Addresses(null, null, actionAssignIpv6AddressesNetworkInterfaceId, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAssignIpv6Addresses', 'assignIpv6Addresses', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAssignPrivateIpAddressesNetworkInterfaceId = 'fakedata'; describe('#assignPrivateIpAddresses - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.assignPrivateIpAddresses(null, actionAssignPrivateIpAddressesNetworkInterfaceId, null, null, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-aws_ec2-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('ActionAssignPrivateIpAddresses', 'assignPrivateIpAddresses', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#associateAddress - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.associateAddress(null, null, null, null, null, null, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAssociateAddress', 'associateAddress', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAssociateClientVpnTargetNetworkClientVpnEndpointId = 'fakedata'; const actionAssociateClientVpnTargetNetworkSubnetId = 'fakedata'; describe('#associateClientVpnTargetNetwork - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.associateClientVpnTargetNetwork(actionAssociateClientVpnTargetNetworkClientVpnEndpointId, actionAssociateClientVpnTargetNetworkSubnetId, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAssociateClientVpnTargetNetwork', 'associateClientVpnTargetNetwork', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAssociateDhcpOptionsDhcpOptionsId = 'fakedata'; const actionAssociateDhcpOptionsVpcId = 'fakedata'; describe('#associateDhcpOptions - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.associateDhcpOptions(actionAssociateDhcpOptionsDhcpOptionsId, actionAssociateDhcpOptionsVpcId, null, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-aws_ec2-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('ActionAssociateDhcpOptions', 'associateDhcpOptions', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAssociateIamInstanceProfileInstanceId = 'fakedata'; describe('#associateIamInstanceProfile - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.associateIamInstanceProfile(null, null, actionAssociateIamInstanceProfileInstanceId, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAssociateIamInstanceProfile', 'associateIamInstanceProfile', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAssociateRouteTableRouteTableId = 'fakedata'; const actionAssociateRouteTableSubnetId = 'fakedata'; describe('#associateRouteTable - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.associateRouteTable(null, actionAssociateRouteTableRouteTableId, actionAssociateRouteTableSubnetId, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAssociateRouteTable', 'associateRouteTable', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAssociateSubnetCidrBlockIpv6CidrBlock = 'fakedata'; const actionAssociateSubnetCidrBlockSubnetId = 'fakedata'; describe('#associateSubnetCidrBlock - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.associateSubnetCidrBlock(actionAssociateSubnetCidrBlockIpv6CidrBlock, actionAssociateSubnetCidrBlockSubnetId, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAssociateSubnetCidrBlock', 'associateSubnetCidrBlock', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAssociateTransitGatewayRouteTableTransitGatewayRouteTableId = 'fakedata'; const actionAssociateTransitGatewayRouteTableTransitGatewayAttachmentId = 'fakedata'; describe('#associateTransitGatewayRouteTable - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.associateTransitGatewayRouteTable(actionAssociateTransitGatewayRouteTableTransitGatewayRouteTableId, actionAssociateTransitGatewayRouteTableTransitGatewayAttachmentId, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAssociateTransitGatewayRouteTable', 'associateTransitGatewayRouteTable', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAssociateVpcCidrBlockVpcId = 'fakedata'; describe('#associateVpcCidrBlock - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.associateVpcCidrBlock(null, null, actionAssociateVpcCidrBlockVpcId, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAssociateVpcCidrBlock', 'associateVpcCidrBlock', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAttachClassicLinkVpcSecurityGroupId = []; const actionAttachClassicLinkVpcInstanceId = 'fakedata'; const actionAttachClassicLinkVpcVpcId = 'fakedata'; describe('#attachClassicLinkVpc - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.attachClassicLinkVpc(null, actionAttachClassicLinkVpcSecurityGroupId, actionAttachClassicLinkVpcInstanceId, actionAttachClassicLinkVpcVpcId, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAttachClassicLinkVpc', 'attachClassicLinkVpc', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAttachInternetGatewayInternetGatewayId = 'fakedata'; const actionAttachInternetGatewayVpcId = 'fakedata'; describe('#attachInternetGateway - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.attachInternetGateway(null, actionAttachInternetGatewayInternetGatewayId, actionAttachInternetGatewayVpcId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-aws_ec2-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('ActionAttachInternetGateway', 'attachInternetGateway', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAttachNetworkInterfaceDeviceIndex = 555; const actionAttachNetworkInterfaceInstanceId = 'fakedata'; const actionAttachNetworkInterfaceNetworkInterfaceId = 'fakedata'; describe('#attachNetworkInterface - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.attachNetworkInterface(actionAttachNetworkInterfaceDeviceIndex, null, actionAttachNetworkInterfaceInstanceId, actionAttachNetworkInterfaceNetworkInterfaceId, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAttachNetworkInterface', 'attachNetworkInterface', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAttachVolumeDevice = 'fakedata'; const actionAttachVolumeInstanceId = 'fakedata'; const actionAttachVolumeVolumeId = 'fakedata'; describe('#attachVolume - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.attachVolume(actionAttachVolumeDevice, actionAttachVolumeInstanceId, actionAttachVolumeVolumeId, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAttachVolume', 'attachVolume', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAttachVpnGatewayVpcId = 'fakedata'; const actionAttachVpnGatewayVpnGatewayId = 'fakedata'; describe('#attachVpnGateway - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.attachVpnGateway(actionAttachVpnGatewayVpcId, actionAttachVpnGatewayVpnGatewayId, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAttachVpnGateway', 'attachVpnGateway', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAuthorizeClientVpnIngressClientVpnEndpointId = 'fakedata'; const actionAuthorizeClientVpnIngressTargetNetworkCidr = 'fakedata'; describe('#authorizeClientVpnIngress - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.authorizeClientVpnIngress(actionAuthorizeClientVpnIngressClientVpnEndpointId, actionAuthorizeClientVpnIngressTargetNetworkCidr, null, null, null, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionAuthorizeClientVpnIngress', 'authorizeClientVpnIngress', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionAuthorizeSecurityGroupEgressGroupId = 'fakedata'; describe('#authorizeSecurityGroupEgress - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.authorizeSecurityGroupEgress(null, actionAuthorizeSecurityGroupEgressGroupId, null, null, null, null, null, null, null, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-aws_ec2-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('ActionAuthorizeSecurityGroupEgress', 'authorizeSecurityGroupEgress', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#authorizeSecurityGroupIngress - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.authorizeSecurityGroupIngress(null, null, null, null, null, null, null, null, null, null, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-aws_ec2-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('ActionAuthorizeSecurityGroupIngress', 'authorizeSecurityGroupIngress', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionBundleInstanceInstanceId = 'fakedata'; describe('#bundleInstance - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.bundleInstance(actionBundleInstanceInstanceId, null, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionBundleInstance', 'bundleInstance', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionCancelBundleTaskBundleId = 'fakedata'; describe('#cancelBundleTask - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.cancelBundleTask(actionCancelBundleTaskBundleId, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionCancelBundleTask', 'cancelBundleTask', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionCancelCapacityReservationCapacityReservationId = 'fakedata'; describe('#cancelCapacityReservation - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.cancelCapacityReservation(actionCancelCapacityReservationCapacityReservationId, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionCancelCapacityReservation', 'cancelCapacityReservation', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionCancelConversionTaskConversionTaskId = 'fakedata'; describe('#cancelConversionTask - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.cancelConversionTask(actionCancelConversionTaskConversionTaskId, null, null, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-aws_ec2-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('ActionCancelConversionTask', 'cancelConversionTask', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionCancelExportTaskExportTaskId = 'fakedata'; describe('#cancelExportTask - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.cancelExportTask(actionCancelExportTaskExportTaskId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-aws_ec2-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('ActionCancelExportTask', 'cancelExportTask', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#cancelImportTask - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.cancelImportTask(null, null, null, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionCancelImportTask', 'cancelImportTask', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionCancelReservedInstancesListingReservedInstancesListingId = 'fakedata'; describe('#cancelReservedInstancesListing - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.cancelReservedInstancesListing(actionCancelReservedInstancesListingReservedInstancesListingId, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else { runCommonAsserts(data, error); } saveMockData('ActionCancelReservedInstancesListing', 'cancelReservedInstancesListing', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const actionCancelSpotFleetRequestsSpotFleetRequestId = []; const actionCancelSpotFleetRequestsTerminateInstances = true; describe('#cancelSpotFleetRequests - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.cancelSpotFleetRequests(null, actionCancelSpotFleetRequestsSpotFleetRequestId, actionCancelSpotFleetRequestsTerminateInstances, (data, error) => { try { runCommonAsserts(data, error); if (stub) { assert.equal('object', typeof data.response); } else