UNPKG

@itentialopensource/adapter-velocloud_orchestrator

Version:

This adapter integrates with system described as: velocloudOrchestratorApi.

1,387 lines (1,313 loc) 222 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-velocloud_orchestrator', type: 'VelocloudOrchestrator', 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 VelocloudOrchestrator = require('../../adapter'); // begin the testing - these should be pretty well defined between the describe and the it! describe('[integration] VelocloudOrchestrator Adapter Test', () => { describe('VelocloudOrchestrator Class Tests', () => { const a = new VelocloudOrchestrator( 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-velocloud_orchestrator-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-velocloud_orchestrator-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 allConfigurationCloneEnterpriseTemplateBodyParam = { enterpriseId: 9, configurationType: 'NETWORK_BASED', name: 'string', description: 'string' }; describe('#configurationCloneEnterpriseTemplate - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.configurationCloneEnterpriseTemplate(allConfigurationCloneEnterpriseTemplateBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(7, data.response.id); } else { runCommonAsserts(data, error); } saveMockData('All', 'configurationCloneEnterpriseTemplate', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allConfigurationDeleteConfigurationBodyParam = { id: 6 }; describe('#configurationDeleteConfiguration - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.configurationDeleteConfiguration(allConfigurationDeleteConfigurationBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(123, data.response.id); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'configurationDeleteConfiguration', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allConfigurationGetConfigurationBodyParam = { id: 10 }; describe('#configurationGetConfiguration - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.configurationGetConfiguration(allConfigurationGetConfigurationBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal('SEGMENT_BASED', data.response.configurationType); assert.equal('string', data.response.created); assert.equal('string', data.response.description); assert.equal(4, data.response.edgeCount); assert.equal('string', data.response.effective); assert.equal(3, data.response.id); assert.equal('string', data.response.logicalId); assert.equal('string', data.response.modified); assert.equal(true, Array.isArray(data.response.modules)); assert.equal('string', data.response.name); assert.equal('string', data.response.schemaVersion); assert.equal('string', data.response.version); } else { runCommonAsserts(data, error); } saveMockData('All', 'configurationGetConfiguration', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allConfigurationGetIdentifiableApplicationsBodyParam = { enterpriseId: 8 }; describe('#configurationGetIdentifiableApplications - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.configurationGetIdentifiableApplications(allConfigurationGetIdentifiableApplicationsBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal('object', typeof data.response.applicationClassToApplication); assert.equal('object', typeof data.response.applicationToApplicationClass); assert.equal(true, Array.isArray(data.response.applications)); } else { runCommonAsserts(data, error); } saveMockData('All', 'configurationGetIdentifiableApplications', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allConfigurationGetRoutableApplicationsBodyParam = { enterpriseId: 5, edgeId: 6 }; describe('#configurationGetRoutableApplications - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.configurationGetRoutableApplications(allConfigurationGetRoutableApplicationsBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal('object', typeof data.response.applicationClassToApplication); assert.equal('object', typeof data.response.applicationToApplicationClass); assert.equal(true, Array.isArray(data.response.applications)); assert.equal('object', typeof data.response.metaData); } else { runCommonAsserts(data, error); } saveMockData('All', 'configurationGetRoutableApplications', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allDisasterRecoveryConfigureActiveForReplicationBodyParam = { standbyList: [ {} ], drVCOUser: 'string', drVCOPassword: 'string' }; describe('#disasterRecoveryConfigureActiveForReplication - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.disasterRecoveryConfigureActiveForReplication(allDisasterRecoveryConfigureActiveForReplicationBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'disasterRecoveryConfigureActiveForReplication', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allDisasterRecoveryDemoteActiveBodyParam = { force: true }; describe('#disasterRecoveryDemoteActive - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.disasterRecoveryDemoteActive(allDisasterRecoveryDemoteActiveBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'disasterRecoveryDemoteActive', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allDisasterRecoveryGetReplicationBlobBodyParam = {}; describe('#disasterRecoveryGetReplicationBlob - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.disasterRecoveryGetReplicationBlob(allDisasterRecoveryGetReplicationBlobBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal('string', data.response.activeAccessFromStandby); } else { runCommonAsserts(data, error); } saveMockData('All', 'disasterRecoveryGetReplicationBlob', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allDisasterRecoveryGetReplicationStatusBodyParam = { with: [ 'storageInfo' ] }; describe('#disasterRecoveryGetReplicationStatus - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.disasterRecoveryGetReplicationStatus(allDisasterRecoveryGetReplicationStatusBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal('string', data.response.activeAddress); assert.equal('string', data.response.activeReplicationAddress); assert.equal(true, Array.isArray(data.response.clientContact)); assert.equal('object', typeof data.response.clientCount); assert.equal('STANDBY_BACKGROUND_IMPORT', data.response.drState); assert.equal('string', data.response.drVCOUser); assert.equal('string', data.response.failureDescription); assert.equal('string', data.response.lastDrProtectedTime); assert.equal('ZOMBIE', data.response.role); assert.equal('string', data.response.roleTimestamp); assert.equal(true, Array.isArray(data.response.standbyList)); assert.equal(true, Array.isArray(data.response.stateHistory)); assert.equal('string', data.response.stateTimestamp); assert.equal('string', data.response.vcoIp); assert.equal('string', data.response.vcoReplicationIp); assert.equal('string', data.response.vcoUuid); } else { runCommonAsserts(data, error); } saveMockData('All', 'disasterRecoveryGetReplicationStatus', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allDisasterRecoveryPrepareForStandbyBodyParam = {}; describe('#disasterRecoveryPrepareForStandby - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.disasterRecoveryPrepareForStandby(allDisasterRecoveryPrepareForStandbyBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'disasterRecoveryPrepareForStandby', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allDisasterRecoveryPromoteStandbyToActiveBodyParam = { force: true }; describe('#disasterRecoveryPromoteStandbyToActive - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.disasterRecoveryPromoteStandbyToActive(allDisasterRecoveryPromoteStandbyToActiveBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'disasterRecoveryPromoteStandbyToActive', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allDisasterRecoveryRemoveStandbyBodyParam = {}; describe('#disasterRecoveryRemoveStandby - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.disasterRecoveryRemoveStandby(allDisasterRecoveryRemoveStandbyBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'disasterRecoveryRemoveStandby', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allDisasterRecoveryTransitionToStandbyBodyParam = { activeAccessFromStandby: 'string' }; describe('#disasterRecoveryTransitionToStandby - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.disasterRecoveryTransitionToStandby(allDisasterRecoveryTransitionToStandbyBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'disasterRecoveryTransitionToStandby', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEdgeDeleteEdgeBodyParam = { enterpriseId: 3, id: 6, ids: [ 7 ] }; describe('#edgeDeleteEdge - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.edgeDeleteEdge(allEdgeDeleteEdgeBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal('object', typeof data.response[0]); assert.equal('object', typeof data.response[1]); } else { runCommonAsserts(data, error); } saveMockData('All', 'edgeDeleteEdge', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEdgeDeleteEdgeBgpNeighborRecordsBodyParam = { records: [ { edgeId: 4, neighborIp: 'string' } ] }; describe('#edgeDeleteEdgeBgpNeighborRecords - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.edgeDeleteEdgeBgpNeighborRecords(allEdgeDeleteEdgeBgpNeighborRecordsBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(123, data.response.id); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'edgeDeleteEdgeBgpNeighborRecords', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEdgeSetEdgeEnterpriseConfigurationBodyParam = { configurationId: 5 }; describe('#edgeSetEdgeEnterpriseConfiguration - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.edgeSetEdgeEnterpriseConfiguration(allEdgeSetEdgeEnterpriseConfigurationBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(123, data.response.id); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'edgeSetEdgeEnterpriseConfiguration', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEdgeSetEdgeHandOffGatewaysBodyParam = { edgeId: 2, enterpriseId: 2, gateways: { primary: 1, primaryIpsecDetail: { ipsecGatewayAddress: 'string', strictHostCheck: false, strictHostCheckDN: 'string' }, secondary: 8, secondaryIpsecDetail: { ipsecGatewayAddress: 'string', strictHostCheck: false, strictHostCheckDN: 'string' } } }; describe('#edgeSetEdgeHandOffGateways - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.edgeSetEdgeHandOffGateways(allEdgeSetEdgeHandOffGatewaysBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'edgeSetEdgeHandOffGateways', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEdgeSetEdgeOperatorConfigurationBodyParam = { edgeId: 4, configurationId: 9 }; describe('#edgeSetEdgeOperatorConfiguration - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.edgeSetEdgeOperatorConfiguration(allEdgeSetEdgeOperatorConfigurationBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(123, data.response.id); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'edgeSetEdgeOperatorConfiguration', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseDeleteEnterpriseBodyParam = { enterpriseId: 5 }; describe('#enterpriseDeleteEnterprise - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.enterpriseDeleteEnterprise(allEnterpriseDeleteEnterpriseBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(123, data.response.id); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'enterpriseDeleteEnterprise', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseDeleteEnterpriseGatewayRecordsBodyParam = { records: [ { gatewayId: 8, neighborIp: 'string' } ] }; describe('#enterpriseDeleteEnterpriseGatewayRecords - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.enterpriseDeleteEnterpriseGatewayRecords(allEnterpriseDeleteEnterpriseGatewayRecordsBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(123, data.response.id); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'enterpriseDeleteEnterpriseGatewayRecords', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseDeleteEnterpriseNetworkAllocationBodyParam = { id: 7 }; describe('#enterpriseDeleteEnterpriseNetworkAllocation - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.enterpriseDeleteEnterpriseNetworkAllocation(allEnterpriseDeleteEnterpriseNetworkAllocationBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(123, data.response.id); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'enterpriseDeleteEnterpriseNetworkAllocation', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseDeleteEnterpriseNetworkSegmentBodyParam = { id: 1 }; describe('#enterpriseDeleteEnterpriseNetworkSegment - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.enterpriseDeleteEnterpriseNetworkSegment(allEnterpriseDeleteEnterpriseNetworkSegmentBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(10, data.response.id); assert.equal('string', data.response.error); assert.equal(8, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'enterpriseDeleteEnterpriseNetworkSegment', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseDeleteEnterpriseServiceBodyParam = { id: 6, logicalId: 'string', enterpriseId: 10 }; describe('#enterpriseDeleteEnterpriseService - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.enterpriseDeleteEnterpriseService(allEnterpriseDeleteEnterpriseServiceBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(123, data.response.id); assert.equal(1, data.response.rows); } else { runCommonAsserts(data, error); } saveMockData('All', 'enterpriseDeleteEnterpriseService', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseGetEnterpriseAddressesBodyParam = { enterpriseId: 4 }; describe('#enterpriseGetEnterpriseAddresses - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.enterpriseGetEnterpriseAddresses(allEnterpriseGetEnterpriseAddressesBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal('object', typeof data.response[0]); assert.equal('object', typeof data.response[1]); assert.equal('object', typeof data.response[2]); } else { runCommonAsserts(data, error); } saveMockData('All', 'enterpriseGetEnterpriseAddresses', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseGetEnterpriseAlertConfigurationsBodyParam = { enterpriseId: 1 }; describe('#enterpriseGetEnterpriseAlertConfigurations - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.enterpriseGetEnterpriseAlertConfigurations(allEnterpriseGetEnterpriseAlertConfigurationsBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal('object', typeof data.response[0]); } else { runCommonAsserts(data, error); } saveMockData('All', 'enterpriseGetEnterpriseAlertConfigurations', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseGetEnterpriseAlertsBodyParam = { enterpriseId: 1, interval: {} }; describe('#enterpriseGetEnterpriseAlerts - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.enterpriseGetEnterpriseAlerts(allEnterpriseGetEnterpriseAlertsBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal('object', typeof data.response.metaData); assert.equal(true, Array.isArray(data.response.data)); } else { runCommonAsserts(data, error); } saveMockData('All', 'enterpriseGetEnterpriseAlerts', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseGetEnterpriseAllAlertRecipientsBodyParam = { enterpriseId: 10 }; describe('#enterpriseGetEnterpriseAllAlertRecipients - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.enterpriseGetEnterpriseAllAlertRecipients(allEnterpriseGetEnterpriseAllAlertRecipientsBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal(true, data.response.emailEnabled); assert.equal(true, Array.isArray(data.response.emailList)); assert.equal(true, Array.isArray(data.response.enterpriseUsers)); assert.equal(false, data.response.mobileEnabled); assert.equal(true, Array.isArray(data.response.mobileList)); assert.equal(false, data.response.smsEnabled); assert.equal(true, Array.isArray(data.response.smsList)); assert.equal(true, data.response.snmpEnabled); assert.equal(true, Array.isArray(data.response.snmpList)); } else { runCommonAsserts(data, error); } saveMockData('All', 'enterpriseGetEnterpriseAllAlertRecipients', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseGetEnterpriseConfigurationsBodyParam = { enterpriseId: 8 }; describe('#enterpriseGetEnterpriseConfigurations - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.enterpriseGetEnterpriseConfigurations(allEnterpriseGetEnterpriseConfigurationsBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal('object', typeof data.response[0]); } else { runCommonAsserts(data, error); } saveMockData('All', 'enterpriseGetEnterpriseConfigurations', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseGetEnterpriseNetworkAllocationsBodyParam = { enterpriseId: 2, name: 'string', with: [ 'edgeCount' ] }; describe('#enterpriseGetEnterpriseNetworkAllocations - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.enterpriseGetEnterpriseNetworkAllocations(allEnterpriseGetEnterpriseNetworkAllocationsBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal('object', typeof data.response[0]); assert.equal('object', typeof data.response[1]); assert.equal('object', typeof data.response[2]); assert.equal('object', typeof data.response[3]); } else { runCommonAsserts(data, error); } saveMockData('All', 'enterpriseGetEnterpriseNetworkAllocations', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseGetEnterpriseNetworkSegmentsBodyParam = { enterpriseId: 10, name: 'string', type: 'string', with: [ 'profileCount' ] }; describe('#enterpriseGetEnterpriseNetworkSegments - errors', () => { it('should work if integrated or standalone with mockdata', (done) => { try { a.enterpriseGetEnterpriseNetworkSegments(allEnterpriseGetEnterpriseNetworkSegmentsBodyParam, (data, error) => { try { if (stub) { runCommonAsserts(data, error); assert.equal('object', typeof data.response[0]); assert.equal('object', typeof data.response[1]); assert.equal('object', typeof data.response[2]); } else { runCommonAsserts(data, error); } saveMockData('All', 'enterpriseGetEnterpriseNetworkSegments', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const allEnterpriseGetEnterpriseRouteConfigurationBodyParam =