@itentialopensource/adapter-zoom
Version:
This adapter integrates with system described as: zoom.
1,432 lines (1,362 loc) • 202 kB
JavaScript
/* @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-zoom',
type: 'Zoom',
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 Zoom = require('../../adapter');
// begin the testing - these should be pretty well defined between the describe and the it!
describe('[integration] Zoom Adapter Test', () => {
describe('Zoom Class Tests', () => {
const a = new Zoom(
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-zoom-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-zoom-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 ******************
-----------------------------------------------------------------------
-----------------------------------------------------------------------
*/
let accountsAccountId = 'fakedata';
const accountsAccountCreateBodyParam = {
first_name: 'string',
last_name: 'string',
email: 'string',
password: 'string'
};
describe('#accountCreate - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.accountCreate(accountsAccountCreateBodyParam, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('string', data.response.id);
assert.equal('string', data.response.owner_id);
assert.equal('string', data.response.owner_email);
assert.equal('string', data.response.created_at);
} else {
runCommonAsserts(data, error);
}
accountsAccountId = data.response.id;
saveMockData('Accounts', 'accountCreate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
describe('#getAccounts - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.getAccounts(null, null, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal(8, data.response.page_count);
assert.equal(1, data.response.pageNumber);
assert.equal(30, data.response.pageSize);
assert.equal(4, data.response.total_records);
assert.equal(true, Array.isArray(data.response.accounts));
} else {
runCommonAsserts(data, error);
}
saveMockData('Accounts', 'getAccounts', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
describe('#account - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.account(accountsAccountId, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('string', data.response.id);
assert.equal('string', data.response.owner_id);
assert.equal('string', data.response.owner_email);
assert.equal('string', data.response.created_at);
assert.equal('object', typeof data.response.options);
assert.equal('string', data.response.vanity_url);
} else {
runCommonAsserts(data, error);
}
saveMockData('Accounts', 'account', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
describe('#accountManagedDomain - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.accountManagedDomain(accountsAccountId, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal(2, data.response.total_records);
assert.equal(true, Array.isArray(data.response.domains));
} else {
runCommonAsserts(data, error);
}
saveMockData('Accounts', 'accountManagedDomain', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
const accountsAccountOptionsUpdateBodyParam = {
share_rc: false,
room_connectors: 'string',
share_mc: false,
meeting_connectors: 'string',
pay_mode: 'master'
};
describe('#accountOptionsUpdate - errors', () => {
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
try {
a.accountOptionsUpdate(accountsAccountId, accountsAccountOptionsUpdateBodyParam, (data, error) => {
try {
if (stub) {
const displayE = 'Error 400 received on request';
runErrorAsserts(data, error, 'AD.500', 'Test-zoom-connectorRest-handleEndResponse', displayE);
} else {
runCommonAsserts(data, error);
}
saveMockData('Accounts', 'accountOptionsUpdate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
const accountsAccountSettingsUpdateBodyParam = {
schedule_meting: {
host_video: false,
participant_video: false,
audio_type: 'both',
join_before_host: false,
enforce_login: true,
enforce_login_with_domains: false,
enforce_login_domains: 'string',
not_store_meeting_topic: true,
force_pmi_jbh_password: true
},
in_meeting: {
e2e_encryption: true,
chat: true,
private_chat: true,
auto_saving_chat: true,
file_transfer: false,
feedback: true,
post_meeting_feedback: true,
co_host: false,
polling: true,
attendee_on_hold: false,
show_meeting_control_toolbar: false,
allow_show_zoom_windows: false,
annotation: true,
whiteboard: false,
webinar_question_answer: false,
anonymous_question_answer: false,
breakout_room: false,
closed_caption: false,
far_end_camera_control: false,
group_hd: false,
virtual_background: true,
watermark: true,
alert_guest_join: false,
auto_answer: true,
p2p_connetion: true,
p2p_ports: true,
ports_range: 'string',
sending_default_email_invites: true,
use_html_format_email: false,
dscp_marking: false,
dscp_audio: 8,
dscp_video: 1,
stereo_audio: true,
original_audio: true,
screen_sharing: true,
remote_control: true,
attention_tracking: true,
allow_live_streaming: false,
workplace_by_facebook: false,
custom_live_streaming: false,
custom_service_instructions: 'string'
},
email_notification: {
cloud_recording_avaliable_reminder: true,
jbh_reminder: true,
cancel_meeting_reminder: true,
low_host_count_reminder: false,
alternative_host_reminder: false
},
zoom_rooms: {
upcoming_meeting_alert: false,
start_airplay_manually: false,
weekly_system_restart: true,
list_meetings_with_calendar: false,
zr_post_meeting_feedback: false,
ultrasonic: false,
force_private_meeting: false,
hide_host_information: true,
cmr_for_instant_meeting: true,
auto_start_stop_scheduled_meetings: true
},
security: {
admin_change_name_pic: false,
import_photos_from_devices: false,
hide_billing_info: true
},
recording: {
local_recording: true,
cloud_recording: false,
record_speaker_view: false,
record_gallery_view: true,
record_audio_file: false,
save_chat_text: true,
show_timestamp: true,
recording_audio_transcript: false,
auto_recording: 'cloud',
cloud_recording_download: true,
cloud_recording_download_host: false,
account_user_access_recording: false,
auto_delete_cmr: true,
auto_delete_cmr_days: 5
},
telephony: {
third_party_audio: false,
audio_conference_info: 'string'
},
integration: {
google_calendar: true,
google_drive: true,
dropbox: false,
box: false,
microsoft_one_drive: false,
kubi: false
},
feature: {
meeting_capacity: 100
}
};
describe('#accountSettingsUpdate - errors', () => {
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
try {
a.accountSettingsUpdate(accountsAccountId, accountsAccountSettingsUpdateBodyParam, (data, error) => {
try {
if (stub) {
const displayE = 'Error 400 received on request';
runErrorAsserts(data, error, 'AD.500', 'Test-zoom-connectorRest-handleEndResponse', displayE);
} else {
runCommonAsserts(data, error);
}
saveMockData('Accounts', 'accountSettingsUpdate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
describe('#accountSettings - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.accountSettings(accountsAccountId, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('object', typeof data.response.schedule_meting);
assert.equal('object', typeof data.response.in_meeting);
assert.equal('object', typeof data.response.email_notification);
assert.equal('object', typeof data.response.zoom_rooms);
assert.equal('object', typeof data.response.security);
assert.equal('object', typeof data.response.recording);
assert.equal('object', typeof data.response.telephony);
assert.equal('object', typeof data.response.integration);
assert.equal('object', typeof data.response.feature);
} else {
runCommonAsserts(data, error);
}
saveMockData('Accounts', 'accountSettings', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
const billingAccountId = 'fakedata';
const billingAccountPlanCreateBodyParam = {
contact: {
first_name: 'string',
last_name: 'string',
email: 'string',
phone_number: 'string',
address: 'string',
apt: 'string',
city: 'string',
state: 'string',
zip: 'string',
country: 'string'
},
plan_base: {
type: 'string',
hosts: 8
},
plan_zoom_rooms: {
type: 'string',
hosts: 3
},
plan_room_connector: {
type: 'string',
hosts: 5
},
plan_large_meeting: [
{
type: 'string',
hosts: 3
}
],
plan_webinar: [
{
type: 'string',
hosts: 9
}
],
plan_recording: 'string',
plan_audio: {
type: 'string',
tollfree_countries: 'string',
premium_countries: 'string',
callout_countries: 'string',
ddi_numbers: 10
}
};
describe('#accountPlanCreate - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.accountPlanCreate(billingAccountId, billingAccountPlanCreateBodyParam, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('object', typeof data.response.plan_base);
assert.equal('object', typeof data.response.plan_zoom_rooms);
assert.equal('object', typeof data.response.plan_room_connector);
assert.equal(true, Array.isArray(data.response.plan_large_meeting));
assert.equal(true, Array.isArray(data.response.plan_webinar));
assert.equal('string', data.response.plan_recording);
assert.equal('object', typeof data.response.plan_audio);
} else {
runCommonAsserts(data, error);
}
saveMockData('Billing', 'accountPlanCreate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
const billingAccountPlanAddonCreateBodyParam = {
type: 'string',
hosts: 2
};
describe('#accountPlanAddonCreate - errors', () => {
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
try {
a.accountPlanAddonCreate(billingAccountId, billingAccountPlanAddonCreateBodyParam, (data, error) => {
try {
if (stub) {
const displayE = 'Error 400 received on request';
runErrorAsserts(data, error, 'AD.500', 'Test-zoom-connectorRest-handleEndResponse', displayE);
} else {
runCommonAsserts(data, error);
}
saveMockData('Billing', 'accountPlanAddonCreate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
const billingAccountBillingUpdateBodyParam = {
first_name: 'string',
last_name: 'string',
email: 'string',
phone_number: 'string',
address: 'string',
apt: 'string',
city: 'string',
state: 'string',
zip: 'string',
country: 'string'
};
describe('#accountBillingUpdate - errors', () => {
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
try {
a.accountBillingUpdate(billingAccountId, billingAccountBillingUpdateBodyParam, (data, error) => {
try {
if (stub) {
const displayE = 'Error 400 received on request';
runErrorAsserts(data, error, 'AD.500', 'Test-zoom-connectorRest-handleEndResponse', displayE);
} else {
runCommonAsserts(data, error);
}
saveMockData('Billing', 'accountBillingUpdate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
describe('#accountBilling - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.accountBilling(billingAccountId, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('string', data.response.first_name);
assert.equal('string', data.response.last_name);
assert.equal('string', data.response.email);
assert.equal('string', data.response.phone_number);
assert.equal('string', data.response.address);
assert.equal('string', data.response.apt);
assert.equal('string', data.response.city);
assert.equal('string', data.response.state);
assert.equal('string', data.response.zip);
assert.equal('string', data.response.country);
} else {
runCommonAsserts(data, error);
}
saveMockData('Billing', 'accountBilling', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
describe('#accountPlans - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.accountPlans(billingAccountId, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('object', typeof data.response.plan_base);
assert.equal('object', typeof data.response.plan_zoom_rooms);
assert.equal('object', typeof data.response.plan_room_connector);
assert.equal(true, Array.isArray(data.response.plan_large_meeting));
assert.equal(true, Array.isArray(data.response.plan_webinar));
assert.equal('string', data.response.plan_recording);
assert.equal('object', typeof data.response.plan_audio);
} else {
runCommonAsserts(data, error);
}
saveMockData('Billing', 'accountPlans', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
const billingAccountPlanAddonUpdateBodyParam = {
type: 'string',
hosts: 5
};
describe('#accountPlanAddonUpdate - errors', () => {
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
try {
a.accountPlanAddonUpdate(billingAccountId, billingAccountPlanAddonUpdateBodyParam, (data, error) => {
try {
if (stub) {
const displayE = 'Error 400 received on request';
runErrorAsserts(data, error, 'AD.500', 'Test-zoom-connectorRest-handleEndResponse', displayE);
} else {
runCommonAsserts(data, error);
}
saveMockData('Billing', 'accountPlanAddonUpdate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
const billingAccountPlanBaseUpdateBodyParam = {
type: 'string',
hosts: 9
};
describe('#accountPlanBaseUpdate - errors', () => {
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
try {
a.accountPlanBaseUpdate(billingAccountId, billingAccountPlanBaseUpdateBodyParam, (data, error) => {
try {
if (stub) {
const displayE = 'Error 400 received on request';
runErrorAsserts(data, error, 'AD.500', 'Test-zoom-connectorRest-handleEndResponse', displayE);
} else {
runCommonAsserts(data, error);
}
saveMockData('Billing', 'accountPlanBaseUpdate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
let groupsGroupId = 'fakedata';
let groupsMemberId = 'fakedata';
const groupsGroupCreateBodyParam = {
name: 'string'
};
describe('#groupCreate - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.groupCreate(groupsGroupCreateBodyParam, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('string', data.response.id);
assert.equal('string', data.response.name);
assert.equal(8, data.response.total_members);
} else {
runCommonAsserts(data, error);
}
groupsGroupId = data.response.id;
groupsMemberId = data.response.id;
saveMockData('Groups', 'groupCreate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
const groupsGroupMembersCreateBodyParam = {
members: [
{
id: 'string',
email: 'string'
}
]
};
describe('#groupMembersCreate - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.groupMembersCreate(groupsGroupId, groupsGroupMembersCreateBodyParam, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('string', data.response.ids);
assert.equal('string', data.response.added_at);
} else {
runCommonAsserts(data, error);
}
saveMockData('Groups', 'groupMembersCreate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
describe('#getGroups - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.getGroups((data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal(2, data.response.total_records);
assert.equal(true, Array.isArray(data.response.groups));
} else {
runCommonAsserts(data, error);
}
saveMockData('Groups', 'getGroups', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
const groupsGroupUpdateBodyParam = {
name: 'string'
};
describe('#groupUpdate - errors', () => {
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
try {
a.groupUpdate(groupsGroupId, groupsGroupUpdateBodyParam, (data, error) => {
try {
if (stub) {
const displayE = 'Error 400 received on request';
runErrorAsserts(data, error, 'AD.500', 'Test-zoom-connectorRest-handleEndResponse', displayE);
} else {
runCommonAsserts(data, error);
}
saveMockData('Groups', 'groupUpdate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
describe('#group - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.group(groupsGroupId, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('string', data.response.id);
assert.equal('string', data.response.name);
assert.equal(8, data.response.total_members);
} else {
runCommonAsserts(data, error);
}
saveMockData('Groups', 'group', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
describe('#groupMembers - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.groupMembers(groupsGroupId, null, null, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal(4, data.response.page_count);
assert.equal(1, data.response.pageNumber);
assert.equal(30, data.response.pageSize);
assert.equal(8, data.response.total_records);
assert.equal(true, Array.isArray(data.response.members));
} else {
runCommonAsserts(data, error);
}
saveMockData('Groups', 'groupMembers', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
let devicesDeviceId = 'fakedata';
const devicesDeviceCreateBodyParam = {
name: 'string',
protocol: 'SIP',
ip: 'string',
encryption: 'auto'
};
describe('#deviceCreate - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.deviceCreate(devicesDeviceCreateBodyParam, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('string', data.response.id);
assert.equal('string', data.response.name);
assert.equal('H.323', data.response.protocol);
assert.equal('string', data.response.ip);
assert.equal('yes', data.response.encryption);
} else {
runCommonAsserts(data, error);
}
devicesDeviceId = data.response.id;
saveMockData('Devices', 'deviceCreate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
describe('#deviceList - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.deviceList((data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal(1, data.response.page_count);
assert.equal(1, data.response.page_number);
assert.equal(30, data.response.page_size);
assert.equal(8, data.response.total_records);
assert.equal(true, Array.isArray(data.response.devices));
} else {
runCommonAsserts(data, error);
}
saveMockData('Devices', 'deviceList', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
const devicesDeviceUpdateBodyParam = {
name: 'string',
protocol: 'SIP',
ip: 'string',
encryption: 'yes'
};
describe('#deviceUpdate - errors', () => {
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
try {
a.deviceUpdate(devicesDeviceId, devicesDeviceUpdateBodyParam, (data, error) => {
try {
if (stub) {
const displayE = 'Error 400 received on request';
runErrorAsserts(data, error, 'AD.500', 'Test-zoom-connectorRest-handleEndResponse', displayE);
} else {
runCommonAsserts(data, error);
}
saveMockData('Devices', 'deviceUpdate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
let trackingFieldFieldId = 'fakedata';
const trackingFieldTrackingfieldCreateBodyParam = {
field: 'string',
required: true,
visible: true,
recommended_values: [
'string'
]
};
describe('#trackingfieldCreate - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.trackingfieldCreate(trackingFieldTrackingfieldCreateBodyParam, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('string', data.response.id);
assert.equal('string', data.response.field);
assert.equal(false, data.response.required);
assert.equal(false, data.response.visible);
assert.equal(true, Array.isArray(data.response.recommended_values));
} else {
runCommonAsserts(data, error);
}
trackingFieldFieldId = data.response.id;
saveMockData('TrackingField', 'trackingfieldCreate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
describe('#trackingfieldList - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.trackingfieldList((data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal(8, data.response.total_records);
assert.equal(true, Array.isArray(data.response.tracking_fields));
} else {
runCommonAsserts(data, error);
}
saveMockData('TrackingField', 'trackingfieldList', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
const trackingFieldTrackingfieldUpdateBodyParam = {
field: 'string',
required: true,
visible: false,
recommended_values: [
'string'
]
};
describe('#trackingfieldUpdate - errors', () => {
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
try {
a.trackingfieldUpdate(trackingFieldFieldId, trackingFieldTrackingfieldUpdateBodyParam, (data, error) => {
try {
if (stub) {
const displayE = 'Error 400 received on request';
runErrorAsserts(data, error, 'AD.500', 'Test-zoom-connectorRest-handleEndResponse', displayE);
} else {
runCommonAsserts(data, error);
}
saveMockData('TrackingField', 'trackingfieldUpdate', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
describe('#trackingfieldGet - errors', () => {
it('should work if integrated or standalone with mockdata', (done) => {
try {
a.trackingfieldGet(trackingFieldFieldId, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('string', data.response.id);
assert.equal('string', data.response.field);
assert.equal(true, data.response.required);
assert.equal(true, data.response.visible);
assert.equal(true, Array.isArray(data.response.recommended_values));
} else {
runCommonAsserts(data, error);
}
saveMockData('TrackingField', 'trackingfieldGet', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
}