UNPKG

@itentialopensource/adapter-akamai_property_manager

Version:

This adapter integrates with the Akamai Property Manager API.

1,326 lines (1,253 loc) 80.6 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-akamai_property_manager', type: 'AkamaiPropertyManager', 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 AkamaiPropertyManager = require('../../adapter'); // begin the testing - these should be pretty well defined between the describe and the it! describe('[integration] Akamai_property_manager Adapter Test', () => { describe('AkamaiPropertyManager Class Tests', () => { const a = new AkamaiPropertyManager( 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-akamai_property_manager-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-akamai_property_manager-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 activationsContractId = 'fakedata'; const activationsGroupId = 'fakedata'; const activationsBulkactivateasetofpropertiesBodyParam = { activatePropertyVersions: [ { network: 'STAGING', note: 'Some activation note', propertyId: 'prp_1', propertyVersion: 2 } ], defaultActivationSettings: { acknowledgeAllWarnings: true, fastPush: true, notifyEmails: [ 'you@example.com', 'them@example.com' ], useFastFallback: false } }; describe('#bulkactivateasetofproperties - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.bulkactivateasetofproperties(activationsContractId, activationsGroupId, activationsBulkactivateasetofpropertiesBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Activations', 'bulkactivateasetofproperties', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const activationsPropertyId = 'fakedata'; const activationsCreateanewactivationordeactivationBodyParam = { acknowledgeWarnings: [ 'string' ], network: 'string', note: 'string', notifyEmails: [ 'string' ], propertyVersion: 10, useFastFallback: false }; describe('#createanewactivationordeactivation - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createanewactivationordeactivation(activationsContractId, activationsGroupId, activationsPropertyId, activationsCreateanewactivationordeactivationBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Activations', 'createanewactivationordeactivation', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const activationsBulkActivationId = 'fakedata'; describe('#listbulkActivatedproperties - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.listbulkActivatedproperties(activationsContractId, activationsGroupId, activationsBulkActivationId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Activations', 'listbulkActivatedproperties', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#listactivations - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.listactivations(activationsContractId, activationsGroupId, activationsPropertyId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Activations', 'listactivations', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const propertyVersionCreationsContractId = 'fakedata'; const propertyVersionCreationsGroupId = 'fakedata'; const propertyVersionCreationsBulkversionasetofpropertiesBodyParam = { createPropertyVersions: [ { createFromVersion: 1, createFromVersionEtag: '2641910c585cf67b', propertyId: 'prp_1' } ] }; describe('#bulkversionasetofproperties - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.bulkversionasetofproperties(propertyVersionCreationsContractId, propertyVersionCreationsGroupId, propertyVersionCreationsBulkversionasetofpropertiesBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('PropertyVersionCreations', 'bulkversionasetofproperties', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const propertyVersionCreationsBulkCreateId = 'fakedata'; describe('#listbulkVersionedproperties - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.listbulkVersionedproperties(propertyVersionCreationsContractId, propertyVersionCreationsGroupId, propertyVersionCreationsBulkCreateId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('PropertyVersionCreations', 'listbulkVersionedproperties', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const rulesPatchRequestsContractId = 'fakedata'; const rulesPatchRequestsGroupId = 'fakedata'; const rulesPatchRequestsBulkpatchasetofpropertiesBodyParam = { patchPropertyVersions: [ { etag: 'a87v5c65c6821bc', patches: [ { op: 'replace', path: '/rules/children/1/features/3/option/enabled', value: 'on' }, { op: 'replace', path: '/rules/children/1/features/0/option/enabled', value: 'on' } ], propertyId: 'prp_1', propertyVersion: 1 } ] }; describe('#bulkpatchasetofproperties - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.bulkpatchasetofproperties(rulesPatchRequestsContractId, rulesPatchRequestsGroupId, rulesPatchRequestsBulkpatchasetofpropertiesBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('RulesPatchRequests', 'bulkpatchasetofproperties', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const rulesPatchRequestsBulkPatchId = 'fakedata'; describe('#listbulkPatchedproperties - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.listbulkPatchedproperties(rulesPatchRequestsContractId, rulesPatchRequestsGroupId, rulesPatchRequestsBulkPatchId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('RulesPatchRequests', 'listbulkPatchedproperties', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const rulesSearchRequestsContractId = 'fakedata'; const rulesSearchRequestsGroupId = 'fakedata'; const rulesSearchRequestsBulksearchasetofpropertiesBodyParam = { bulkSearchQuery: { bulkSearchQualifiers: [ '$.options[?(@.secure=="true\')]', '$..features[?(@.name==\'origin\')].options[?(@.hostname==\'old.origin.example.com\')]' ], match: '$..conditions[?(@.name == \'ext\' && \'mp3\' in @.options.value && \'mp4\' nin @.options.value)].options.value[?(@ == \'mp3\')]', syntax: 'JSONPATH' } }; describe('#bulksearchasetofproperties - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.bulksearchasetofproperties(rulesSearchRequestsContractId, rulesSearchRequestsGroupId, rulesSearchRequestsBulksearchasetofpropertiesBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('RulesSearchRequests', 'bulksearchasetofproperties', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const rulesSearchRequestsBulkSearchId = 'fakedata'; describe('#listbulksearchresults - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.listbulksearchresults(rulesSearchRequestsContractId, rulesSearchRequestsGroupId, rulesSearchRequestsBulkSearchId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('RulesSearchRequests', 'listbulksearchresults', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const bulkContractId = 'fakedata'; const bulkGroupId = 'fakedata'; const bulkSynchronouslybulksearchasetofpropertiesBodyParam = { bulkSearchQuery: { bulkSearchQualifiers: [ '$.options[?(@.secure=="true\')]', '$..features[?(@.name==\'origin\')].options[?(@.hostname==\'old.origin.example.com\')]' ], match: '$..conditions[?(@.name == \'ext\' && \'mp3\' in @.options.value && \'mp4\' nin @.options.value)].options.value[?(@ == \'mp3\')]', syntax: 'JSONPATH' } }; describe('#synchronouslybulksearchasetofproperties - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.synchronouslybulksearchasetofproperties(bulkContractId, bulkGroupId, bulkSynchronouslybulksearchasetofpropertiesBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Bulk', 'synchronouslybulksearchasetofproperties', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const clientSettingsUpdateclientsettingsBodyParam = { ruleFormat: 'string', usePrefixes: true }; describe('#updateclientsettings - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.updateclientsettings(clientSettingsUpdateclientsettingsBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('ClientSettings', 'updateclientsettings', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getclientsettings - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getclientsettings((data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('ClientSettings', 'getclientsettings', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const cpcodesContractId = 'fakedata'; const cpcodesGroupId = 'fakedata'; const cpcodesCreateanewCPcodeBodyParam = { cpcodeName: 'string', productId: 'string' }; describe('#createanewCPcode - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createanewCPcode(cpcodesContractId, cpcodesGroupId, cpcodesCreateanewCPcodeBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Cpcodes', 'createanewCPcode', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#listCPcodes - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.listCPcodes(cpcodesContractId, cpcodesGroupId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Cpcodes', 'listCPcodes', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const cpcodesCpcodeId = 'fakedata'; describe('#getaCPcode - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getaCPcode(cpcodesContractId, cpcodesGroupId, cpcodesCpcodeId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Cpcodes', 'getaCPcode', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const behaviorIdLock = true; const behaviorIdBehaviorId = 'fakedata'; const behaviorIdLockacustombehaviorBodyParam = {}; describe('#lockacustombehavior - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.lockacustombehavior(behaviorIdLock, behaviorIdBehaviorId, behaviorIdLockacustombehaviorBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('BehaviorId', 'lockacustombehavior', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getacustombehavior - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getacustombehavior(behaviorIdBehaviorId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('BehaviorId', 'getacustombehavior', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const customBehaviorsCreateanewcustombehaviorBodyParam = { approvedByUser: 'string', description: 'string', displayName: 'string', name: 'string', sharingLevel: 'string', xml: 'string' }; describe('#createanewcustombehavior - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createanewcustombehavior(customBehaviorsCreateanewcustombehaviorBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('CustomBehaviors', 'createanewcustombehavior', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#listcustombehaviors - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.listcustombehaviors((data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('CustomBehaviors', 'listcustombehaviors', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const overrideIdLock = true; const overrideIdOverrideId = 'fakedata'; const overrideIdLockacustomoverrideBodyParam = {}; describe('#lockacustomoverride - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.lockacustomoverride(overrideIdLock, overrideIdOverrideId, overrideIdLockacustomoverrideBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('OverrideId', 'lockacustomoverride', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getacustomoverride - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getacustomoverride(overrideIdOverrideId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('OverrideId', 'getacustomoverride', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const customOverridesCreateanewcustomoverrideBodyParam = { approvedByUser: 'string', description: 'string', displayName: 'string', name: 'string', sharingLevel: 'string', xml: 'string' }; describe('#createanewcustomoverride - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createanewcustomoverride(customOverridesCreateanewcustomoverrideBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('CustomOverrides', 'createanewcustomoverride', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#listcustomoverrides - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.listcustomoverrides((data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('CustomOverrides', 'listcustomoverrides', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const edgehostnamesContractId = 'fakedata'; const edgehostnamesGroupId = 'fakedata'; const edgehostnamesOptions = 'fakedata'; const edgehostnamesCreateanewedgehostnameBodyParam = { domainPrefix: 'string', domainSuffix: 'string', ipVersionBehavior: 'string', productId: 'string', secureNetwork: 'string', useCases: [ { option: 'BACKGROUND', type: 'GLOBAL', useCase: 'Download_Mode' } ] }; describe('#createanewedgehostname - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createanewedgehostname(edgehostnamesContractId, edgehostnamesGroupId, edgehostnamesOptions, edgehostnamesCreateanewedgehostnameBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Edgehostnames', 'createanewedgehostname', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#listedgehostnames - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.listedgehostnames(edgehostnamesContractId, edgehostnamesGroupId, edgehostnamesOptions, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Edgehostnames', 'listedgehostnames', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const edgehostnamesEdgeHostnameId = 'fakedata'; describe('#getanedgehostname - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getanedgehostname(edgehostnamesContractId, edgehostnamesGroupId, edgehostnamesOptions, edgehostnamesEdgeHostnameId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Edgehostnames', 'getanedgehostname', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const productsContractId = 'fakedata'; describe('#listproducts - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.listproducts(productsContractId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Products', 'listproducts', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const productsProductId = 'fakedata'; describe('#listusecases - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.listusecases(productsContractId, productsProductId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-akamai_property_manager-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Products', 'listusecases', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const activationIdContractId = 'fakedata'; const activationIdGroupId = 'fakedata'; const activationIdPropertyId = 'fakedata'; const activationIdActivationId = 'fakedata'; describe('#getanactivation - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getanactivation(activationIdContractId, activationIdGroupId, activationIdPropertyId, activationIdActivationId, (data, error) => { try { if (stub) {