UNPKG

@itentialopensource/adapter-kentik_v5

Version:

This adapter integrates with system described as: kentikV5Api.

1,491 lines (1,420 loc) 84.3 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-kentik_v5', type: 'KentikV5', 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 KentikV5 = require('../../adapter'); // begin the testing - these should be pretty well defined between the describe and the it! describe('[integration] Kentik_v5 Adapter Test', () => { describe('KentikV5 Class Tests', () => { const a = new KentikV5( 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-kentik_v5-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-kentik_v5-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 queryMethodsRunQueryBodyParam = { query: 'string' }; describe('#runQuery - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.runQuery(queryMethodsRunQueryBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('QueryMethods', 'runQuery', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const queryMethodsTopxchartBodyParam = { queries: [ { query: { viz_type: 'string', show_overlay: false, overlay_day: 8, sync_axes: false, dimension: [ 'RegionTopTalkers' ], cidr: 8, cidr6: 7, pps_threshold: 5, metric: null, topx: 2, depth: 1, fastData: null, outsort: 'string', lookback_seconds: 8, hostname_lookup: true, starting_time: 'string', ending_time: 'string', device_name: 'string', all_selected: false, filters_obj: { connector: null, filterGroups: [ { connector: null, filters: [ { filterField: null, operator: null, filterValue: 'string' } ], not: false } ] }, saved_filters: [ { filter_id: 7, isNot: false } ], descriptor: 'string', aggregates: [ { name: 'string', column: null, fn: null, rank: 8, leftOperand: 'string', compositeFn: null, rightOperand: null, raw: true } ], query_title: 'string' }, bucket: 'string', bucketIndex: 7, isOverlay: false } ], imageType: null }; describe('#topxchart - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.topxchart(queryMethodsTopxchartBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('QueryMethods', 'topxchart', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const queryMethodsTopxdataBodyParam = { queries: [ { query: { dimension: [ 'src_geo_region' ], cidr: 2, cidr6: 2, pps_threshold: 8, metric: null, topx: 9, depth: 8, fastData: null, outsort: 'string', lookback_seconds: 1, hostname_lookup: true, starting_time: 'string', ending_time: 'string', device_name: 'string', all_selected: false, filters_obj: { connector: null, filterGroups: [ { connector: null, filters: [ { filterField: null, operator: null, filterValue: 'string' } ], not: false } ] }, saved_filters: [ { filter_id: 4, isNot: true } ], descriptor: 'string', aggregates: [ { name: 'string', column: null, fn: null, rank: 4, leftOperand: 'string', compositeFn: null, rightOperand: null, raw: true } ] }, bucket: 'string', bucketIndex: 4 } ] }; describe('#topxdata - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.topxdata(queryMethodsTopxdataBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('QueryMethods', 'topxdata', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const queryMethodsQueryUrlBodyParam = { version: null, queries: [ { query: { dimension: [ 'dst_geo_region' ], cidr: 6, cidr6: 8, pps_threshold: 7, metric: null, topx: 8, depth: 7, fastData: null, outsort: 'string', lookback_seconds: 6, time_format: null, hostname_lookup: true, starting_time: 'string', ending_time: 'string', device_name: 'string', all_selected: false, filters_obj: { connector: null, filterGroups: [ { connector: null, filters: [ { filterField: null, operator: null, filterValue: 'string' } ], not: false } ] }, saved_filters: [ { filter_id: 10, isNot: false } ], descriptor: 'string', aggregates: [ { name: 'string', column: null, fn: null, rank: 2, leftOperand: 'string', compositeFn: null, rightOperand: null, raw: false } ] }, bucket: 'string', bucketIndex: 8 } ] }; describe('#queryUrl - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.queryUrl(queryMethodsQueryUrlBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('QueryMethods', 'queryUrl', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const userCreateUserBodyParam = { user: { user_email: 'string', user_full_name: 'string', role: null, email_product: true, email_service: true } }; describe('#createUser - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createUser(userCreateUserBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('User', 'createUser', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const userUserId = 555; const userUpdateUserBodyParam = { user: { user_email: 'string', user_full_name: 'string', role: null, email_product: true, email_service: true } }; describe('#updateUser - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.updateUser(userUserId, userUpdateUserBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('User', 'updateUser', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#findUser - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.findUser(userUserId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('User', 'findUser', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#findUsers - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.findUsers((data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('User', 'findUsers', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const deviceCreateDeviceBodyParam = { device: { device_name: 'string', device_subtype: null, cdn_attr: null, device_description: 'string', sending_ips: [], device_sample_rate: 5, plan_id: 10, site_id: 7, minimize_snmp: false, device_snmp_ip: 'string', device_snmp_community: 'string', device_snmp_v3_conf: { UserName: 'string', AuthenticationProtocol: null, AuthenticationPassphrase: 'string', PrivacyProtocol: null, PrivacyPassphrase: 'string' }, device_bgp_type: null, device_bgp_neighbor_ip: 'string', device_bgp_neighbor_ip6: 'string', device_bgp_neighbor_asn: 'string', device_bgp_password: 'string', use_bgp_device_id: 1, device_bgp_flowspec: true } }; describe('#createDevice - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createDevice(deviceCreateDeviceBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Device', 'createDevice', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const deviceDeviceId = 555; const deviceCreateInterfaceBodyParam = { snmp_id: 'string', interface_description: 'string', snmp_speed: 8 }; describe('#createInterface - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createInterface(deviceDeviceId, deviceCreateInterfaceBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Device', 'createInterface', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const deviceUpdateDeviceBodyParam = { device: { cdn_attr: null, device_description: 'string', sending_ips: [ 'string' ], device_sample_rate: 10, plan_id: 7, site_id: 10, minimize_snmp: false, device_snmp_ip: 'string', device_snmp_community: 'string', device_snmp_v3_conf: { UserName: 'string', AuthenticationProtocol: null, AuthenticationPassphrase: 'string', PrivacyProtocol: null, PrivacyPassphrase: 'string' }, device_bgp_type: null, device_bgp_neighbor_ip: 'string', device_bgp_neighbor_ip6: 'string', device_bgp_neighbor_asn: 'string', device_bgp_password: 'string', use_bgp_device_id: 10, device_bgp_flowspec: false } }; describe('#updateDevice - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.updateDevice(deviceDeviceId, deviceUpdateDeviceBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Device', 'updateDevice', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#findDevice - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.findDevice(deviceDeviceId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Device', 'findDevice', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const deviceInterfaceId = 555; const deviceUpdateInterfaceBodyParam = { snmp_id: 7, snmp_speed: 4 }; describe('#updateInterface - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.updateInterface(deviceDeviceId, deviceInterfaceId, deviceUpdateInterfaceBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Device', 'updateInterface', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#findInterface - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.findInterface(deviceDeviceId, deviceInterfaceId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Device', 'findInterface', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#findInterfaces - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.findInterfaces(deviceDeviceId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Device', 'findInterfaces', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#findDevices - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.findDevices((data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Device', 'findDevices', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const deviceDeviceApplyLabelsBodyParam = { labels: [ {} ] }; describe('#deviceApplyLabels - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.deviceApplyLabels(deviceDeviceId, deviceDeviceApplyLabelsBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Device', 'deviceApplyLabels', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const deviceLabelCreateDeviceLabelBodyParam = { name: 'string', color: 'string' }; describe('#createDeviceLabel - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createDeviceLabel(deviceLabelCreateDeviceLabelBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('DeviceLabel', 'createDeviceLabel', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#findDeviceLabels - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.findDeviceLabels((data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('DeviceLabel', 'findDeviceLabels', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const deviceLabelDeviceLabelId = 555; const deviceLabelUpdateDeviceLabelBodyParam = { name: 'string' }; describe('#updateDeviceLabel - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.updateDeviceLabel(deviceLabelDeviceLabelId, deviceLabelUpdateDeviceLabelBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('DeviceLabel', 'updateDeviceLabel', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#findDeviceLabel - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.findDeviceLabel(deviceLabelDeviceLabelId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('DeviceLabel', 'findDeviceLabel', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#findPlans - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.findPlans((data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Plan', 'findPlans', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const siteCreateSiteBodyParam = { site: { site_name: 'string', lat: 2, lon: 2 } }; describe('#createSite - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createSite(siteCreateSiteBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Site', 'createSite', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const siteSiteId = 555; const siteUpdateSiteBodyParam = { site: { site_name: 'string', lat: 9, lon: 9 } }; describe('#updateSite - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.updateSite(siteSiteId, siteUpdateSiteBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Site', 'updateSite', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#findSite - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.findSite(siteSiteId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Site', 'findSite', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#findSites - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.findSites((data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Site', 'findSites', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const tagCreateTagBodyParam = { tag: { flow_tag: 'string', device_name: 'string', device_type: 'string', site: 'string', interface_name: 'string', addr: 'string', port: 'string', tcp_flags: 'string', protocol: 'string', asn: 'string', lasthop_as_name: 'string', nexthop_asn: 'string', nexthop_as_name: 'string', nexthop: 'string', bgp_aspath: 'string', bgp_community: 'string', mac: 'string', country: 'string', vlans: 'string' } }; describe('#createTag - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createTag(tagCreateTagBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Tag', 'createTag', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const tagTagId = 555; const tagUpdateTagBodyParam = { tag: { flow_tag: 'string', device_name: 'string', device_type: 'string', site: 'string', interface_name: 'string', addr: 'string', port: 'string', tcp_flags: 'string', protocol: 'string', asn: 'string', lasthop_as_name: 'string', nexthop_asn: 'string', nexthop_as_name: 'string', nexthop: 'string', bgp_aspath: 'string', bgp_community: 'string', mac: 'string', country: 'string', vlans: 'string' } }; describe('#updateTag - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.updateTag(tagTagId, tagUpdateTagBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-kentik_v5-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Tag', 'updateTag', 'default', data); do