diff --git a/test/functional/CommandCallFunctional.js b/test/functional/CommandCallFunctional.js index 61c8e441..e82a4acd 100644 --- a/test/functional/CommandCallFunctional.js +++ b/test/functional/CommandCallFunctional.js @@ -18,82 +18,60 @@ /* eslint-env mocha */ const { expect } = require('chai'); -const { readFileSync } = require('fs'); const { parseString } = require('xml2js'); -const { CommandCall } = require('../../lib/itoolkit'); -const { returnTransports } = require('../../lib/utils'); +const { CommandCall, Connection } = require('../../lib/itoolkit'); +const { config, printConfig } = require('./config'); -// Set Env variables or set values here. -let privateKey; -if (process.env.TKPK) { - privateKey = readFileSync(process.env.TKPK, 'utf-8'); -} -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', - privateKey, - passphrase: process.env.TKPHRASE, - verbose: !!process.env.TKVERBOSE, - dsn: process.env.TKDSN, -}; - -const transports = returnTransports(opt); describe('CommandCall Functional Tests', () => { + before(() => { + printConfig(); + }); + describe('CL command tests', () => { - transports.forEach((transport) => { - it(`calls CL command using ${transport.name} transport`, (done) => { - const connection = transport.me; - connection.add(new CommandCall({ command: 'RTVJOBA USRLIBL(?) SYSLIBL(?)', type: 'cl' })); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.cmd[0].success[0]).to.include('+++ success RTVJOBA USRLIBL(?) SYSLIBL(?)'); - done(); - }); + it('calls CL command', (done) => { + const connection = new Connection(config); + connection.add(new CommandCall({ command: 'RTVJOBA USRLIBL(?) SYSLIBL(?)', type: 'cl' })); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.cmd[0].success[0]).to.include('+++ success RTVJOBA USRLIBL(?) SYSLIBL(?)'); + done(); }); }); }); }); describe('SH command tests', () => { - transports.forEach((transport) => { - it(`calls PASE shell command using ${transport.name} transport`, (done) => { - const connection = transport.me; - connection.add(new CommandCall({ command: 'system -i wrksyssts', type: 'sh' })); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - // xs does not return success property for sh or qsh command calls - // but on error sh or qsh node will not have any inner data - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sh[0]._).to.match(/(System\sStatus\sInformation)/); - done(); - }); + it('calls PASE shell command', (done) => { + const connection = new Connection(config); + connection.add(new CommandCall({ command: 'system -i wrksyssts', type: 'sh' })); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + // xs does not return success property for sh or qsh command calls + // but on error sh or qsh node will not have any inner data + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sh[0]._).to.match(/(System\sStatus\sInformation)/); + done(); }); }); }); }); describe('QSH command tests', () => { - transports.forEach((transport) => { - it(`calls QSH command using ${transport.name} transport`, (done) => { - const connection = transport.me; - connection.add(new CommandCall({ command: 'system wrksyssts', type: 'qsh' })); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - // xs does not return success property for sh or qsh command calls - // but on error sh or qsh node will not have any inner data - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.qsh[0]._).to.match(/(System\sStatus\sInformation)/); - done(); - }); + it('calls QSH command', (done) => { + const connection = new Connection(config); + connection.add(new CommandCall({ command: 'system wrksyssts', type: 'qsh' })); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + // xs does not return success property for sh or qsh command calls + // but on error sh or qsh node will not have any inner data + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.qsh[0]._).to.match(/(System\sStatus\sInformation)/); + done(); }); }); }); diff --git a/test/functional/ProgramCallFunctional.js b/test/functional/ProgramCallFunctional.js index f100731a..20e6857e 100644 --- a/test/functional/ProgramCallFunctional.js +++ b/test/functional/ProgramCallFunctional.js @@ -16,87 +16,68 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* eslint-env mocha */ -/* eslint-disable new-cap */ const { expect } = require('chai'); -const { readFileSync } = require('fs'); const { parseString } = require('xml2js'); -const { ProgramCall } = require('../../lib/itoolkit'); -const { returnTransports } = require('../../lib/utils'); - -// Set Env variables or set values here. -let privateKey; -if (process.env.TKPK) { - privateKey = readFileSync(process.env.TKPK, 'utf-8'); -} -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', - privateKey, - passphrase: process.env.TKPHRASE, - verbose: !!process.env.TKVERBOSE, - dsn: process.env.TKDSN, -}; - -const transports = returnTransports(opt); +const { ProgramCall, Connection } = require('../../lib/itoolkit'); +const { config, printConfig } = require('./config'); + describe('ProgramCall Functional Tests', () => { + before(() => { + printConfig(); + }); + describe('Test ProgramCall()', () => { - transports.forEach((transport) => { - it(`calls QWCRSVAL program checks if it ran successfully using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const program = new ProgramCall('QWCRSVAL', { lib: 'QSYS' }); - - const outBuf = { - type: 'ds', - io: 'out', - fields: [ - { type: '10i0', value: 0 }, - { type: '10i0', value: 0 }, - { type: '36h', value: '' }, - { type: '10A', value: '' }, - { type: '1A', value: '' }, - { type: '1A', value: '' }, - { type: '10i0', value: 0 }, - { type: '10i0', value: 0 }, - ], - }; - - const errno = { - type: 'ds', - io: 'both', - len: 'rec2', - fields: [ - { - name: 'bytes_provided', - type: '10i0', - value: 0, - setlen: 'rec2', - }, - { name: 'bytes_available', type: '10i0', value: 0 }, - { name: 'msgid', type: '7A', value: '' }, - { type: '1A', value: '' }, - ], - }; - - program.addParam(outBuf); - program.addParam({ type: '10i0', value: 66 }); - program.addParam({ type: '10i0', value: 1 }); - program.addParam({ type: '10A', value: 'QCCSID' }); - program.addParam(errno); - connection.add(program); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.pgm[0].success[0]).to.include('+++ success QSYS QWCRSVAL'); - done(); - }); + it('calls QWCRSVAL program checks if it ran successfully', (done) => { + const connection = new Connection(config); + + const program = new ProgramCall('QWCRSVAL', { lib: 'QSYS' }); + + const outBuf = { + type: 'ds', + io: 'out', + fields: [ + { type: '10i0', value: 0 }, + { type: '10i0', value: 0 }, + { type: '36h', value: '' }, + { type: '10A', value: '' }, + { type: '1A', value: '' }, + { type: '1A', value: '' }, + { type: '10i0', value: 0 }, + { type: '10i0', value: 0 }, + ], + }; + + const errno = { + type: 'ds', + io: 'both', + len: 'rec2', + fields: [ + { + name: 'bytes_provided', + type: '10i0', + value: 0, + setlen: 'rec2', + }, + { name: 'bytes_available', type: '10i0', value: 0 }, + { name: 'msgid', type: '7A', value: '' }, + { type: '1A', value: '' }, + ], + }; + + program.addParam(outBuf); + program.addParam({ type: '10i0', value: 66 }); + program.addParam({ type: '10i0', value: 1 }); + program.addParam({ type: '10A', value: 'QCCSID' }); + program.addParam(errno); + connection.add(program); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.pgm[0].success[0]).to.include('+++ success QSYS QWCRSVAL'); + done(); }); }); }); @@ -104,58 +85,56 @@ describe('ProgramCall Functional Tests', () => { describe('Test ProgramCall()', () => { - transports.forEach((transport) => { - it(`calls QWCRSVAL program and returns arbitrarily named parameter using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const program = new ProgramCall('QWCRSVAL', { lib: 'QSYS' }); - - const outBuf = { - type: 'ds', - io: 'out', - fields: [ - { type: '10i0', value: 0 }, - { type: '10i0', value: 0 }, - { type: '36h', value: '' }, - { type: '10A', value: '' }, - { type: '1A', value: '' }, - { type: '1A', value: '' }, - { type: '10i0', value: 0 }, - { type: '10i0', value: 0 }, - ], - }; - - const errno = { - name: 'errno', - type: 'ds', - io: 'both', - len: 'rec2', - fields: [ - { - name: 'bytes_provided', - type: '10i0', - value: 0, - setlen: 'rec2', - }, - { name: 'bytes_available', type: '10i0', value: 0 }, - { name: 'msgid', type: '7A', value: '' }, - { type: '1A', value: '' }, - ], - }; - - program.addParam(outBuf); - program.addParam({ type: '10i0', value: 66 }); - program.addParam({ type: '10i0', value: 1 }); - program.addParam({ type: '10A', value: 'QCCSID' }); - program.addParam(errno); - connection.add(program); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.pgm[0].success[0]).to.include('+++ success QSYS QWCRSVAL'); - done(); - }); + it('calls QWCRSVAL program and returns arbitrarily named parameter', (done) => { + const connection = new Connection(config); + + const program = new ProgramCall('QWCRSVAL', { lib: 'QSYS' }); + + const outBuf = { + type: 'ds', + io: 'out', + fields: [ + { type: '10i0', value: 0 }, + { type: '10i0', value: 0 }, + { type: '36h', value: '' }, + { type: '10A', value: '' }, + { type: '1A', value: '' }, + { type: '1A', value: '' }, + { type: '10i0', value: 0 }, + { type: '10i0', value: 0 }, + ], + }; + + const errno = { + name: 'errno', + type: 'ds', + io: 'both', + len: 'rec2', + fields: [ + { + name: 'bytes_provided', + type: '10i0', + value: 0, + setlen: 'rec2', + }, + { name: 'bytes_available', type: '10i0', value: 0 }, + { name: 'msgid', type: '7A', value: '' }, + { type: '1A', value: '' }, + ], + }; + + program.addParam(outBuf); + program.addParam({ type: '10i0', value: 66 }); + program.addParam({ type: '10i0', value: 1 }); + program.addParam({ type: '10A', value: 'QCCSID' }); + program.addParam(errno); + connection.add(program); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.pgm[0].success[0]).to.include('+++ success QSYS QWCRSVAL'); + done(); }); }); }); @@ -164,24 +143,22 @@ describe('ProgramCall Functional Tests', () => { describe.skip('Test ProgramCall()', () => { // ZZSRV6 program requires XMLSERVICE built with tests // Skip for now, we need to add before hook to check ZZSRV6 is available - transports.forEach((transport) => { - it.skip(`Should be successful with addReturn arbitrary attribute specified using using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const program = new ProgramCall('ZZSRV6', { lib: 'XMLSERVICE', func: 'ZZVARY4' }); - - program.addParam({ type: '10A', varying: '4', value: 'Gill' }); - const testValue = 'NEW_NAME'; - program.addReturn('0', '20A', { varying: '4', name: testValue }); - connection.add(program); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.pgm[0].success[0]).to.include('+++ success'); - expect(result.myscript.pgm[0].return[0].data[0]._).to.equal('my name is Gill'); - done(); - }); + it.skip('Should be successful with addReturn arbitrary attribute specified', (done) => { + const connection = new Connection(config); + + const program = new ProgramCall('ZZSRV6', { lib: 'XMLSERVICE', func: 'ZZVARY4' }); + + program.addParam({ type: '10A', varying: '4', value: 'Gill' }); + const testValue = 'NEW_NAME'; + program.addReturn('0', '20A', { varying: '4', name: testValue }); + connection.add(program); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.pgm[0].success[0]).to.include('+++ success'); + expect(result.myscript.pgm[0].return[0].data[0]._).to.equal('my name is Gill'); + done(); }); }); }); diff --git a/test/functional/ToolkitFunctional.js b/test/functional/ToolkitFunctional.js index d345aa73..d1a71e25 100644 --- a/test/functional/ToolkitFunctional.js +++ b/test/functional/ToolkitFunctional.js @@ -19,629 +19,552 @@ /* eslint-disable new-cap */ const { expect } = require('chai'); -const { readFileSync } = require('fs'); -const { Toolkit } = require('../../lib/itoolkit'); -const { returnTransports } = require('../../lib/utils'); - -// Set Env variables or set values here. -let privateKey; -if (process.env.TKPK) { - privateKey = readFileSync(process.env.TKPK, 'utf-8'); -} -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', - privateKey, - passphrase: process.env.TKPHRASE, - verbose: !!process.env.TKVERBOSE, - dsn: process.env.TKDSN, -}; +const { Toolkit, Connection } = require('../../lib/itoolkit'); +const { config, printConfig } = require('./config'); +const { checkObjectExists } = require('./checkObjectExists'); const lib = 'NODETKTEST'; -const transports = returnTransports(opt); describe('Toolkit Functional Tests', () => { + before(() => { + printConfig(); + }); + describe('DataQueue Functional Tests', () => { const dqName = 'TESTQ'; - before('setup library for tests and create DQ', async () => { - // eslint-disable-next-line global-require - const { DBPool } = require('idb-pconnector'); - - const pool = new DBPool({ url: '*LOCAL' }, { incrementSize: 2 }); - - const qcmdexec = 'CALL QSYS2.QCMDEXC(?)'; - - const createLib = `CRTLIB LIB(${lib}) TYPE(*TEST) TEXT('Used to test Node.js toolkit')`; - - const createDQ = `CRTDTAQ DTAQ(${lib}/${dqName}) MAXLEN(100) AUT(*EXCLUDE) TEXT('TEST DQ FOR NODE TOOLKIT TESTS')`; - - const findLib = 'SELECT SCHEMA_NAME FROM qsys2.sysschemas WHERE SCHEMA_NAME = \'NODETKTEST\''; - - const findDQ = 'SELECT OBJLONGNAME FROM TABLE (QSYS2.OBJECT_STATISTICS(\'NODETKTEST\', \'*DTAQ\')) AS X'; - - const libResult = await pool.runSql(findLib); - - const dqResult = await pool.runSql(findDQ); - - if (!libResult.length) { - await pool.prepareExecute(qcmdexec, [createLib]).catch((error) => { - // eslint-disable-next-line no-console - console.log('Unable to Create Lib!'); - throw error; - }); - // eslint-disable-next-line no-console - console.log('CREATED LIB!'); - } - if (!dqResult.length) { - await pool.prepareExecute(qcmdexec, [createDQ]).catch((error) => { - // eslint-disable-next-line no-console - console.log('Unable to Create DQ!'); - throw error; - }); - // eslint-disable-next-line no-console - console.log('CREATED DQ!'); - } + before('check if data queue exists for tests', (done) => { + checkObjectExists(config, '*DTAQ', (error) => { + if (error) { throw error; } + done(); + }); }); - describe('sendToDataQueue', () => { - transports.forEach((transport) => { - it(`sends data to specified DQ using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('sends data to specified DQ', (done) => { + const connection = new Connection(config); - const toolkit = new Toolkit(connection); + const toolkit = new Toolkit(connection); - toolkit.sendToDataQueue(dqName, lib, 'Hello from DQ!', (error, output) => { - expect(error).to.equal(null); - expect(output).to.equal(true); - done(); - }); + toolkit.sendToDataQueue(dqName, lib, 'Hello from DQ!', (error, output) => { + expect(error).to.equal(null); + expect(output).to.equal(true); + done(); }); }); }); describe('receiveFromDataQueue', () => { - transports.forEach((transport) => { - it(`receives data from specfied DQ using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('receives data from specfied DQ', (done) => { + const connection = new Connection(config); - const toolkit = new Toolkit(connection); + const toolkit = new Toolkit(connection); - toolkit.receiveFromDataQueue(dqName, lib, 100, (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.a('string').and.to.equal('Hello from DQ!'); - done(); - }); + toolkit.receiveFromDataQueue(dqName, lib, 100, (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.a('string').and.to.equal('Hello from DQ!'); + done(); }); }); }); describe('clearDataQueue', () => { - transports.forEach((transport) => { - it(`clears the specifed DQ using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('clears the specifed DQ', (done) => { + const connection = new Connection(config); - const toolkit = new Toolkit(connection); + const toolkit = new Toolkit(connection); - toolkit.clearDataQueue(dqName, lib, (error, output) => { - expect(error).to.equal(null); - expect(output).to.equal(true); - done(); - }); + toolkit.clearDataQueue(dqName, lib, (error, output) => { + expect(error).to.equal(null); + expect(output).to.equal(true); + done(); }); }); }); }); describe('getTCPIPAttr', () => { - transports.forEach((transport) => { - it(`retrieves TCP/IP Attributes using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.getTCPIPAttr((error, output) => { - expect(error).to.equal(null); - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('TCP/IPv4_stack_status'); - expect(output).to.have.a.property('How_long_active'); - expect(output).to.have.a.property('When_last_started_-_date'); - expect(output).to.have.a.property('When_last_started_-_time'); - expect(output).to.have.a.property('When_last_ended_-_date'); - expect(output).to.have.a.property('When_last_ended_-_time'); - expect(output).to.have.a.property('Who_last_started_-_job_name'); - expect(output).to.have.a.property('Who_last_started_-_job_user_name'); - expect(output).to.have.a.property('Who_last_started_-_job_number'); - expect(output).to.have.a.property('Who_last_started_-_internal_job_identifier'); - expect(output).to.have.a.property('Who_last_ended_-_job_name'); - expect(output).to.have.a.property('Who_last_ended_-_job_user_name'); - expect(output).to.have.a.property('Who_last_ended_-_job_number'); - expect(output).to.have.a.property('Who_last_ended_-_internal_job_identifier'); - expect(output).to.have.a.property('Offset_to_additional_information'); - expect(output).to.have.a.property('Length_of_additional_information'); - expect(output).to.have.a.property('Limited_mode'); - expect(output).to.have.a.property('Offset_to_list_of_Internet_addresses'); - expect(output).to.have.a.property('Number_of_Internet_addresses'); - expect(output).to.have.a.property('Entry_length_for_list_of_Internet_addresses'); - expect(output).to.have.a.property('DNS_protocol'); - expect(output).to.have.a.property('Retries'); - expect(output).to.have.a.property('Time_interval'); - expect(output).to.have.a.property('Search_order'); - expect(output).to.have.a.property('Initial_domain_name_server'); - expect(output).to.have.a.property('DNS_listening_port'); - expect(output).to.have.a.property('Host_name'); - expect(output).to.have.a.property('Domain_name'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Domain_search_list'); - done(); - }); + it('retrieves TCP/IP Attributes', (done) => { + const connection = new Connection(config); + + const toolkit = new Toolkit(connection); + + toolkit.getTCPIPAttr((error, output) => { + expect(error).to.equal(null); + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('TCP/IPv4_stack_status'); + expect(output).to.have.a.property('How_long_active'); + expect(output).to.have.a.property('When_last_started_-_date'); + expect(output).to.have.a.property('When_last_started_-_time'); + expect(output).to.have.a.property('When_last_ended_-_date'); + expect(output).to.have.a.property('When_last_ended_-_time'); + expect(output).to.have.a.property('Who_last_started_-_job_name'); + expect(output).to.have.a.property('Who_last_started_-_job_user_name'); + expect(output).to.have.a.property('Who_last_started_-_job_number'); + expect(output).to.have.a.property('Who_last_started_-_internal_job_identifier'); + expect(output).to.have.a.property('Who_last_ended_-_job_name'); + expect(output).to.have.a.property('Who_last_ended_-_job_user_name'); + expect(output).to.have.a.property('Who_last_ended_-_job_number'); + expect(output).to.have.a.property('Who_last_ended_-_internal_job_identifier'); + expect(output).to.have.a.property('Offset_to_additional_information'); + expect(output).to.have.a.property('Length_of_additional_information'); + expect(output).to.have.a.property('Limited_mode'); + expect(output).to.have.a.property('Offset_to_list_of_Internet_addresses'); + expect(output).to.have.a.property('Number_of_Internet_addresses'); + expect(output).to.have.a.property('Entry_length_for_list_of_Internet_addresses'); + expect(output).to.have.a.property('DNS_protocol'); + expect(output).to.have.a.property('Retries'); + expect(output).to.have.a.property('Time_interval'); + expect(output).to.have.a.property('Search_order'); + expect(output).to.have.a.property('Initial_domain_name_server'); + expect(output).to.have.a.property('DNS_listening_port'); + expect(output).to.have.a.property('Host_name'); + expect(output).to.have.a.property('Domain_name'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Domain_search_list'); + done(); }); }); }); describe('getNetInterfaceData', () => { - transports.forEach((transport) => { - it(`retrieves IPv4 network interface info using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.getNetInterfaceData('127.0.0.1', (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Internet_address'); - expect(output).to.have.a.property('Internet_address_binary'); - expect(output).to.have.a.property('Network_address'); - expect(output).to.have.a.property('Network_address_binary'); - expect(output).to.have.a.property('Line_description'); - expect(output).to.have.a.property('Interface_status'); - expect(output).to.have.a.property('Interface_type_of_service'); - expect(output).to.have.a.property('Interface_MTU'); - expect(output).to.have.a.property('Interface_line_type'); - expect(output).to.have.a.property('Host_address'); - expect(output).to.have.a.property('Host_address_binary'); - expect(output).to.have.a.property('Interface_subnet_mask'); - expect(output).to.have.a.property('Interface_subnet_mask_binary'); - expect(output).to.have.a.property('Directed_broadcast_address'); - expect(output).to.have.a.property('Directed_broadcast_address_binary'); - expect(output).to.have.a.property('Change_date'); - expect(output).to.have.a.property('Change_time'); - expect(output).to.have.a.property('Associated_local_interface'); - expect(output).to.have.a.property('Associated_local_interface_binary'); - expect(output).to.have.a.property('Packet_rules'); - expect(output).to.have.a.property('Change_status'); - expect(output).to.have.a.property('Automatic_start'); - expect(output).to.have.a.property('TRLAN_bit_sequencing'); - expect(output).to.have.a.property('Interface_type'); - expect(output).to.have.a.property('Proxy_ARP_allowed'); - expect(output).to.have.a.property('Proxy_ARP_enabled'); - expect(output).to.have.a.property('Configured_MTU'); - expect(output).to.have.a.property('Network_name'); - expect(output).to.have.a.property('Interface_name'); - expect(output).to.have.a.property('Alias_name'); - expect(output).to.have.a.property('Interface_description'); - expect(output).to.have.a.property('Offset_to_preferred_interface_list'); - expect(output).to.have.a.property('Number_of_entries_in_preferred_interface_list'); - expect(output).to.have.a.property('Length_of_one_preferred_interface_list_entry'); - expect(output).to.have.a.property('DHCP_created'); - expect(output).to.have.a.property('DHCP_dynamic_DNS_updates'); - expect(output).to.have.a.property('DHCP_lease_expiration'); - expect(output).to.have.a.property('DHCP_lease_expiration_-_date'); - expect(output).to.have.a.property('DHCP_lease_expiration_-_time'); - expect(output).to.have.a.property('DHCP_lease_obtained'); - expect(output).to.have.a.property('DHCP_lease_obtained_-_date'); - expect(output).to.have.a.property('DHCP_lease_obtained_-_time'); - expect(output).to.have.a.property('Use_DHCP_unique_identifier'); - expect(output).to.have.a.property('DHCP_server_IP_address'); - expect(output).to.have.a.property('Preferred_interface_Internet_address'); - expect(output).to.have.a.property('Preferred_interface_Internet_address_binary'); - done(); - }); + it('retrieves IPv4 network interface info', (done) => { + const connection = new Connection(config); + + const toolkit = new Toolkit(connection); + + toolkit.getNetInterfaceData('127.0.0.1', (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Internet_address'); + expect(output).to.have.a.property('Internet_address_binary'); + expect(output).to.have.a.property('Network_address'); + expect(output).to.have.a.property('Network_address_binary'); + expect(output).to.have.a.property('Line_description'); + expect(output).to.have.a.property('Interface_status'); + expect(output).to.have.a.property('Interface_type_of_service'); + expect(output).to.have.a.property('Interface_MTU'); + expect(output).to.have.a.property('Interface_line_type'); + expect(output).to.have.a.property('Host_address'); + expect(output).to.have.a.property('Host_address_binary'); + expect(output).to.have.a.property('Interface_subnet_mask'); + expect(output).to.have.a.property('Interface_subnet_mask_binary'); + expect(output).to.have.a.property('Directed_broadcast_address'); + expect(output).to.have.a.property('Directed_broadcast_address_binary'); + expect(output).to.have.a.property('Change_date'); + expect(output).to.have.a.property('Change_time'); + expect(output).to.have.a.property('Associated_local_interface'); + expect(output).to.have.a.property('Associated_local_interface_binary'); + expect(output).to.have.a.property('Packet_rules'); + expect(output).to.have.a.property('Change_status'); + expect(output).to.have.a.property('Automatic_start'); + expect(output).to.have.a.property('TRLAN_bit_sequencing'); + expect(output).to.have.a.property('Interface_type'); + expect(output).to.have.a.property('Proxy_ARP_allowed'); + expect(output).to.have.a.property('Proxy_ARP_enabled'); + expect(output).to.have.a.property('Configured_MTU'); + expect(output).to.have.a.property('Network_name'); + expect(output).to.have.a.property('Interface_name'); + expect(output).to.have.a.property('Alias_name'); + expect(output).to.have.a.property('Interface_description'); + expect(output).to.have.a.property('Offset_to_preferred_interface_list'); + expect(output).to.have.a.property('Number_of_entries_in_preferred_interface_list'); + expect(output).to.have.a.property('Length_of_one_preferred_interface_list_entry'); + expect(output).to.have.a.property('DHCP_created'); + expect(output).to.have.a.property('DHCP_dynamic_DNS_updates'); + expect(output).to.have.a.property('DHCP_lease_expiration'); + expect(output).to.have.a.property('DHCP_lease_expiration_-_date'); + expect(output).to.have.a.property('DHCP_lease_expiration_-_time'); + expect(output).to.have.a.property('DHCP_lease_obtained'); + expect(output).to.have.a.property('DHCP_lease_obtained_-_date'); + expect(output).to.have.a.property('DHCP_lease_obtained_-_time'); + expect(output).to.have.a.property('Use_DHCP_unique_identifier'); + expect(output).to.have.a.property('DHCP_server_IP_address'); + expect(output).to.have.a.property('Preferred_interface_Internet_address'); + expect(output).to.have.a.property('Preferred_interface_Internet_address_binary'); + done(); }); }); }); describe('retrUsrAuth', () => { - transports.forEach((transport) => { - it(`returns uses's authority for an object using ${transport.name} tranport`, (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.retrUsrAuth('*PUBLIC', '*PGM', 'XMLCGI', 'QXMLSERV', (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Object_authority_/_Data_authority'); - expect(output).to.have.a.property('Authorization_list_management'); - expect(output).to.have.a.property('Object_operational'); - expect(output).to.have.a.property('Object_management'); - expect(output).to.have.a.property('Object_existence'); - expect(output).to.have.a.property('Data_read'); - expect(output).to.have.a.property('Data_add'); - expect(output).to.have.a.property('Data_update'); - expect(output).to.have.a.property('Data_delete'); - expect(output).to.have.a.property('Authorization_list'); - expect(output).to.have.a.property('Authority_source'); - expect(output).to.have.a.property('Some_adopted_authority'); - expect(output).to.have.a.property('Adopted_object_authority'); - expect(output).to.have.a.property('Adopted_authorization_list_management'); - expect(output).to.have.a.property('Adopted_object_operational'); - expect(output).to.have.a.property('Adopted_object_management'); - expect(output).to.have.a.property('Adopted_object_existence'); - expect(output).to.have.a.property('Adopted_data_read'); - expect(output).to.have.a.property('Adopted_data_add'); - expect(output).to.have.a.property('Adopted_data_update'); - expect(output).to.have.a.property('Adopted_data_delete'); - expect(output).to.have.a.property('Adopted_data_execute'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Adopted_object_alter'); - expect(output).to.have.a.property('Adopted_object_reference'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Data_execute'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Object_alter'); - expect(output).to.have.a.property('Object_reference'); - expect(output).to.have.a.property('ASP_device_name_of_library'); - expect(output).to.have.a.property('ASP_device_name_of_object'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Offset_to_group_information_table'); - expect(output).to.have.a.property('Number_of_group_table_entries_returned'); - done(); - }); + it(`returns uses's authority for an object using ${config.transport} tranport`, (done) => { + const connection = new Connection(config); + + const toolkit = new Toolkit(connection); + + toolkit.retrUsrAuth('*PUBLIC', '*PGM', 'XMLCGI', 'QXMLSERV', (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Object_authority_/_Data_authority'); + expect(output).to.have.a.property('Authorization_list_management'); + expect(output).to.have.a.property('Object_operational'); + expect(output).to.have.a.property('Object_management'); + expect(output).to.have.a.property('Object_existence'); + expect(output).to.have.a.property('Data_read'); + expect(output).to.have.a.property('Data_add'); + expect(output).to.have.a.property('Data_update'); + expect(output).to.have.a.property('Data_delete'); + expect(output).to.have.a.property('Authorization_list'); + expect(output).to.have.a.property('Authority_source'); + expect(output).to.have.a.property('Some_adopted_authority'); + expect(output).to.have.a.property('Adopted_object_authority'); + expect(output).to.have.a.property('Adopted_authorization_list_management'); + expect(output).to.have.a.property('Adopted_object_operational'); + expect(output).to.have.a.property('Adopted_object_management'); + expect(output).to.have.a.property('Adopted_object_existence'); + expect(output).to.have.a.property('Adopted_data_read'); + expect(output).to.have.a.property('Adopted_data_add'); + expect(output).to.have.a.property('Adopted_data_update'); + expect(output).to.have.a.property('Adopted_data_delete'); + expect(output).to.have.a.property('Adopted_data_execute'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Adopted_object_alter'); + expect(output).to.have.a.property('Adopted_object_reference'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Data_execute'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Object_alter'); + expect(output).to.have.a.property('Object_reference'); + expect(output).to.have.a.property('ASP_device_name_of_library'); + expect(output).to.have.a.property('ASP_device_name_of_object'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Offset_to_group_information_table'); + expect(output).to.have.a.property('Number_of_group_table_entries_returned'); + done(); }); }); }); describe('rtrCmdInfo', () => { - transports.forEach((transport) => { - it(`returns command info using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.retrCmdInfo('CRTLIB', '*LIBL', (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Command_name'); - expect(output).to.have.a.property('Command_library_name'); - expect(output).to.have.a.property('Command_processing_program_or_proxy_target_command'); - expect(output).to.have.a.property('Command_processing_program\'s_or_proxy_target_command\'s_library_name'); - expect(output).to.have.a.property('Source_file_name'); - expect(output).to.have.a.property('Source_file_library_name'); - expect(output).to.have.a.property('Source_file_member_name'); - expect(output).to.have.a.property('Validity_check_program_name'); - expect(output).to.have.a.property('Validity_check_program_library_name'); - expect(output).to.have.a.property('Mode_information'); - expect(output).to.have.a.property('Where_allowed_to_run'); - expect(output).to.have.a.property('Allow_limited_user'); - expect(output).to.have.a.property('Maximum_positional_parameters'); - expect(output).to.have.a.property('Prompt_message_file_name'); - expect(output).to.have.a.property('Prompt_message_file_library_name'); - expect(output).to.have.a.property('Message_file_name'); - expect(output).to.have.a.property('Message_file_library_name'); - expect(output).to.have.a.property('Help_panel_group_name'); - expect(output).to.have.a.property('Help_panel_group_library_name'); - expect(output).to.have.a.property('Help_identifier'); - expect(output).to.have.a.property('Search_index_name'); - expect(output).to.have.a.property('Search_index_library_name'); - expect(output).to.have.a.property('Current_library'); - expect(output).to.have.a.property('Product_library'); - expect(output).to.have.a.property('Prompt_override_program_name'); - expect(output).to.have.a.property('Prompt_override_program_library_name'); - expect(output).to.have.a.property('Restricted_to_target_release'); - expect(output).to.have.a.property('Text_description'); - expect(output).to.have.a.property('Command_processing_program_call_state'); - expect(output).to.have.a.property('Validity_check_program_call_state'); - expect(output).to.have.a.property('Prompt_override_program_call_state'); - expect(output).to.have.a.property('Offset_to_help_bookshelf_information'); - expect(output).to.have.a.property('Length_of_help_bookshelf_information'); - expect(output).to.have.a.property('Coded_character_set_ID_(CCSID)'); - expect(output).to.have.a.property('Enabled_for_GUI_indicator'); - expect(output).to.have.a.property('Threadsafe_indicator'); - expect(output).to.have.a.property('Multithreaded_job_action'); - expect(output).to.have.a.property('Proxy_command_indicator'); - expect(output).to.have.a.property('Prompt_message_file_text_indicator'); - done(); - }); + it('returns command info', (done) => { + const connection = new Connection(config); + + const toolkit = new Toolkit(connection); + + toolkit.retrCmdInfo('CRTLIB', '*LIBL', (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Command_name'); + expect(output).to.have.a.property('Command_library_name'); + expect(output).to.have.a.property('Command_processing_program_or_proxy_target_command'); + expect(output).to.have.a.property('Command_processing_program\'s_or_proxy_target_command\'s_library_name'); + expect(output).to.have.a.property('Source_file_name'); + expect(output).to.have.a.property('Source_file_library_name'); + expect(output).to.have.a.property('Source_file_member_name'); + expect(output).to.have.a.property('Validity_check_program_name'); + expect(output).to.have.a.property('Validity_check_program_library_name'); + expect(output).to.have.a.property('Mode_information'); + expect(output).to.have.a.property('Where_allowed_to_run'); + expect(output).to.have.a.property('Allow_limited_user'); + expect(output).to.have.a.property('Maximum_positional_parameters'); + expect(output).to.have.a.property('Prompt_message_file_name'); + expect(output).to.have.a.property('Prompt_message_file_library_name'); + expect(output).to.have.a.property('Message_file_name'); + expect(output).to.have.a.property('Message_file_library_name'); + expect(output).to.have.a.property('Help_panel_group_name'); + expect(output).to.have.a.property('Help_panel_group_library_name'); + expect(output).to.have.a.property('Help_identifier'); + expect(output).to.have.a.property('Search_index_name'); + expect(output).to.have.a.property('Search_index_library_name'); + expect(output).to.have.a.property('Current_library'); + expect(output).to.have.a.property('Product_library'); + expect(output).to.have.a.property('Prompt_override_program_name'); + expect(output).to.have.a.property('Prompt_override_program_library_name'); + expect(output).to.have.a.property('Restricted_to_target_release'); + expect(output).to.have.a.property('Text_description'); + expect(output).to.have.a.property('Command_processing_program_call_state'); + expect(output).to.have.a.property('Validity_check_program_call_state'); + expect(output).to.have.a.property('Prompt_override_program_call_state'); + expect(output).to.have.a.property('Offset_to_help_bookshelf_information'); + expect(output).to.have.a.property('Length_of_help_bookshelf_information'); + expect(output).to.have.a.property('Coded_character_set_ID_(CCSID)'); + expect(output).to.have.a.property('Enabled_for_GUI_indicator'); + expect(output).to.have.a.property('Threadsafe_indicator'); + expect(output).to.have.a.property('Multithreaded_job_action'); + expect(output).to.have.a.property('Proxy_command_indicator'); + expect(output).to.have.a.property('Prompt_message_file_text_indicator'); + done(); }); }); }); describe('retrPgmInfo', () => { - transports.forEach((transport) => { - it(`returns program info using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.retrPgmInfo('XMLCGI', 'QXMLSERV', (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Program_name'); - expect(output).to.have.a.property('Program_library_name'); - expect(output).to.have.a.property('Program_owner'); - expect(output).to.have.a.property('Program_attribute'); - expect(output).to.have.a.property('Creation_date_and_time'); - expect(output).to.have.a.property('Source_file_name'); - expect(output).to.have.a.property('Source_file_library_name'); - expect(output).to.have.a.property('Source_file_member_name'); - expect(output).to.have.a.property('Source_file_updated_date_and_time'); - expect(output).to.have.a.property('Observable_information'); - expect(output).to.have.a.property('User_profile_option'); - expect(output).to.have.a.property('Use_adopted_authority'); - expect(output).to.have.a.property('Log_commands'); - expect(output).to.have.a.property('Allow_RTVCLSRC'); - expect(output).to.have.a.property('Fix_decimal_data'); - expect(output).to.have.a.property('Text_description'); - expect(output).to.have.a.property('Type_of_program'); - expect(output).to.have.a.property('Teraspace_storage-enabled_program'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Minimum_number_of_parameters'); - expect(output).to.have.a.property('Maximum_number_of_parameters'); - expect(output).to.have.a.property('Program_size'); - expect(output).to.have.a.property('Associated_space_size'); - expect(output).to.have.a.property('Static_storage_size'); - expect(output).to.have.a.property('Automatic_storage_size'); - expect(output).to.have.a.property('Number_of_MI_instructions'); - expect(output).to.have.a.property('Number_of_MI_ODT_entries'); - expect(output).to.have.a.property('Program_state'); - expect(output).to.have.a.property('Compiler_identification'); - expect(output).to.have.a.property('Earliest_release_program_can_run'); - expect(output).to.have.a.property('Sort_sequence_table_name'); - expect(output).to.have.a.property('Sort_sequence_table_library_name'); - expect(output).to.have.a.property('Language_identifier'); - expect(output).to.have.a.property('Program_domain'); - expect(output).to.have.a.property('Conversion_required'); - expect(output).to.have.a.property('Conversion_details'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Optimization'); - expect(output).to.have.a.property('Paging_pool'); - expect(output).to.have.a.property('Update_program_automatic_storage_area_(PASA)'); - expect(output).to.have.a.property('Clear_program_automatic_storage_area_(PASA)'); - expect(output).to.have.a.property('Paging_amount'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Program_entry_procedure_module'); - expect(output).to.have.a.property('Program_entry_procedure_module_library'); - expect(output).to.have.a.property('Activation_group_attribute'); - expect(output).to.have.a.property('Observable_information_compressed'); - expect(output).to.have.a.property('Run-time_information_compressed'); - expect(output).to.have.a.property('Release_program_created_on'); - expect(output).to.have.a.property('Shared_activation_group'); - expect(output).to.have.a.property('Allow_update'); - expect(output).to.have.a.property('Program_CCSID'); - expect(output).to.have.a.property('Number_of_modules'); - expect(output).to.have.a.property('Number_of_service_programs'); - expect(output).to.have.a.property('Number_of_copyrights'); - expect(output).to.have.a.property('Number_of_unresolved_references'); - expect(output).to.have.a.property('Release_program_created_for'); - expect(output).to.have.a.property('Allow_static_storage_reinitialization'); - expect(output).to.have.a.property('All_creation_data'); - expect(output).to.have.a.property('Allow_bound_*SRVPGM_library_name_update'); - expect(output).to.have.a.property('Profiling_data'); - expect(output).to.have.a.property('Teraspace_storage_enabled_modules'); - expect(output).to.have.a.property('Storage_model'); - expect(output).to.have.a.property('Uses_argument_optimization_(ARGOPT)'); - done(); - }); + it('returns program info', (done) => { + const connection = new Connection(config); + + const toolkit = new Toolkit(connection); + + toolkit.retrPgmInfo('XMLCGI', 'QXMLSERV', (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Program_name'); + expect(output).to.have.a.property('Program_library_name'); + expect(output).to.have.a.property('Program_owner'); + expect(output).to.have.a.property('Program_attribute'); + expect(output).to.have.a.property('Creation_date_and_time'); + expect(output).to.have.a.property('Source_file_name'); + expect(output).to.have.a.property('Source_file_library_name'); + expect(output).to.have.a.property('Source_file_member_name'); + expect(output).to.have.a.property('Source_file_updated_date_and_time'); + expect(output).to.have.a.property('Observable_information'); + expect(output).to.have.a.property('User_profile_option'); + expect(output).to.have.a.property('Use_adopted_authority'); + expect(output).to.have.a.property('Log_commands'); + expect(output).to.have.a.property('Allow_RTVCLSRC'); + expect(output).to.have.a.property('Fix_decimal_data'); + expect(output).to.have.a.property('Text_description'); + expect(output).to.have.a.property('Type_of_program'); + expect(output).to.have.a.property('Teraspace_storage-enabled_program'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Minimum_number_of_parameters'); + expect(output).to.have.a.property('Maximum_number_of_parameters'); + expect(output).to.have.a.property('Program_size'); + expect(output).to.have.a.property('Associated_space_size'); + expect(output).to.have.a.property('Static_storage_size'); + expect(output).to.have.a.property('Automatic_storage_size'); + expect(output).to.have.a.property('Number_of_MI_instructions'); + expect(output).to.have.a.property('Number_of_MI_ODT_entries'); + expect(output).to.have.a.property('Program_state'); + expect(output).to.have.a.property('Compiler_identification'); + expect(output).to.have.a.property('Earliest_release_program_can_run'); + expect(output).to.have.a.property('Sort_sequence_table_name'); + expect(output).to.have.a.property('Sort_sequence_table_library_name'); + expect(output).to.have.a.property('Language_identifier'); + expect(output).to.have.a.property('Program_domain'); + expect(output).to.have.a.property('Conversion_required'); + expect(output).to.have.a.property('Conversion_details'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Optimization'); + expect(output).to.have.a.property('Paging_pool'); + expect(output).to.have.a.property('Update_program_automatic_storage_area_(PASA)'); + expect(output).to.have.a.property('Clear_program_automatic_storage_area_(PASA)'); + expect(output).to.have.a.property('Paging_amount'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Program_entry_procedure_module'); + expect(output).to.have.a.property('Program_entry_procedure_module_library'); + expect(output).to.have.a.property('Activation_group_attribute'); + expect(output).to.have.a.property('Observable_information_compressed'); + expect(output).to.have.a.property('Run-time_information_compressed'); + expect(output).to.have.a.property('Release_program_created_on'); + expect(output).to.have.a.property('Shared_activation_group'); + expect(output).to.have.a.property('Allow_update'); + expect(output).to.have.a.property('Program_CCSID'); + expect(output).to.have.a.property('Number_of_modules'); + expect(output).to.have.a.property('Number_of_service_programs'); + expect(output).to.have.a.property('Number_of_copyrights'); + expect(output).to.have.a.property('Number_of_unresolved_references'); + expect(output).to.have.a.property('Release_program_created_for'); + expect(output).to.have.a.property('Allow_static_storage_reinitialization'); + expect(output).to.have.a.property('All_creation_data'); + expect(output).to.have.a.property('Allow_bound_*SRVPGM_library_name_update'); + expect(output).to.have.a.property('Profiling_data'); + expect(output).to.have.a.property('Teraspace_storage_enabled_modules'); + expect(output).to.have.a.property('Storage_model'); + expect(output).to.have.a.property('Uses_argument_optimization_(ARGOPT)'); + done(); }); }); }); describe('retrSrvPgmInfo', () => { - transports.forEach((transport) => { - it(`returns service program info using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.retrSrvPgmInfo('QZSRVSSL', 'QHTTPSVR', (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Service_program_name'); - expect(output).to.have.a.property('Service_program_name'); - expect(output).to.have.a.property('Service_program_owner'); - expect(output).to.have.a.property('Service_program_attribute'); - expect(output).to.have.a.property('Creation_date_and_time'); - expect(output).to.have.a.property('Export_source_file_name'); - expect(output).to.have.a.property('Export_source_file_library_name'); - expect(output).to.have.a.property('Export_source_file_member_name'); - expect(output).to.have.a.property('Activation_group_attribute'); - expect(output).to.have.a.property('Current_export_signature'); - expect(output).to.have.a.property('User_profile'); - expect(output).to.have.a.property('Observable_information_compressed'); - expect(output).to.have.a.property('Run-time_information_compressed'); - expect(output).to.have.a.property('Run-time_information_compressed'); - expect(output).to.have.a.property('Service_program_CCSID'); - expect(output).to.have.a.property('Number_of_modules'); - expect(output).to.have.a.property('Number_of_service_programs'); - expect(output).to.have.a.property('Number_of_copyrights'); - expect(output).to.have.a.property('Text_description'); - expect(output).to.have.a.property('Shared_activation_group'); - expect(output).to.have.a.property('Allow_update'); - expect(output).to.have.a.property('Number_of_unresolved_references'); - expect(output).to.have.a.property('Use_adopted_authority'); - expect(output).to.have.a.property('Allow_bound_*SRVPGM_library_name_update'); - expect(output).to.have.a.property('Profiling_data'); - expect(output).to.have.a.property('Teraspace_storage_enabled_modules'); - expect(output).to.have.a.property('Storage_model'); - expect(output).to.have.a.property('Uses_argument_optimization_(ARGOPT)'); - expect(output).to.have.a.property('Reserved_\'00\'X'); - expect(output).to.have.a.property('Service_program_state'); - expect(output).to.have.a.property('Service_program_domain'); - expect(output).to.have.a.property('Associated_space_size'); - expect(output).to.have.a.property('Static_storage_size'); - expect(output).to.have.a.property('Service_program_size'); - expect(output).to.have.a.property('Release_service_program_created_on'); - expect(output).to.have.a.property('Earliest_release_service_program_can_run'); - expect(output).to.have.a.property('Release_service_program_created_for'); - expect(output).to.have.a.property('Allow_static_storage_reinitialization'); - expect(output).to.have.a.property('Conversion_required'); - expect(output).to.have.a.property('All_creation_data'); - expect(output).to.have.a.property('Conversion_details'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Paging_pool'); - expect(output).to.have.a.property('Paging_amount'); - done(); - }); + it('returns service program info', (done) => { + const connection = new Connection(config); + + const toolkit = new Toolkit(connection); + + toolkit.retrSrvPgmInfo('QZSRVSSL', 'QHTTPSVR', (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Service_program_name'); + expect(output).to.have.a.property('Service_program_name'); + expect(output).to.have.a.property('Service_program_owner'); + expect(output).to.have.a.property('Service_program_attribute'); + expect(output).to.have.a.property('Creation_date_and_time'); + expect(output).to.have.a.property('Export_source_file_name'); + expect(output).to.have.a.property('Export_source_file_library_name'); + expect(output).to.have.a.property('Export_source_file_member_name'); + expect(output).to.have.a.property('Activation_group_attribute'); + expect(output).to.have.a.property('Current_export_signature'); + expect(output).to.have.a.property('User_profile'); + expect(output).to.have.a.property('Observable_information_compressed'); + expect(output).to.have.a.property('Run-time_information_compressed'); + expect(output).to.have.a.property('Run-time_information_compressed'); + expect(output).to.have.a.property('Service_program_CCSID'); + expect(output).to.have.a.property('Number_of_modules'); + expect(output).to.have.a.property('Number_of_service_programs'); + expect(output).to.have.a.property('Number_of_copyrights'); + expect(output).to.have.a.property('Text_description'); + expect(output).to.have.a.property('Shared_activation_group'); + expect(output).to.have.a.property('Allow_update'); + expect(output).to.have.a.property('Number_of_unresolved_references'); + expect(output).to.have.a.property('Use_adopted_authority'); + expect(output).to.have.a.property('Allow_bound_*SRVPGM_library_name_update'); + expect(output).to.have.a.property('Profiling_data'); + expect(output).to.have.a.property('Teraspace_storage_enabled_modules'); + expect(output).to.have.a.property('Storage_model'); + expect(output).to.have.a.property('Uses_argument_optimization_(ARGOPT)'); + expect(output).to.have.a.property('Reserved_\'00\'X'); + expect(output).to.have.a.property('Service_program_state'); + expect(output).to.have.a.property('Service_program_domain'); + expect(output).to.have.a.property('Associated_space_size'); + expect(output).to.have.a.property('Static_storage_size'); + expect(output).to.have.a.property('Service_program_size'); + expect(output).to.have.a.property('Release_service_program_created_on'); + expect(output).to.have.a.property('Earliest_release_service_program_can_run'); + expect(output).to.have.a.property('Release_service_program_created_for'); + expect(output).to.have.a.property('Allow_static_storage_reinitialization'); + expect(output).to.have.a.property('Conversion_required'); + expect(output).to.have.a.property('All_creation_data'); + expect(output).to.have.a.property('Conversion_details'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Paging_pool'); + expect(output).to.have.a.property('Paging_amount'); + done(); }); }); }); describe('retrUserInfo', () => { - transports.forEach((transport) => { - it(`returns specified user profile info using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.retrUserInfo('QSYS', (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('User_profile_name'); - expect(output).to.have.a.property('Previous_sign-on_date_and_time'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Sign-on_attempts_not_valid'); - expect(output).to.have.a.property('Status'); - expect(output).to.have.a.property('Password_change_date'); - expect(output).to.have.a.property('No_password_indicator'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Password_expiration_interval'); - expect(output).to.have.a.property('Date_password_expires'); - expect(output).to.have.a.property('Days_until_password_expires'); - expect(output).to.have.a.property('Set_password_to_expire'); - expect(output).to.have.a.property('Display_sign-on_information'); - expect(output).to.have.a.property('Local_password_management'); - expect(output).to.have.a.property('Block_password_change'); - done(); - }); + it('returns specified user profile info', (done) => { + const connection = new Connection(config); + + const toolkit = new Toolkit(connection); + + toolkit.retrUserInfo('QSYS', (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('User_profile_name'); + expect(output).to.have.a.property('Previous_sign-on_date_and_time'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Sign-on_attempts_not_valid'); + expect(output).to.have.a.property('Status'); + expect(output).to.have.a.property('Password_change_date'); + expect(output).to.have.a.property('No_password_indicator'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Password_expiration_interval'); + expect(output).to.have.a.property('Date_password_expires'); + expect(output).to.have.a.property('Days_until_password_expires'); + expect(output).to.have.a.property('Set_password_to_expire'); + expect(output).to.have.a.property('Display_sign-on_information'); + expect(output).to.have.a.property('Local_password_management'); + expect(output).to.have.a.property('Block_password_change'); + done(); }); }); }); describe('retrUsrAuthToObj', () => { - transports.forEach((transport) => { - it(`retrieves info for users who are authorized to an object using ${transport.name} transpsort`, (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.retrUserAuthToObj('/home', (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Profile_name'); - expect(output).to.have.a.property('User_or_group_indicator'); - expect(output).to.have.a.property('Data_authority'); - expect(output).to.have.a.property('Authorization_list_management'); - expect(output).to.have.a.property('Object_management'); - expect(output).to.have.a.property('Object_existence'); - expect(output).to.have.a.property('Object_alter'); - expect(output).to.have.a.property('Object_reference'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Object_operational'); - expect(output).to.have.a.property('Data_read'); - expect(output).to.have.a.property('Data_add'); - expect(output).to.have.a.property('Data_update'); - expect(output).to.have.a.property('Data_delete'); - expect(output).to.have.a.property('Data_execute'); - done(); - }); + it(`retrieves info for users who are authorized to an object using ${config.transport} transpsort`, (done) => { + const connection = new Connection(config); + + const toolkit = new Toolkit(connection); + + toolkit.retrUserAuthToObj('/home', (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Profile_name'); + expect(output).to.have.a.property('User_or_group_indicator'); + expect(output).to.have.a.property('Data_authority'); + expect(output).to.have.a.property('Authorization_list_management'); + expect(output).to.have.a.property('Object_management'); + expect(output).to.have.a.property('Object_existence'); + expect(output).to.have.a.property('Object_alter'); + expect(output).to.have.a.property('Object_reference'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Object_operational'); + expect(output).to.have.a.property('Data_read'); + expect(output).to.have.a.property('Data_add'); + expect(output).to.have.a.property('Data_update'); + expect(output).to.have.a.property('Data_delete'); + expect(output).to.have.a.property('Data_execute'); + done(); }); }); }); describe('addToLibraryList', () => { - transports.forEach((transport) => { - it(`appends lib to user's lib list using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('appends lib to user\'s lib list', (done) => { + const connection = new Connection(config); - const toolkit = new Toolkit(connection); + const toolkit = new Toolkit(connection); - toolkit.addToLibraryList('QHTTPSVR', (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.a('boolean').and.to.equal(true); - done(); - }); + toolkit.addToLibraryList('QHTTPSVR', (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.a('boolean').and.to.equal(true); + done(); }); }); }); describe('getPTFInfo', () => { - transports.forEach((transport) => { - it(`returns info for specified ptf using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.getPTFInfo('SI67726', (error, ptf) => { - expect(error).to.equal(null); - expect(ptf).to.be.an('Object'); - expect(ptf).to.have.a.property('Product_ID'); - expect(ptf).to.have.a.property('PTF_ID'); - expect(ptf).to.have.a.property('Release_level'); - expect(ptf).to.have.a.property('Product_option'); - expect(ptf).to.have.a.property('Load_ID'); - expect(ptf).to.have.a.property('Loaded_status'); - expect(ptf).to.have.a.property('Cover_letter_status'); - expect(ptf).to.have.a.property('On-order_status'); - expect(ptf).to.have.a.property('Save_file_status'); - expect(ptf).to.have.a.property('File_name'); - expect(ptf).to.have.a.property('File_library_name'); - expect(ptf).to.have.a.property('PTF_type'); - expect(ptf).to.have.a.property('IPL_action'); - expect(ptf).to.have.a.property('Action_pending'); - expect(ptf).to.have.a.property('Action_required'); - expect(ptf).to.have.a.property('PTF_is_released'); - expect(ptf).to.have.a.property('Target_release'); - expect(ptf).to.have.a.property('Superseding_PTF'); - expect(ptf).to.have.a.property('Current_IPL_source'); - expect(ptf).to.have.a.property('Minimum_level'); - expect(ptf).to.have.a.property('Maximum_level'); - expect(ptf).to.have.a.property('Format_information_available'); - expect(ptf).to.have.a.property('Status_date_and_time'); - expect(ptf).to.have.a.property('Licensed_Internal_Code_group'); - expect(ptf).to.have.a.property('Superseded_by_PTF_ID'); - expect(ptf).to.have.a.property('Current_server_IPL_source'); - expect(ptf).to.have.a.property('Server_IPL_required'); - expect(ptf).to.have.a.property('Creation_date_and_time'); - expect(ptf).to.have.a.property('Technology_refresh_PTF'); - expect(ptf).to.have.a.property('Reserved'); - done(); - }); + it('returns info for specified ptf', (done) => { + const connection = new Connection(config); + + const toolkit = new Toolkit(connection); + + toolkit.getPTFInfo('SI67726', (error, ptf) => { + expect(error).to.equal(null); + expect(ptf).to.be.an('Object'); + expect(ptf).to.have.a.property('Product_ID'); + expect(ptf).to.have.a.property('PTF_ID'); + expect(ptf).to.have.a.property('Release_level'); + expect(ptf).to.have.a.property('Product_option'); + expect(ptf).to.have.a.property('Load_ID'); + expect(ptf).to.have.a.property('Loaded_status'); + expect(ptf).to.have.a.property('Cover_letter_status'); + expect(ptf).to.have.a.property('On-order_status'); + expect(ptf).to.have.a.property('Save_file_status'); + expect(ptf).to.have.a.property('File_name'); + expect(ptf).to.have.a.property('File_library_name'); + expect(ptf).to.have.a.property('PTF_type'); + expect(ptf).to.have.a.property('IPL_action'); + expect(ptf).to.have.a.property('Action_pending'); + expect(ptf).to.have.a.property('Action_required'); + expect(ptf).to.have.a.property('PTF_is_released'); + expect(ptf).to.have.a.property('Target_release'); + expect(ptf).to.have.a.property('Superseding_PTF'); + expect(ptf).to.have.a.property('Current_IPL_source'); + expect(ptf).to.have.a.property('Minimum_level'); + expect(ptf).to.have.a.property('Maximum_level'); + expect(ptf).to.have.a.property('Format_information_available'); + expect(ptf).to.have.a.property('Status_date_and_time'); + expect(ptf).to.have.a.property('Licensed_Internal_Code_group'); + expect(ptf).to.have.a.property('Superseded_by_PTF_ID'); + expect(ptf).to.have.a.property('Current_server_IPL_source'); + expect(ptf).to.have.a.property('Server_IPL_required'); + expect(ptf).to.have.a.property('Creation_date_and_time'); + expect(ptf).to.have.a.property('Technology_refresh_PTF'); + expect(ptf).to.have.a.property('Reserved'); + done(); }); }); }); describe('getProductInfo', () => { - transports.forEach((transport) => { - it(`returns info for specified product using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.getProductInfo('5770DG1', (error, product) => { - expect(error).to.equal(null); - expect(product).to.be.an('Object'); - expect(product).to.have.a.property('Reserved'); - expect(product).to.have.a.property('Product_ID'); - expect(product).to.have.a.property('Release_level'); - expect(product).to.have.a.property('Product_option'); - expect(product).to.have.a.property('Load_ID'); - expect(product).to.have.a.property('Symbolic_load_state'); - expect(product).to.have.a.property('Load_error_indicator'); - expect(product).to.have.a.property('Load_state'); - expect(product).to.have.a.property('Supported_flag'); - expect(product).to.have.a.property('Registration_type'); - expect(product).to.have.a.property('Registration_value'); - expect(product).to.have.a.property('Offset_to_additional_information'); - expect(product).to.have.a.property('Primary_language_load_identifier'); - expect(product).to.have.a.property('Minimum_target_release'); - expect(product).to.have.a.property('Minimum_VRM_of_*BASE_required_by_option'); - expect(product).to.have.a.property('Requirements_met_between_base_and_option_value'); - expect(product).to.have.a.property('Level'); - done(); - }); + it('returns info for specified product', (done) => { + const connection = new Connection(config); + + const toolkit = new Toolkit(connection); + + toolkit.getProductInfo('5770DG1', (error, product) => { + expect(error).to.equal(null); + expect(product).to.be.an('Object'); + expect(product).to.have.a.property('Reserved'); + expect(product).to.have.a.property('Product_ID'); + expect(product).to.have.a.property('Release_level'); + expect(product).to.have.a.property('Product_option'); + expect(product).to.have.a.property('Load_ID'); + expect(product).to.have.a.property('Symbolic_load_state'); + expect(product).to.have.a.property('Load_error_indicator'); + expect(product).to.have.a.property('Load_state'); + expect(product).to.have.a.property('Supported_flag'); + expect(product).to.have.a.property('Registration_type'); + expect(product).to.have.a.property('Registration_value'); + expect(product).to.have.a.property('Offset_to_additional_information'); + expect(product).to.have.a.property('Primary_language_load_identifier'); + expect(product).to.have.a.property('Minimum_target_release'); + expect(product).to.have.a.property('Minimum_VRM_of_*BASE_required_by_option'); + expect(product).to.have.a.property('Requirements_met_between_base_and_option_value'); + expect(product).to.have.a.property('Level'); + done(); }); }); }); @@ -649,343 +572,286 @@ describe('Toolkit Functional Tests', () => { // REST transport currently failing with 414 URI Too Long response code // The requested URL's length exceeds the capacity limit for this server describe('getInstalledProducts', () => { - transports.forEach((transport) => { - // eslint-disable-next-line func-names - it(`returns info for installed products using ${transport.name} transport`, function (done) { - const connection = transport.me; + // eslint-disable-next-line func-names + it('returns info for installed products', (done) => { + const connection = new Connection(config); - const toolkit = new Toolkit(connection); + const toolkit = new Toolkit(connection); - toolkit.getInstalledProducts((error, products) => { - expect(error).to.equal(null); - expect(products).to.be.an('Array'); - expect(products.length).to.be.greaterThan(0); - - products.forEach((product) => { - expect(product).to.be.an('Object'); - expect(product).to.have.a.property('Product_ID'); - expect(product).to.have.a.property('Product_option'); - expect(product).to.have.a.property('Release_level'); - expect(product).to.have.a.property('Description_text_message_ID'); - expect(product).to.have.a.property('Description_text_object_name'); - expect(product).to.have.a.property('Description_text_library_name'); - expect(product).to.have.a.property('Installed_flag'); - expect(product).to.have.a.property('Supported_flag'); - expect(product).to.have.a.property('Registration_type'); - expect(product).to.have.a.property('Registration_value'); - expect(product).to.have.a.property('Description_text'); - }); - done(); + toolkit.getInstalledProducts((error, products) => { + expect(error).to.equal(null); + expect(products).to.be.an('Array'); + expect(products.length).to.be.greaterThan(0); + + products.forEach((product) => { + expect(product).to.be.an('Object'); + expect(product).to.have.a.property('Product_ID'); + expect(product).to.have.a.property('Product_option'); + expect(product).to.have.a.property('Release_level'); + expect(product).to.have.a.property('Description_text_message_ID'); + expect(product).to.have.a.property('Description_text_object_name'); + expect(product).to.have.a.property('Description_text_library_name'); + expect(product).to.have.a.property('Installed_flag'); + expect(product).to.have.a.property('Supported_flag'); + expect(product).to.have.a.property('Registration_type'); + expect(product).to.have.a.property('Registration_value'); + expect(product).to.have.a.property('Description_text'); }); + done(); }); }); }); describe('UserSpace Functional Tests', () => { describe('createUserSpace', () => { - transports.forEach((transport) => { - it(`creates a user space using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('creates a user space', (done) => { + const connection = new Connection(config); - const toolkit = new Toolkit(connection); + const toolkit = new Toolkit(connection); - const description = 'Node toolkit test user space'; + const description = 'Node toolkit test user space'; - const userSpaceName = `USP${(transport.name).toUpperCase()}`; + const userSpaceName = `USP${(config.transport).toUpperCase()}`; - toolkit.createUserSpace(userSpaceName, lib, 'LOG', 50, '*EXCLUDE', - description, (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.a('boolean').and.to.equal(true); - done(); - }); - }); + toolkit.createUserSpace(userSpaceName, lib, 'LOG', 50, '*EXCLUDE', + description, (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.a('boolean').and.to.equal(true); + done(); + }); }); }); describe('setUserSpaceData', () => { - transports.forEach((transport) => { - it(`sets data within the user space using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('sets data within the user space', (done) => { + const connection = new Connection(config); - const toolkit = new Toolkit(connection); + const toolkit = new Toolkit(connection); - const msg = 'Hello from userspace!'; + const msg = 'Hello from userspace!'; - const userSpaceName = `USP${(transport.name).toUpperCase()}`; + const userSpaceName = `USP${(config.transport).toUpperCase()}`; - toolkit.setUserSpaceData(userSpaceName, lib, msg.length, msg, - (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.a('boolean').and.to.equal(true); - done(); - }); - }); + toolkit.setUserSpaceData(userSpaceName, lib, msg.length, msg, + (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.a('boolean').and.to.equal(true); + done(); + }); }); }); describe('getUserSpaceData', () => { - transports.forEach((transport) => { - it(`returns specified length of data using ${transport.name} transport`, - (done) => { - const connection = transport.me; + it('returns specified length of data', + (done) => { + const connection = new Connection(config); - const toolkit = new Toolkit(connection); + const toolkit = new Toolkit(connection); - const userSpaceName = `USP${(transport.name).toUpperCase()}`; + const userSpaceName = `USP${(config.transport).toUpperCase()}`; - toolkit.getUserSpaceData(userSpaceName, lib, 21, (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.a('string').and.to.equal('Hello from userspace!'); - done(); - }); + toolkit.getUserSpaceData(userSpaceName, lib, 21, (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.a('string').and.to.equal('Hello from userspace!'); + done(); }); - }); + }); }); describe('deleteUserSpace', () => { - transports.forEach((transport) => { - it(`removes a user space using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('removes a user space', (done) => { + const connection = new Connection(config); - const toolkit = new Toolkit(connection); + const toolkit = new Toolkit(connection); - const userSpaceName = `USP${(transport.name).toUpperCase()}`; + const userSpaceName = `USP${(config.transport).toUpperCase()}`; - toolkit.deleteUserSpace(userSpaceName, lib, (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.a('boolean').and.to.equal(true); - done(); - }); + toolkit.deleteUserSpace(userSpaceName, lib, (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.a('boolean').and.to.equal(true); + done(); }); }); }); }); describe('getSysValue', () => { - transports.forEach((transport) => { - it(`returns the value of system variable using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('returns the value of system variable', (done) => { + const connection = new Connection(config); - const toolkit = new Toolkit(connection); + const toolkit = new Toolkit(connection); - toolkit.getSysValue('QCENTURY', (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.a('string').and.to.equal('1'); - done(); - }); + toolkit.getSysValue('QCENTURY', (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.a('string').and.to.equal('1'); + done(); }); }); }); describe('getSysStatus', () => { - transports.forEach((transport) => { - it('returns basic system status information about the signed-on users ' - + `and batch jobs using ${transport.name} transport`, + it('returns basic system status information about the signed-on users ' + + 'and batch jobs', + (done) => { + const connection = new Connection(config); + const toolkit = new Toolkit(connection); + + toolkit.getSysStatus((error, output) => { + expect(error).to.equal(null); + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Current_date_and_time'); + expect(output).to.have.a.property('System_name'); + expect(output).to.have.a.property('Users_currently_signed_on'); + expect(output).to.have.a.property('Users_temporarily_signed_off_(disconnected)'); + expect(output).to.have.a.property('Users_suspended_by_system_request'); + expect(output).to.have.a.property('Users_suspended_by_group_jobs'); + expect(output).to.have.a.property('Users_signed_off_with_printer_output_waiting_to_print'); + expect(output).to.have.a.property('Batch_jobs_waiting_for_messages'); + expect(output).to.have.a.property('Batch_jobs_running'); + expect(output).to.have.a.property('Batch_jobs_held_while_running'); + expect(output).to.have.a.property('Batch_jobs_ending'); + expect(output).to.have.a.property('Batch_jobs_waiting_to_run_or_already_scheduled'); + expect(output).to.have.a.property('Batch_jobs_held_on_a_job_queue'); + expect(output).to.have.a.property('Batch_jobs_on_a_held_job_queue'); + expect(output).to.have.a.property('Batch_jobs_on_an_unassigned_job_queue'); + expect(output).to.have.a.property('Batch_jobs_ended_with_printer_output_waiting_to_print'); + done(); + }); + }); + }); + + describe('getSysStatusExt', () => { + it('returns more detailed system status info', (done) => { - const connection = transport.me; + const connection = new Connection(config); + const toolkit = new Toolkit(connection); - toolkit.getSysStatus((error, output) => { + toolkit.getSysStatusExt((error, output) => { expect(error).to.equal(null); expect(output).to.be.an('Object'); expect(output).to.have.a.property('Current_date_and_time'); expect(output).to.have.a.property('System_name'); - expect(output).to.have.a.property('Users_currently_signed_on'); - expect(output).to.have.a.property('Users_temporarily_signed_off_(disconnected)'); - expect(output).to.have.a.property('Users_suspended_by_system_request'); - expect(output).to.have.a.property('Users_suspended_by_group_jobs'); - expect(output).to.have.a.property('Users_signed_off_with_printer_output_waiting_to_print'); - expect(output).to.have.a.property('Batch_jobs_waiting_for_messages'); - expect(output).to.have.a.property('Batch_jobs_running'); - expect(output).to.have.a.property('Batch_jobs_held_while_running'); - expect(output).to.have.a.property('Batch_jobs_ending'); - expect(output).to.have.a.property('Batch_jobs_waiting_to_run_or_already_scheduled'); - expect(output).to.have.a.property('Batch_jobs_held_on_a_job_queue'); - expect(output).to.have.a.property('Batch_jobs_on_a_held_job_queue'); - expect(output).to.have.a.property('Batch_jobs_on_an_unassigned_job_queue'); - expect(output).to.have.a.property('Batch_jobs_ended_with_printer_output_waiting_to_print'); + expect(output).to.have.a.property('Elapsed_time'); + expect(output).to.have.a.property('Restricted_state_flag'); + expect(output).to.have.a.property('%_processing_unit_used'); + expect(output).to.have.a.property('Jobs_in_system'); + expect(output).to.have.a.property('%_permanent_addresses'); + expect(output).to.have.a.property('%_temporary_addresses'); + expect(output).to.have.a.property('System_ASP'); + expect(output).to.have.a.property('%_system_ASP_used'); + expect(output).to.have.a.property('Total_auxiliary_storage'); + expect(output).to.have.a.property('Current_unprotected_storage_used'); + expect(output).to.have.a.property('Maximum_unprotected_storage_used'); + expect(output).to.have.a.property('%_DB_capability'); + expect(output).to.have.a.property('Main_storage_size'); + expect(output).to.have.a.property('Number_of_partitions'); + expect(output).to.have.a.property('Partition_identifier'); + expect(output).to.have.a.property('Current_processing_capacity'); + expect(output).to.have.a.property('Processor_sharing_attribute'); + expect(output).to.have.a.property('Number_of_processors'); + expect(output).to.have.a.property('Active_jobs_in_system'); + expect(output).to.have.a.property('Active_threads_in_system'); + expect(output).to.have.a.property('Maximum_jobs_in_system'); + expect(output).to.have.a.property('%_temporary_256MB_segments_used'); + expect(output).to.have.a.property('%_temporary_4GB_segments_used'); + expect(output).to.have.a.property('%_permanent_256MB_segments_used'); + expect(output).to.have.a.property('%_permanent_4GB_segments_used'); + expect(output).to.have.a.property('%_current_interactive_performance'); + expect(output).to.have.a.property('%_uncapped_CPU_capacity_used'); + expect(output).to.have.a.property('%_shared_processor_pool_used'); + expect(output).to.have.a.property('Main_storage_size_(long)'); done(); }); }); - }); - }); - - describe('getSysStatusExt', () => { - transports.forEach((transport) => { - it(`returns more detailed system status info using ${transport.name} transport`, - (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.getSysStatusExt((error, output) => { - expect(error).to.equal(null); - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Current_date_and_time'); - expect(output).to.have.a.property('System_name'); - expect(output).to.have.a.property('Elapsed_time'); - expect(output).to.have.a.property('Restricted_state_flag'); - expect(output).to.have.a.property('%_processing_unit_used'); - expect(output).to.have.a.property('Jobs_in_system'); - expect(output).to.have.a.property('%_permanent_addresses'); - expect(output).to.have.a.property('%_temporary_addresses'); - expect(output).to.have.a.property('System_ASP'); - expect(output).to.have.a.property('%_system_ASP_used'); - expect(output).to.have.a.property('Total_auxiliary_storage'); - expect(output).to.have.a.property('Current_unprotected_storage_used'); - expect(output).to.have.a.property('Maximum_unprotected_storage_used'); - expect(output).to.have.a.property('%_DB_capability'); - expect(output).to.have.a.property('Main_storage_size'); - expect(output).to.have.a.property('Number_of_partitions'); - expect(output).to.have.a.property('Partition_identifier'); - expect(output).to.have.a.property('Current_processing_capacity'); - expect(output).to.have.a.property('Processor_sharing_attribute'); - expect(output).to.have.a.property('Number_of_processors'); - expect(output).to.have.a.property('Active_jobs_in_system'); - expect(output).to.have.a.property('Active_threads_in_system'); - expect(output).to.have.a.property('Maximum_jobs_in_system'); - expect(output).to.have.a.property('%_temporary_256MB_segments_used'); - expect(output).to.have.a.property('%_temporary_4GB_segments_used'); - expect(output).to.have.a.property('%_permanent_256MB_segments_used'); - expect(output).to.have.a.property('%_permanent_4GB_segments_used'); - expect(output).to.have.a.property('%_current_interactive_performance'); - expect(output).to.have.a.property('%_uncapped_CPU_capacity_used'); - expect(output).to.have.a.property('%_shared_processor_pool_used'); - expect(output).to.have.a.property('Main_storage_size_(long)'); - done(); - }); - }); - }); }); describe('getJobStatus', () => { - transports.forEach((transport) => { - it(`returns status of specified job using ${transport.name} transport`, - (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.getJobStatus('000000', (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Job_status'); - expect(output).to.have.a.property('Fully_qualified_job_name'); - done(); - }); - }); - }); - }); - - describe('getJobInfo', () => { - transports.forEach((transport) => { - it(`returns info on specfed job using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('returns status of specified job', + (done) => { + const connection = new Connection(config); const toolkit = new Toolkit(connection); - toolkit.getJobInfo('SCPF', 'QSYS', '000000', (error, output) => { + toolkit.getJobStatus('000000', (error, output) => { expect(error).to.equal(null); expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Job_name'); - expect(output).to.have.a.property('User_name'); - expect(output).to.have.a.property('Job_number'); expect(output).to.have.a.property('Job_status'); - expect(output).to.have.a.property('Job_type'); - expect(output).to.have.a.property('Job_subtype'); - expect(output).to.have.a.property('Subsystem_description_name'); - expect(output).to.have.a.property('Run_priority_(job)'); - expect(output).to.have.a.property('System_pool_identifier'); - expect(output).to.have.a.property('Processing_unit_time_used,_if_less_than_2,147,483,647_milliseconds'); - expect(output).to.have.a.property('Number_of_auxiliary_I/O_requests,_if_less_than_2,147,483,647'); - expect(output).to.have.a.property('Number_of_interactive_transactions'); - expect(output).to.have.a.property('Response_time_total'); - expect(output).to.have.a.property('Function_type'); - expect(output).to.have.a.property('Function_name'); - expect(output).to.have.a.property('Active_job_status'); - expect(output).to.have.a.property('Number_of_database_lock_waits'); - expect(output).to.have.a.property('Number_of_internal_machine_lock_waits'); - expect(output).to.have.a.property('Number_of_nondatabase_lock_waits'); - expect(output).to.have.a.property('Time_spent_on_database_lock_waits'); - expect(output).to.have.a.property('Time_spent_on_internal_machine_lock_waits'); - expect(output).to.have.a.property('Time_spent_on_nondatabase_lock_waits'); - expect(output).to.have.a.property('Current_system_pool_identifier'); - expect(output).to.have.a.property('Thread_count'); - expect(output).to.have.a.property('Processing_unit_time_used_-_total_for_the_job'); - expect(output).to.have.a.property('Number_of_auxiliary_I/O_requests'); - expect(output).to.have.a.property('Processing_unit_time_used_for_database_-_total_for_the_job'); - expect(output).to.have.a.property('Page_faults'); - expect(output).to.have.a.property('Active_job_status_for_jobs_ending'); - expect(output).to.have.a.property('Memory_pool_name'); - expect(output).to.have.a.property('Message_reply'); - expect(output).to.have.a.property('Message_key,_when_active_job_waiting_for_a_message'); - expect(output).to.have.a.property('Message_queue_name,_when_active_job_waiting_for_a_message'); - expect(output).to.have.a.property('Message_queue_library_name,_when_active_job_waiting_for_a_message'); - expect(output).to.have.a.property('Message_queue_library_ASP_device_name,_when_active_job_waiting_for_a_message'); + expect(output).to.have.a.property('Fully_qualified_job_name'); done(); }); }); + }); + + describe('getJobInfo', () => { + it('returns info on specfed job', (done) => { + const connection = new Connection(config); + + const toolkit = new Toolkit(connection); + + toolkit.getJobInfo('SCPF', 'QSYS', '000000', (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Job_name'); + expect(output).to.have.a.property('User_name'); + expect(output).to.have.a.property('Job_number'); + expect(output).to.have.a.property('Job_status'); + expect(output).to.have.a.property('Job_type'); + expect(output).to.have.a.property('Job_subtype'); + expect(output).to.have.a.property('Subsystem_description_name'); + expect(output).to.have.a.property('Run_priority_(job)'); + expect(output).to.have.a.property('System_pool_identifier'); + expect(output).to.have.a.property('Processing_unit_time_used,_if_less_than_2,147,483,647_milliseconds'); + expect(output).to.have.a.property('Number_of_auxiliary_I/O_requests,_if_less_than_2,147,483,647'); + expect(output).to.have.a.property('Number_of_interactive_transactions'); + expect(output).to.have.a.property('Response_time_total'); + expect(output).to.have.a.property('Function_type'); + expect(output).to.have.a.property('Function_name'); + expect(output).to.have.a.property('Active_job_status'); + expect(output).to.have.a.property('Number_of_database_lock_waits'); + expect(output).to.have.a.property('Number_of_internal_machine_lock_waits'); + expect(output).to.have.a.property('Number_of_nondatabase_lock_waits'); + expect(output).to.have.a.property('Time_spent_on_database_lock_waits'); + expect(output).to.have.a.property('Time_spent_on_internal_machine_lock_waits'); + expect(output).to.have.a.property('Time_spent_on_nondatabase_lock_waits'); + expect(output).to.have.a.property('Current_system_pool_identifier'); + expect(output).to.have.a.property('Thread_count'); + expect(output).to.have.a.property('Processing_unit_time_used_-_total_for_the_job'); + expect(output).to.have.a.property('Number_of_auxiliary_I/O_requests'); + expect(output).to.have.a.property('Processing_unit_time_used_for_database_-_total_for_the_job'); + expect(output).to.have.a.property('Page_faults'); + expect(output).to.have.a.property('Active_job_status_for_jobs_ending'); + expect(output).to.have.a.property('Memory_pool_name'); + expect(output).to.have.a.property('Message_reply'); + expect(output).to.have.a.property('Message_key,_when_active_job_waiting_for_a_message'); + expect(output).to.have.a.property('Message_queue_name,_when_active_job_waiting_for_a_message'); + expect(output).to.have.a.property('Message_queue_library_name,_when_active_job_waiting_for_a_message'); + expect(output).to.have.a.property('Message_queue_library_ASP_device_name,_when_active_job_waiting_for_a_message'); + done(); + }); }); }); describe('getDataArea', () => { - before('init lib, data area, and add data', async () => { - // eslint-disable-next-line global-require - const { DBPool } = require('idb-pconnector'); - const pool = new DBPool({ url: '*LOCAL' }, { incrementSize: 2 }); - - const qcmdexec = 'CALL QSYS2.QCMDEXC(?)'; - const dataArea = 'TESTDA'; - - const createLib = `CRTLIB LIB(${lib}) TYPE(*TEST) TEXT('Used to test' Node.js toolkit')`; - - const createDataArea = `CRTDTAARA DTAARA(${lib}/${dataArea}) TYPE(*CHAR) ` - + 'TEXT(\'TEST DATA AREA FOR NODE TOOLKIT\') ' - + 'VALUE(\'Hello From Test Data Area!\')'; - - const findLib = 'SELECT SCHEMA_NAME FROM qsys2.sysschemas WHERE SCHEMA_NAME = \'NODETKTEST\''; - - const findDataArea = `SELECT OBJNAME FROM TABLE (QSYS2.OBJECT_STATISTICS('${lib}', '*DTAARA')) AS X`; - - const libResult = await pool.runSql(findLib); - - const dataAreaResult = await pool.runSql(findDataArea); - - if (!libResult.length) { - await pool.prepareExecute(qcmdexec, [createLib]).catch((error) => { - // eslint-disable-next-line no-console - console.log('Unable to Create Lib!'); - throw error; - }); - // eslint-disable-next-line no-console - console.log('CREATED LIB!'); - } - if (!dataAreaResult.length) { - await pool.prepareExecute(qcmdexec, [createDataArea]).catch((error) => { - // eslint-disable-next-line no-console - console.log('Unable to Create DA!'); - throw error; - }); - // eslint-disable-next-line no-console - console.log('CREATED DA!'); - } + before('check if data area exists for tests', (done) => { + checkObjectExists(config, '*DTAARA', (error) => { + if (error) { throw error; } + done(); + }); }); - transports.forEach((transport) => { - it(`returns contents of a data area using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const toolkit = new Toolkit(connection); - - toolkit.getDataArea('NODETKTEST', 'TESTDA', 20, (error, output) => { - expect(error).to.equal(null); - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Type_of_value_returned'); - expect(output).to.have.a.property('Library_name'); - expect(output).to.have.a.property('Length_of_value_returned'); - expect(output).to.have.a.property('Number_of_decimal_positions'); - expect(output).to.have.a.property('Value'); - done(); - }); + it('returns contents of a data area', (done) => { + const connection = new Connection(config); + + const toolkit = new Toolkit(connection); + + toolkit.getDataArea('NODETKTEST', 'TESTDA', 20, (error, output) => { + expect(error).to.equal(null); + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Type_of_value_returned'); + expect(output).to.have.a.property('Library_name'); + expect(output).to.have.a.property('Length_of_value_returned'); + expect(output).to.have.a.property('Number_of_decimal_positions'); + expect(output).to.have.a.property('Value'); + done(); }); }); }); diff --git a/test/functional/checkObjectExists.js b/test/functional/checkObjectExists.js new file mode 100644 index 00000000..6ad9b329 --- /dev/null +++ b/test/functional/checkObjectExists.js @@ -0,0 +1,177 @@ +const lib = 'NODETKTEST'; +const createLib = `CRTLIB LIB(${lib}) TYPE(*TEST) TEXT('Used to test Node.js toolkit')`; +const findLib = `SELECT SCHEMA_NAME FROM qsys2.sysschemas WHERE SCHEMA_NAME = '${lib}'`; +const dataQueue = 'TESTQ'; +const dataArea = 'TESTDA'; + +function checkObjectExistsSSH(config, object = {}, callback) { + /* eslint-disable global-require */ + const { Client } = require('ssh2'); + + const client = new Client(); + const checkLibCommand = `system 'CHKOBJ OBJ(QSYS/${lib}) OBJTYPE(*LIB)'`; + const checkObjectCommand = `system 'CHKOBJ OBJ(${lib}/${object.name}) OBJTYPE(${object.type})'`; + + // if client.connect has an error it will be handled here + client.on('error', (error) => { + callback(error, false); + }); + + client.on('ready', () => { + client.exec(checkLibCommand, (checkLibError, checkLibStream) => { + /* eslint-disable no-console */ + console.log(`executing ${checkLibCommand}`); + if (checkLibError) { + callback(checkLibError, false); + return; + } + checkLibStream.stderr.on('data', (data) => { + console.log(`STDERR: ${data}`); + }); + checkLibStream.on('exit', (checkLibCode) => { + if (checkLibCode !== 0) { + if (config.verbose) { console.log(`Command exited abnormally with code: ${checkLibCode}`); } + const libError = new Error(`${lib} lib was not found!\nCreate it by running: ${createLib}`); + client.end(); + callback(libError, false); + return; + } + client.exec(checkObjectCommand, (checkObjectError, checkObjectStream) => { + if (config.verbose) { console.log(`executing ${checkObjectCommand}`); } + if (checkObjectError) { + client.end(); + callback(checkLibError, false); + return; + } + checkObjectStream.stderr.on('data', (data) => { + console.log(`STDERR: ${data}`); + }); + checkObjectStream.on('exit', (checkObjectCode) => { + if (checkObjectCode !== 0) { + client.end(); + console.log(`Command exited abnormally with code: ${checkObjectCode}`); + const objectError = new Error(`${object.name} was not found!\nCreate it by running: ${object.createObject}`); + callback(objectError); + return; + } + client.end(); + callback(null, true); + }); + }); + }); + }); + }); + + client.connect(config); +} + +function checkObjectExistsODBC(config, object = {}, callback) { + const odbc = require('odbc'); + + const connectionString = config.dsn || `DRIVER=IBM i Access ODBC Driver;SYSTEM=${config.host};UID=${config.username};PWD=${config.password};`; + + odbc.connect(connectionString, (connectError, connection) => { + if (connectError) { + callback(connectError, false); + return; + } + connection.query(findLib, (findLibError, libResult) => { + if (findLibError) { + callback(findLibError, false); + return; + } + if (config.verbose) { + console.log('find lib result set: ', libResult); + } + if (!libResult.length) { + const libError = new Error(`${lib} lib was not found!\nCreate it by running:${createLib}`); + callback(libError, false); + return; + } + connection.query(object.findObject, (findObjectError, result) => { + if (findObjectError) { + callback(findObjectError, false); + return; + } + if (config.verbose) { + console.log('find lib result set: ', result); + } + if (!result.length) { + const resultError = new Error(`${object.name} was not found! Create it by running: ${object.createObject}`); + callback(resultError, false); + return; + } + callback(null, true); + }); + }); + }); +} + +function checkObjectExistsIDB(config, object = {}, callback) { + const { dbconn, dbstmt } = require('idb-connector'); + + /* eslint-disable new-cap */ + const connection = new dbconn(); + connection.conn('*LOCAL'); + const statement = new dbstmt(connection); + + statement.exec(findLib, (libResult, error) => { + if (error) { + callback(error, null); + return; + } + if (config.verbose) { + console.log('find lib result set: ', libResult); + } + if (!libResult.length) { + const libError = new Error(`${lib} lib was not found! Create it by running: ${createLib}`); + callback(libError, null); + return; + } + statement.closeCursor(); + statement.exec(object.findObject, (result, findObjecError) => { + if (findObjecError) { + callback(findObjecError, null); + return; + } + if (config.verbose) { + console.log('find object result set: ', result); + } + if (!result.length) { + const resultError = new Error(`${object.name} was not found! Create it by running: ${object.createObject}`); + callback(resultError, null); + return; + } + statement.close(); + connection.disconn(); + connection.close(); + callback(null, true); + }); + }); +} + +function checkObjectExists(config, type, callback) { + const object = { type }; + + if (type === '*DTAARA') { + object.name = dataArea; + object.createObject = `CRTDTAARA DTAARA(${lib}/${dataArea}) TYPE(*CHAR) TEXT('TEST DATA AREA FOR NODE TOOLKIT') VALUE('Hello From Test Data Area!')`; + } else if (type === '*DTAQ') { + object.name = dataQueue; + object.createObject = `CRTDTAQ DTAQ(${lib}/${dataQueue}) MAXLEN(100) AUT(*EXCLUDE) TEXT('TEST DQ FOR NODE TOOLKIT TESTS')`; + } + + object.findObject = `SELECT OBJNAME FROM TABLE (QSYS2.OBJECT_STATISTICS('${lib}', '${type}')) AS X WHERE OBJNAME = '${object.name}'`; + // eslint-disable-next-line no-param-reassign + config.transportOptions.verbose = config.verbose; + + if (config.transport === 'idb') { + checkObjectExistsIDB(config.transportOptions, object, callback); + } else if (config.transport === 'odbc') { + checkObjectExistsODBC(config.transportOptions, object, callback); + } else if (config.transport === 'ssh') { + checkObjectExistsSSH(config.transportOptions, object, callback); + } +} + +module.exports.checkObjectExists = checkObjectExists; diff --git a/test/functional/config.js b/test/functional/config.js new file mode 100644 index 00000000..1db87625 --- /dev/null +++ b/test/functional/config.js @@ -0,0 +1,34 @@ +const { readFileSync } = require('fs'); + +let privateKey; +if (process.env.TKPK) { + privateKey = readFileSync(process.env.TKPK, 'utf-8'); +} + +const config = { + transport: process.env.TKTRANSPORT || 'ssh', + verbose: !!process.env.TKVERBOSE, + transportOptions: { + database: process.env.TKDB || '*LOCAL', + username: process.env.TKUSER || '', + password: process.env.TKPASS || '', + host: process.env.TKHOST || 'localhost', + port: process.env.TKPORT, + path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', + privateKey, + // passphrase is used by the ssh transport to decrypt the private key + passphrase: process.env.TKPHRASE, + dsn: process.env.TKDSN, + }, +}; + +function printConfig() { +/* eslint-disable no-console */ + console.log('-----------------------'); + console.log('transport:', config.transport); + console.log(`verbose: ${config.verbose ? 'on' : 'off'}`); + console.log('-----------------------'); +} + +module.exports.config = config; +module.exports.printConfig = printConfig; diff --git a/test/functional/deprecated/commandsFunctional.js b/test/functional/deprecated/commandsFunctional.js index 7cb881f3..bd01b477 100644 --- a/test/functional/deprecated/commandsFunctional.js +++ b/test/functional/deprecated/commandsFunctional.js @@ -16,76 +16,80 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* eslint-env mocha */ +/* eslint-disable new-cap */ + const { expect } = require('chai'); const { parseString } = require('xml2js'); const { - iCmd, iSh, iQsh, + iCmd, iSh, iQsh, iConn, } = require('../../../lib/itoolkit'); -const { returnTransportsDeprecated } = require('../../../lib/utils'); +const { config, printConfig } = require('../config'); -// Set Env variables or set values here. -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT || 80, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', -}; +// deprecated tests are in place to test compatability using deprecated classes and functions +// these tests use deprecated iConn Class to create a connnection +// iConn only supported idb and rest transports +if (config.transport !== 'idb' && config.transport !== 'rest') { + throw new Error('Only idb and rest transports are available for deprecated tests'); +} +const { database, username, password } = config.transportOptions; -const transports = returnTransportsDeprecated(opt); +let restOptions = null; +if (config.transport === 'rest') { + restOptions = { + hodt: config.host, + port: config.port || 80, + path: config.path, + }; +} describe('iSh, iCmd, iQsh, Functional Tests', () => { + before(() => { + printConfig(); + }); + describe('iCmd()', () => { - transports.forEach((transport) => { - it(`calls CL command using ${transport.name} transport`, (done) => { - const connection = transport.me; - connection.add(iCmd('RTVJOBA USRLIBL(?) SYSLIBL(?)')); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.cmd[0].success[0]).to.include('+++ success RTVJOBA USRLIBL(?) SYSLIBL(?)'); - done(); - }); + it('calls CL command', (done) => { + const connection = new iConn(database, username, password, restOptions); + connection.add(iCmd('RTVJOBA USRLIBL(?) SYSLIBL(?)')); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.cmd[0].success[0]).to.include('+++ success RTVJOBA USRLIBL(?) SYSLIBL(?)'); + done(); }); }); }); }); describe('iSh()', () => { - transports.forEach((transport) => { - it(`calls PASE shell command using ${transport.name} transport`, (done) => { - const connection = transport.me; - - connection.add(iSh('system -i wrksyssts')); - connection.run((xmlOut) => { - // xs does not return success property for sh or qsh command calls - // but on error sh or qsh node will not have any inner data - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sh[0]._).to.match(/(System\sStatus\sInformation)/); - done(); - }); + it('calls PASE shell command', (done) => { + const connection = new iConn(database, username, password, restOptions); + connection.add(iSh('system -i wrksyssts')); + connection.run((xmlOut) => { + // xs does not return success property for sh or qsh command calls + // but on error sh or qsh node will not have any inner data + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sh[0]._).to.match(/(System\sStatus\sInformation)/); + done(); }); }); }); }); describe('iQsh()', () => { - transports.forEach((transport) => { - it(`calls QSH command using ${transport.name} transport`, (done) => { - const connection = transport.me; - connection.add(iQsh('system wrksyssts')); - connection.run((xmlOut) => { - // xs does not return success property for sh or qsh command calls - // but on error sh or qsh node will not have any inner data - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.qsh[0]._).to.match(/(System\sStatus\sInformation)/); - done(); - }); + it('calls QSH command', (done) => { + const connection = new iConn(database, username, password, restOptions); + connection.add(iQsh('system wrksyssts')); + connection.run((xmlOut) => { + // xs does not return success property for sh or qsh command calls + // but on error sh or qsh node will not have any inner data + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.qsh[0]._).to.match(/(System\sStatus\sInformation)/); + done(); }); }); }); diff --git a/test/functional/deprecated/iDataQueueFunctional.js b/test/functional/deprecated/iDataQueueFunctional.js index bbe464ba..8d138a08 100644 --- a/test/functional/deprecated/iDataQueueFunctional.js +++ b/test/functional/deprecated/iDataQueueFunctional.js @@ -20,66 +20,42 @@ const { expect } = require('chai'); const { iConn, iDataQueue } = require('../../../lib/itoolkit'); +const { config, printConfig } = require('../config'); +const { checkObjectExists } = require('../checkObjectExists'); -// Set Env variables or set values here. -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT || 80, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', -}; +// deprecated tests are in place to test compatability using deprecated classes and functions +// these tests use deprecated iConn Class to create a connnection. +// iConn only supported idb and rest transports +if (config.transport !== 'idb' && config.transport !== 'rest') { + throw new Error('Only idb and rest transports are available for deprecated tests'); +} -const lib = 'NODETKTEST'; const dqName = 'TESTQ'; - -const { returnTransportsDeprecated } = require('../../../lib/utils'); - -const transports = returnTransportsDeprecated(opt); - -describe('iDataQueue Functional Tests', () => { - before('setup library for tests and create DQ', async () => { - // eslint-disable-next-line global-require - const { DBPool } = require('idb-pconnector'); - - const pool = new DBPool({ url: '*LOCAL' }, { incrementSize: 2 }); - - const qcmdexec = 'CALL QSYS2.QCMDEXC(?)'; - - const createLib = `CRTLIB LIB(${lib}) TYPE(*TEST) TEXT('Used to test Node.js toolkit')`; - - const createDQ = `CRTDTAQ DTAQ(${lib}/${dqName}) MAXLEN(100) AUT(*EXCLUDE) TEXT('TEST DQ FOR NODE TOOLKIT TESTS')`; - - const findLib = 'SELECT SCHEMA_NAME FROM qsys2.sysschemas WHERE SCHEMA_NAME = \'NODETKTEST\''; +const { database, username, password } = config.transportOptions; - const findDQ = 'SELECT OBJLONGNAME FROM TABLE (QSYS2.OBJECT_STATISTICS(\'NODETKTEST\', \'*DTAQ\')) AS X'; +let restOptions = null; - const libResult = await pool.runSql(findLib); +if (config.transport === 'rest') { + restOptions = { + hodt: config.host, + port: config.port || 80, + path: config.path, + }; +} - const dqResult = await pool.runSql(findDQ); +const lib = 'NODETKTEST'; const dqName = 'TESTQ'; - if (!libResult.length) { - await pool.prepareExecute(qcmdexec, [createLib]).catch((error) => { - // eslint-disable-next-line no-console - console.log('Unable to Create Lib!'); - throw error; - }); - // eslint-disable-next-line no-console - console.log('CREATED LIB!'); - } - if (!dqResult.length) { - await pool.prepareExecute(qcmdexec, [createDQ]).catch((error) => { - // eslint-disable-next-line no-console - console.log('Unable to Create DQ!'); - throw error; - }); - // eslint-disable-next-line no-console - console.log('CREATED DQ!'); - } +describe('iDataQueue Functional Tests', () => { + before('check if data queue exists for tests', (done) => { + printConfig(); + checkObjectExists(config, '*DTAQ', (error) => { + if (error) { throw error; } + done(); + }); }); + describe('constructor', () => { it('creates and returns an instance of iDataQueue', () => { - const connection = new iConn(opt.database, opt.user, opt.password); + const connection = new iConn(database, config.user, password); const dq = new iDataQueue(connection); expect(dq).to.be.instanceOf(iDataQueue); @@ -87,46 +63,40 @@ describe('iDataQueue Functional Tests', () => { }); describe('sendToDataQueue', () => { - transports.forEach((transport) => { - it(`sends data to specified DQ using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('sends data to specified DQ', (done) => { + const connection = new iConn(database, username, password, restOptions); - const dq = new iDataQueue(connection); + const dq = new iDataQueue(connection); - dq.sendToDataQueue(dqName, lib, 'Hello from DQ!', (output) => { - expect(output).to.equal(true); - done(); - }); + dq.sendToDataQueue(dqName, lib, 'Hello from DQ!', (output) => { + expect(output).to.equal(true); + done(); }); }); }); describe('receiveFromDataQueue', () => { - transports.forEach((transport) => { - it(`receives data from specfied DQ using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('receives data from specfied DQ', (done) => { + const connection = new iConn(database, username, password, restOptions); - const dq = new iDataQueue(connection); + const dq = new iDataQueue(connection); - dq.receiveFromDataQueue(dqName, lib, 100, (output) => { - expect(output).to.be.a('string').and.to.equal('Hello from DQ!'); - done(); - }); + dq.receiveFromDataQueue(dqName, lib, 100, (output) => { + expect(output).to.be.a('string').and.to.equal('Hello from DQ!'); + done(); }); }); }); describe('clearDataQueue', () => { - transports.forEach((transport) => { - it(`clears the specifed DQ using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('clears the specifed DQ', (done) => { + const connection = new iConn(database, username, password, restOptions); - const dq = new iDataQueue(connection); + const dq = new iDataQueue(connection); - dq.clearDataQueue(dqName, lib, (output) => { - expect(output).to.equal(true); - done(); - }); + dq.clearDataQueue(dqName, lib, (output) => { + expect(output).to.equal(true); + done(); }); }); }); diff --git a/test/functional/deprecated/iNetworkFunctional.js b/test/functional/deprecated/iNetworkFunctional.js index e411b942..2c96f3f3 100644 --- a/test/functional/deprecated/iNetworkFunctional.js +++ b/test/functional/deprecated/iNetworkFunctional.js @@ -20,25 +20,35 @@ const { expect } = require('chai'); const { iConn, iNetwork } = require('../../../lib/itoolkit'); +const { config, printConfig } = require('../config'); -// Set Env variables or set values here. -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT || 80, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', -}; +// deprecated tests are in place to test compatability using deprecated classes and functions +// these tests use deprecated iConn Class to create a connnection +// iConn only supported idb and rest transports +if (config.transport !== 'idb' && config.transport !== 'rest') { + throw new Error('Only idb and rest transports are available for deprecated tests'); +} -const { returnTransportsDeprecated } = require('../../../lib/utils'); +const { database, username, password } = config.transportOptions; -const transports = returnTransportsDeprecated(opt); +let restOptions = null; + +if (config.transport === 'rest') { + restOptions = { + hodt: config.host, + port: config.port || 80, + path: config.path, + }; +} describe('iNetwork Functional Tests', () => { + before(() => { + printConfig(); + }); + describe('constructor', () => { it('creates and returns an instance of iNetwork', () => { - const connection = new iConn(opt.database, opt.user, opt.password); + const connection = new iConn(database, config.user, password); const net = new iNetwork(connection); @@ -47,107 +57,103 @@ describe('iNetwork Functional Tests', () => { }); describe('getTCPIPAttr', () => { - transports.forEach((transport) => { - it(`retrieves TCP/IP Attributes using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const net = new iNetwork(connection); - - net.getTCPIPAttr((output) => { - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('TCP/IPv4_stack_status'); - expect(output).to.have.a.property('How_long_active'); - expect(output).to.have.a.property('When_last_started_-_date'); - expect(output).to.have.a.property('When_last_started_-_time'); - expect(output).to.have.a.property('When_last_ended_-_date'); - expect(output).to.have.a.property('When_last_ended_-_time'); - expect(output).to.have.a.property('Who_last_started_-_job_name'); - expect(output).to.have.a.property('Who_last_started_-_job_user_name'); - expect(output).to.have.a.property('Who_last_started_-_job_number'); - expect(output).to.have.a.property('Who_last_started_-_internal_job_identifier'); - expect(output).to.have.a.property('Who_last_ended_-_job_name'); - expect(output).to.have.a.property('Who_last_ended_-_job_user_name'); - expect(output).to.have.a.property('Who_last_ended_-_job_number'); - expect(output).to.have.a.property('Who_last_ended_-_internal_job_identifier'); - expect(output).to.have.a.property('Offset_to_additional_information'); - expect(output).to.have.a.property('Length_of_additional_information'); - expect(output).to.have.a.property('Limited_mode'); - expect(output).to.have.a.property('Offset_to_list_of_Internet_addresses'); - expect(output).to.have.a.property('Number_of_Internet_addresses'); - expect(output).to.have.a.property('Entry_length_for_list_of_Internet_addresses'); - expect(output).to.have.a.property('DNS_protocol'); - expect(output).to.have.a.property('Retries'); - expect(output).to.have.a.property('Time_interval'); - expect(output).to.have.a.property('Search_order'); - expect(output).to.have.a.property('Initial_domain_name_server'); - expect(output).to.have.a.property('DNS_listening_port'); - expect(output).to.have.a.property('Host_name'); - expect(output).to.have.a.property('Domain_name'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Domain_search_list'); - done(); - }); + it('retrieves TCP/IP Attributes', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const net = new iNetwork(connection); + + net.getTCPIPAttr((output) => { + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('TCP/IPv4_stack_status'); + expect(output).to.have.a.property('How_long_active'); + expect(output).to.have.a.property('When_last_started_-_date'); + expect(output).to.have.a.property('When_last_started_-_time'); + expect(output).to.have.a.property('When_last_ended_-_date'); + expect(output).to.have.a.property('When_last_ended_-_time'); + expect(output).to.have.a.property('Who_last_started_-_job_name'); + expect(output).to.have.a.property('Who_last_started_-_job_user_name'); + expect(output).to.have.a.property('Who_last_started_-_job_number'); + expect(output).to.have.a.property('Who_last_started_-_internal_job_identifier'); + expect(output).to.have.a.property('Who_last_ended_-_job_name'); + expect(output).to.have.a.property('Who_last_ended_-_job_user_name'); + expect(output).to.have.a.property('Who_last_ended_-_job_number'); + expect(output).to.have.a.property('Who_last_ended_-_internal_job_identifier'); + expect(output).to.have.a.property('Offset_to_additional_information'); + expect(output).to.have.a.property('Length_of_additional_information'); + expect(output).to.have.a.property('Limited_mode'); + expect(output).to.have.a.property('Offset_to_list_of_Internet_addresses'); + expect(output).to.have.a.property('Number_of_Internet_addresses'); + expect(output).to.have.a.property('Entry_length_for_list_of_Internet_addresses'); + expect(output).to.have.a.property('DNS_protocol'); + expect(output).to.have.a.property('Retries'); + expect(output).to.have.a.property('Time_interval'); + expect(output).to.have.a.property('Search_order'); + expect(output).to.have.a.property('Initial_domain_name_server'); + expect(output).to.have.a.property('DNS_listening_port'); + expect(output).to.have.a.property('Host_name'); + expect(output).to.have.a.property('Domain_name'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Domain_search_list'); + done(); }); }); }); describe('getNetInterfaceData', () => { - transports.forEach((transport) => { - it(`retrieves IPv4 network interface info using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const net = new iNetwork(connection); - - net.getNetInterfaceData('127.0.0.1', (output) => { - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Internet_address'); - expect(output).to.have.a.property('Internet_address_binary'); - expect(output).to.have.a.property('Network_address'); - expect(output).to.have.a.property('Network_address_binary'); - expect(output).to.have.a.property('Line_description'); - expect(output).to.have.a.property('Interface_status'); - expect(output).to.have.a.property('Interface_type_of_service'); - expect(output).to.have.a.property('Interface_MTU'); - expect(output).to.have.a.property('Interface_line_type'); - expect(output).to.have.a.property('Host_address'); - expect(output).to.have.a.property('Host_address_binary'); - expect(output).to.have.a.property('Interface_subnet_mask'); - expect(output).to.have.a.property('Interface_subnet_mask_binary'); - expect(output).to.have.a.property('Directed_broadcast_address'); - expect(output).to.have.a.property('Directed_broadcast_address_binary'); - expect(output).to.have.a.property('Change_date'); - expect(output).to.have.a.property('Change_time'); - expect(output).to.have.a.property('Associated_local_interface'); - expect(output).to.have.a.property('Associated_local_interface_binary'); - expect(output).to.have.a.property('Packet_rules'); - expect(output).to.have.a.property('Change_status'); - expect(output).to.have.a.property('Automatic_start'); - expect(output).to.have.a.property('TRLAN_bit_sequencing'); - expect(output).to.have.a.property('Interface_type'); - expect(output).to.have.a.property('Proxy_ARP_allowed'); - expect(output).to.have.a.property('Proxy_ARP_enabled'); - expect(output).to.have.a.property('Configured_MTU'); - expect(output).to.have.a.property('Network_name'); - expect(output).to.have.a.property('Interface_name'); - expect(output).to.have.a.property('Alias_name'); - expect(output).to.have.a.property('Interface_description'); - expect(output).to.have.a.property('Offset_to_preferred_interface_list'); - expect(output).to.have.a.property('Number_of_entries_in_preferred_interface_list'); - expect(output).to.have.a.property('Length_of_one_preferred_interface_list_entry'); - expect(output).to.have.a.property('DHCP_created'); - expect(output).to.have.a.property('DHCP_dynamic_DNS_updates'); - expect(output).to.have.a.property('DHCP_lease_expiration'); - expect(output).to.have.a.property('DHCP_lease_expiration_-_date'); - expect(output).to.have.a.property('DHCP_lease_expiration_-_time'); - expect(output).to.have.a.property('DHCP_lease_obtained'); - expect(output).to.have.a.property('DHCP_lease_obtained_-_date'); - expect(output).to.have.a.property('DHCP_lease_obtained_-_time'); - expect(output).to.have.a.property('Use_DHCP_unique_identifier'); - expect(output).to.have.a.property('DHCP_server_IP_address'); - expect(output).to.have.a.property('Preferred_interface_Internet_address'); - expect(output).to.have.a.property('Preferred_interface_Internet_address_binary'); - done(); - }); + it('retrieves IPv4 network interface info', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const net = new iNetwork(connection); + + net.getNetInterfaceData('127.0.0.1', (output) => { + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Internet_address'); + expect(output).to.have.a.property('Internet_address_binary'); + expect(output).to.have.a.property('Network_address'); + expect(output).to.have.a.property('Network_address_binary'); + expect(output).to.have.a.property('Line_description'); + expect(output).to.have.a.property('Interface_status'); + expect(output).to.have.a.property('Interface_type_of_service'); + expect(output).to.have.a.property('Interface_MTU'); + expect(output).to.have.a.property('Interface_line_type'); + expect(output).to.have.a.property('Host_address'); + expect(output).to.have.a.property('Host_address_binary'); + expect(output).to.have.a.property('Interface_subnet_mask'); + expect(output).to.have.a.property('Interface_subnet_mask_binary'); + expect(output).to.have.a.property('Directed_broadcast_address'); + expect(output).to.have.a.property('Directed_broadcast_address_binary'); + expect(output).to.have.a.property('Change_date'); + expect(output).to.have.a.property('Change_time'); + expect(output).to.have.a.property('Associated_local_interface'); + expect(output).to.have.a.property('Associated_local_interface_binary'); + expect(output).to.have.a.property('Packet_rules'); + expect(output).to.have.a.property('Change_status'); + expect(output).to.have.a.property('Automatic_start'); + expect(output).to.have.a.property('TRLAN_bit_sequencing'); + expect(output).to.have.a.property('Interface_type'); + expect(output).to.have.a.property('Proxy_ARP_allowed'); + expect(output).to.have.a.property('Proxy_ARP_enabled'); + expect(output).to.have.a.property('Configured_MTU'); + expect(output).to.have.a.property('Network_name'); + expect(output).to.have.a.property('Interface_name'); + expect(output).to.have.a.property('Alias_name'); + expect(output).to.have.a.property('Interface_description'); + expect(output).to.have.a.property('Offset_to_preferred_interface_list'); + expect(output).to.have.a.property('Number_of_entries_in_preferred_interface_list'); + expect(output).to.have.a.property('Length_of_one_preferred_interface_list_entry'); + expect(output).to.have.a.property('DHCP_created'); + expect(output).to.have.a.property('DHCP_dynamic_DNS_updates'); + expect(output).to.have.a.property('DHCP_lease_expiration'); + expect(output).to.have.a.property('DHCP_lease_expiration_-_date'); + expect(output).to.have.a.property('DHCP_lease_expiration_-_time'); + expect(output).to.have.a.property('DHCP_lease_obtained'); + expect(output).to.have.a.property('DHCP_lease_obtained_-_date'); + expect(output).to.have.a.property('DHCP_lease_obtained_-_time'); + expect(output).to.have.a.property('Use_DHCP_unique_identifier'); + expect(output).to.have.a.property('DHCP_server_IP_address'); + expect(output).to.have.a.property('Preferred_interface_Internet_address'); + expect(output).to.have.a.property('Preferred_interface_Internet_address_binary'); + done(); }); }); }); diff --git a/test/functional/deprecated/iObjFunctional.js b/test/functional/deprecated/iObjFunctional.js index 601b9971..ef184b98 100644 --- a/test/functional/deprecated/iObjFunctional.js +++ b/test/functional/deprecated/iObjFunctional.js @@ -20,25 +20,35 @@ const { expect } = require('chai'); const { iConn, iObj } = require('../../../lib/itoolkit'); +const { config, printConfig } = require('../config'); -// Set Env variables or set values here. -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT || 80, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', -}; +// deprecated tests are in place to test compatability using deprecated classes and functions +// these tests use deprecated iConn Class to create a connnection +// iConn only supported idb and rest transports +if (config.transport !== 'idb' && config.transport !== 'rest') { + throw new Error('Only idb and rest transports are available for deprecated tests'); +} -const { returnTransportsDeprecated } = require('../../../lib/utils'); +const { database, username, password } = config.transportOptions; -const transports = returnTransportsDeprecated(opt); +let restOptions = null; + +if (config.transport === 'rest') { + restOptions = { + hodt: config.host, + port: config.port || 80, + path: config.path, + }; +} describe('iObj Functional Tests', () => { + before(() => { + printConfig(); + }); + describe('constructor', () => { it('creates and returns an instance of iObj', () => { - const connection = new iConn(opt.database, opt.user, opt.password); + const connection = new iConn(database, config.user, password); const obj = new iObj(connection); @@ -47,318 +57,304 @@ describe('iObj Functional Tests', () => { }); describe('retrUsrAuth', () => { - transports.forEach((transport) => { - it(`returns uses's authority for an object using ${transport.name} tranport`, (done) => { - const connection = transport.me; - - const obj = new iObj(connection); - - obj.retrUsrAuth('*PUBLIC', '*PGM', 'XMLCGI', 'QXMLSERV', (output) => { - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Object_authority_/_Data_authority'); - expect(output).to.have.a.property('Authorization_list_management'); - expect(output).to.have.a.property('Object_operational'); - expect(output).to.have.a.property('Object_management'); - expect(output).to.have.a.property('Object_existence'); - expect(output).to.have.a.property('Data_read'); - expect(output).to.have.a.property('Data_add'); - expect(output).to.have.a.property('Data_update'); - expect(output).to.have.a.property('Data_delete'); - expect(output).to.have.a.property('Authorization_list'); - expect(output).to.have.a.property('Authority_source'); - expect(output).to.have.a.property('Some_adopted_authority'); - expect(output).to.have.a.property('Adopted_object_authority'); - expect(output).to.have.a.property('Adopted_authorization_list_management'); - expect(output).to.have.a.property('Adopted_object_operational'); - expect(output).to.have.a.property('Adopted_object_management'); - expect(output).to.have.a.property('Adopted_object_existence'); - expect(output).to.have.a.property('Adopted_data_read'); - expect(output).to.have.a.property('Adopted_data_add'); - expect(output).to.have.a.property('Adopted_data_update'); - expect(output).to.have.a.property('Adopted_data_delete'); - expect(output).to.have.a.property('Adopted_data_execute'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Adopted_object_alter'); - expect(output).to.have.a.property('Adopted_object_reference'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Data_execute'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Object_alter'); - expect(output).to.have.a.property('Object_reference'); - expect(output).to.have.a.property('ASP_device_name_of_library'); - expect(output).to.have.a.property('ASP_device_name_of_object'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Offset_to_group_information_table'); - expect(output).to.have.a.property('Number_of_group_table_entries_returned'); - done(); - }); + it(`returns uses's authority for an object using ${config.transport} tranport`, (done) => { + const connection = new iConn(database, username, password, restOptions); + + const obj = new iObj(connection); + + obj.retrUsrAuth('*PUBLIC', '*PGM', 'XMLCGI', 'QXMLSERV', (output) => { + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Object_authority_/_Data_authority'); + expect(output).to.have.a.property('Authorization_list_management'); + expect(output).to.have.a.property('Object_operational'); + expect(output).to.have.a.property('Object_management'); + expect(output).to.have.a.property('Object_existence'); + expect(output).to.have.a.property('Data_read'); + expect(output).to.have.a.property('Data_add'); + expect(output).to.have.a.property('Data_update'); + expect(output).to.have.a.property('Data_delete'); + expect(output).to.have.a.property('Authorization_list'); + expect(output).to.have.a.property('Authority_source'); + expect(output).to.have.a.property('Some_adopted_authority'); + expect(output).to.have.a.property('Adopted_object_authority'); + expect(output).to.have.a.property('Adopted_authorization_list_management'); + expect(output).to.have.a.property('Adopted_object_operational'); + expect(output).to.have.a.property('Adopted_object_management'); + expect(output).to.have.a.property('Adopted_object_existence'); + expect(output).to.have.a.property('Adopted_data_read'); + expect(output).to.have.a.property('Adopted_data_add'); + expect(output).to.have.a.property('Adopted_data_update'); + expect(output).to.have.a.property('Adopted_data_delete'); + expect(output).to.have.a.property('Adopted_data_execute'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Adopted_object_alter'); + expect(output).to.have.a.property('Adopted_object_reference'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Data_execute'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Object_alter'); + expect(output).to.have.a.property('Object_reference'); + expect(output).to.have.a.property('ASP_device_name_of_library'); + expect(output).to.have.a.property('ASP_device_name_of_object'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Offset_to_group_information_table'); + expect(output).to.have.a.property('Number_of_group_table_entries_returned'); + done(); }); }); }); describe('rtrCmdInfo', () => { - transports.forEach((transport) => { - it(`returns command info using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const obj = new iObj(connection); - - obj.retrCmdInfo('CRTLIB', '*LIBL', (output) => { - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Command_name'); - expect(output).to.have.a.property('Command_library_name'); - expect(output).to.have.a.property('Command_processing_program_or_proxy_target_command'); - expect(output).to.have.a.property('Command_processing_program\'s_or_proxy_target_command\'s_library_name'); - expect(output).to.have.a.property('Source_file_name'); - expect(output).to.have.a.property('Source_file_library_name'); - expect(output).to.have.a.property('Source_file_member_name'); - expect(output).to.have.a.property('Validity_check_program_name'); - expect(output).to.have.a.property('Validity_check_program_library_name'); - expect(output).to.have.a.property('Mode_information'); - expect(output).to.have.a.property('Where_allowed_to_run'); - expect(output).to.have.a.property('Allow_limited_user'); - expect(output).to.have.a.property('Maximum_positional_parameters'); - expect(output).to.have.a.property('Prompt_message_file_name'); - expect(output).to.have.a.property('Prompt_message_file_library_name'); - expect(output).to.have.a.property('Message_file_name'); - expect(output).to.have.a.property('Message_file_library_name'); - expect(output).to.have.a.property('Help_panel_group_name'); - expect(output).to.have.a.property('Help_panel_group_library_name'); - expect(output).to.have.a.property('Help_identifier'); - expect(output).to.have.a.property('Search_index_name'); - expect(output).to.have.a.property('Search_index_library_name'); - expect(output).to.have.a.property('Current_library'); - expect(output).to.have.a.property('Product_library'); - expect(output).to.have.a.property('Prompt_override_program_name'); - expect(output).to.have.a.property('Prompt_override_program_library_name'); - expect(output).to.have.a.property('Restricted_to_target_release'); - expect(output).to.have.a.property('Text_description'); - expect(output).to.have.a.property('Command_processing_program_call_state'); - expect(output).to.have.a.property('Validity_check_program_call_state'); - expect(output).to.have.a.property('Prompt_override_program_call_state'); - expect(output).to.have.a.property('Offset_to_help_bookshelf_information'); - expect(output).to.have.a.property('Length_of_help_bookshelf_information'); - expect(output).to.have.a.property('Coded_character_set_ID_(CCSID)'); - expect(output).to.have.a.property('Enabled_for_GUI_indicator'); - expect(output).to.have.a.property('Threadsafe_indicator'); - expect(output).to.have.a.property('Multithreaded_job_action'); - expect(output).to.have.a.property('Proxy_command_indicator'); - expect(output).to.have.a.property('Prompt_message_file_text_indicator'); - done(); - }); + it('returns command info', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const obj = new iObj(connection); + + obj.retrCmdInfo('CRTLIB', '*LIBL', (output) => { + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Command_name'); + expect(output).to.have.a.property('Command_library_name'); + expect(output).to.have.a.property('Command_processing_program_or_proxy_target_command'); + expect(output).to.have.a.property('Command_processing_program\'s_or_proxy_target_command\'s_library_name'); + expect(output).to.have.a.property('Source_file_name'); + expect(output).to.have.a.property('Source_file_library_name'); + expect(output).to.have.a.property('Source_file_member_name'); + expect(output).to.have.a.property('Validity_check_program_name'); + expect(output).to.have.a.property('Validity_check_program_library_name'); + expect(output).to.have.a.property('Mode_information'); + expect(output).to.have.a.property('Where_allowed_to_run'); + expect(output).to.have.a.property('Allow_limited_user'); + expect(output).to.have.a.property('Maximum_positional_parameters'); + expect(output).to.have.a.property('Prompt_message_file_name'); + expect(output).to.have.a.property('Prompt_message_file_library_name'); + expect(output).to.have.a.property('Message_file_name'); + expect(output).to.have.a.property('Message_file_library_name'); + expect(output).to.have.a.property('Help_panel_group_name'); + expect(output).to.have.a.property('Help_panel_group_library_name'); + expect(output).to.have.a.property('Help_identifier'); + expect(output).to.have.a.property('Search_index_name'); + expect(output).to.have.a.property('Search_index_library_name'); + expect(output).to.have.a.property('Current_library'); + expect(output).to.have.a.property('Product_library'); + expect(output).to.have.a.property('Prompt_override_program_name'); + expect(output).to.have.a.property('Prompt_override_program_library_name'); + expect(output).to.have.a.property('Restricted_to_target_release'); + expect(output).to.have.a.property('Text_description'); + expect(output).to.have.a.property('Command_processing_program_call_state'); + expect(output).to.have.a.property('Validity_check_program_call_state'); + expect(output).to.have.a.property('Prompt_override_program_call_state'); + expect(output).to.have.a.property('Offset_to_help_bookshelf_information'); + expect(output).to.have.a.property('Length_of_help_bookshelf_information'); + expect(output).to.have.a.property('Coded_character_set_ID_(CCSID)'); + expect(output).to.have.a.property('Enabled_for_GUI_indicator'); + expect(output).to.have.a.property('Threadsafe_indicator'); + expect(output).to.have.a.property('Multithreaded_job_action'); + expect(output).to.have.a.property('Proxy_command_indicator'); + expect(output).to.have.a.property('Prompt_message_file_text_indicator'); + done(); }); }); }); describe('retrPgmInfo', () => { - transports.forEach((transport) => { - it(`returns program info using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const obj = new iObj(connection); - - obj.retrPgmInfo('XMLCGI', 'QXMLSERV', (output) => { - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Program_name'); - expect(output).to.have.a.property('Program_library_name'); - expect(output).to.have.a.property('Program_owner'); - expect(output).to.have.a.property('Program_attribute'); - expect(output).to.have.a.property('Creation_date_and_time'); - expect(output).to.have.a.property('Source_file_name'); - expect(output).to.have.a.property('Source_file_library_name'); - expect(output).to.have.a.property('Source_file_member_name'); - expect(output).to.have.a.property('Source_file_updated_date_and_time'); - expect(output).to.have.a.property('Observable_information'); - expect(output).to.have.a.property('User_profile_option'); - expect(output).to.have.a.property('Use_adopted_authority'); - expect(output).to.have.a.property('Log_commands'); - expect(output).to.have.a.property('Allow_RTVCLSRC'); - expect(output).to.have.a.property('Fix_decimal_data'); - expect(output).to.have.a.property('Text_description'); - expect(output).to.have.a.property('Type_of_program'); - expect(output).to.have.a.property('Teraspace_storage-enabled_program'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Minimum_number_of_parameters'); - expect(output).to.have.a.property('Maximum_number_of_parameters'); - expect(output).to.have.a.property('Program_size'); - expect(output).to.have.a.property('Associated_space_size'); - expect(output).to.have.a.property('Static_storage_size'); - expect(output).to.have.a.property('Automatic_storage_size'); - expect(output).to.have.a.property('Number_of_MI_instructions'); - expect(output).to.have.a.property('Number_of_MI_ODT_entries'); - expect(output).to.have.a.property('Program_state'); - expect(output).to.have.a.property('Compiler_identification'); - expect(output).to.have.a.property('Earliest_release_program_can_run'); - expect(output).to.have.a.property('Sort_sequence_table_name'); - expect(output).to.have.a.property('Sort_sequence_table_library_name'); - expect(output).to.have.a.property('Language_identifier'); - expect(output).to.have.a.property('Program_domain'); - expect(output).to.have.a.property('Conversion_required'); - expect(output).to.have.a.property('Conversion_details'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Optimization'); - expect(output).to.have.a.property('Paging_pool'); - expect(output).to.have.a.property('Update_program_automatic_storage_area_(PASA)'); - expect(output).to.have.a.property('Clear_program_automatic_storage_area_(PASA)'); - expect(output).to.have.a.property('Paging_amount'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Program_entry_procedure_module'); - expect(output).to.have.a.property('Program_entry_procedure_module_library'); - expect(output).to.have.a.property('Activation_group_attribute'); - expect(output).to.have.a.property('Observable_information_compressed'); - expect(output).to.have.a.property('Run-time_information_compressed'); - expect(output).to.have.a.property('Release_program_created_on'); - expect(output).to.have.a.property('Shared_activation_group'); - expect(output).to.have.a.property('Allow_update'); - expect(output).to.have.a.property('Program_CCSID'); - expect(output).to.have.a.property('Number_of_modules'); - expect(output).to.have.a.property('Number_of_service_programs'); - expect(output).to.have.a.property('Number_of_copyrights'); - expect(output).to.have.a.property('Number_of_unresolved_references'); - expect(output).to.have.a.property('Release_program_created_for'); - expect(output).to.have.a.property('Allow_static_storage_reinitialization'); - expect(output).to.have.a.property('All_creation_data'); - expect(output).to.have.a.property('Allow_bound_*SRVPGM_library_name_update'); - expect(output).to.have.a.property('Profiling_data'); - expect(output).to.have.a.property('Teraspace_storage_enabled_modules'); - expect(output).to.have.a.property('Storage_model'); - expect(output).to.have.a.property('Uses_argument_optimization_(ARGOPT)'); - done(); - }); + it('returns program info', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const obj = new iObj(connection); + + obj.retrPgmInfo('XMLCGI', 'QXMLSERV', (output) => { + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Program_name'); + expect(output).to.have.a.property('Program_library_name'); + expect(output).to.have.a.property('Program_owner'); + expect(output).to.have.a.property('Program_attribute'); + expect(output).to.have.a.property('Creation_date_and_time'); + expect(output).to.have.a.property('Source_file_name'); + expect(output).to.have.a.property('Source_file_library_name'); + expect(output).to.have.a.property('Source_file_member_name'); + expect(output).to.have.a.property('Source_file_updated_date_and_time'); + expect(output).to.have.a.property('Observable_information'); + expect(output).to.have.a.property('User_profile_option'); + expect(output).to.have.a.property('Use_adopted_authority'); + expect(output).to.have.a.property('Log_commands'); + expect(output).to.have.a.property('Allow_RTVCLSRC'); + expect(output).to.have.a.property('Fix_decimal_data'); + expect(output).to.have.a.property('Text_description'); + expect(output).to.have.a.property('Type_of_program'); + expect(output).to.have.a.property('Teraspace_storage-enabled_program'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Minimum_number_of_parameters'); + expect(output).to.have.a.property('Maximum_number_of_parameters'); + expect(output).to.have.a.property('Program_size'); + expect(output).to.have.a.property('Associated_space_size'); + expect(output).to.have.a.property('Static_storage_size'); + expect(output).to.have.a.property('Automatic_storage_size'); + expect(output).to.have.a.property('Number_of_MI_instructions'); + expect(output).to.have.a.property('Number_of_MI_ODT_entries'); + expect(output).to.have.a.property('Program_state'); + expect(output).to.have.a.property('Compiler_identification'); + expect(output).to.have.a.property('Earliest_release_program_can_run'); + expect(output).to.have.a.property('Sort_sequence_table_name'); + expect(output).to.have.a.property('Sort_sequence_table_library_name'); + expect(output).to.have.a.property('Language_identifier'); + expect(output).to.have.a.property('Program_domain'); + expect(output).to.have.a.property('Conversion_required'); + expect(output).to.have.a.property('Conversion_details'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Optimization'); + expect(output).to.have.a.property('Paging_pool'); + expect(output).to.have.a.property('Update_program_automatic_storage_area_(PASA)'); + expect(output).to.have.a.property('Clear_program_automatic_storage_area_(PASA)'); + expect(output).to.have.a.property('Paging_amount'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Program_entry_procedure_module'); + expect(output).to.have.a.property('Program_entry_procedure_module_library'); + expect(output).to.have.a.property('Activation_group_attribute'); + expect(output).to.have.a.property('Observable_information_compressed'); + expect(output).to.have.a.property('Run-time_information_compressed'); + expect(output).to.have.a.property('Release_program_created_on'); + expect(output).to.have.a.property('Shared_activation_group'); + expect(output).to.have.a.property('Allow_update'); + expect(output).to.have.a.property('Program_CCSID'); + expect(output).to.have.a.property('Number_of_modules'); + expect(output).to.have.a.property('Number_of_service_programs'); + expect(output).to.have.a.property('Number_of_copyrights'); + expect(output).to.have.a.property('Number_of_unresolved_references'); + expect(output).to.have.a.property('Release_program_created_for'); + expect(output).to.have.a.property('Allow_static_storage_reinitialization'); + expect(output).to.have.a.property('All_creation_data'); + expect(output).to.have.a.property('Allow_bound_*SRVPGM_library_name_update'); + expect(output).to.have.a.property('Profiling_data'); + expect(output).to.have.a.property('Teraspace_storage_enabled_modules'); + expect(output).to.have.a.property('Storage_model'); + expect(output).to.have.a.property('Uses_argument_optimization_(ARGOPT)'); + done(); }); }); }); describe('retrSrvPgmInfo', () => { - transports.forEach((transport) => { - it(`returns service program info using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const obj = new iObj(connection); - - obj.retrSrvPgmInfo('QZSRVSSL', 'QHTTPSVR', (output) => { - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Service_program_name'); - expect(output).to.have.a.property('Service_program_name'); - expect(output).to.have.a.property('Service_program_owner'); - expect(output).to.have.a.property('Service_program_attribute'); - expect(output).to.have.a.property('Creation_date_and_time'); - expect(output).to.have.a.property('Export_source_file_name'); - expect(output).to.have.a.property('Export_source_file_library_name'); - expect(output).to.have.a.property('Export_source_file_member_name'); - expect(output).to.have.a.property('Activation_group_attribute'); - expect(output).to.have.a.property('Current_export_signature'); - expect(output).to.have.a.property('User_profile'); - expect(output).to.have.a.property('Observable_information_compressed'); - expect(output).to.have.a.property('Run-time_information_compressed'); - expect(output).to.have.a.property('Run-time_information_compressed'); - expect(output).to.have.a.property('Service_program_CCSID'); - expect(output).to.have.a.property('Number_of_modules'); - expect(output).to.have.a.property('Number_of_service_programs'); - expect(output).to.have.a.property('Number_of_copyrights'); - expect(output).to.have.a.property('Text_description'); - expect(output).to.have.a.property('Shared_activation_group'); - expect(output).to.have.a.property('Allow_update'); - expect(output).to.have.a.property('Number_of_unresolved_references'); - expect(output).to.have.a.property('Use_adopted_authority'); - expect(output).to.have.a.property('Allow_bound_*SRVPGM_library_name_update'); - expect(output).to.have.a.property('Profiling_data'); - expect(output).to.have.a.property('Teraspace_storage_enabled_modules'); - expect(output).to.have.a.property('Storage_model'); - expect(output).to.have.a.property('Uses_argument_optimization_(ARGOPT)'); - expect(output).to.have.a.property('Reserved_\'00\'X'); - expect(output).to.have.a.property('Service_program_state'); - expect(output).to.have.a.property('Service_program_domain'); - expect(output).to.have.a.property('Associated_space_size'); - expect(output).to.have.a.property('Static_storage_size'); - expect(output).to.have.a.property('Service_program_size'); - expect(output).to.have.a.property('Release_service_program_created_on'); - expect(output).to.have.a.property('Earliest_release_service_program_can_run'); - expect(output).to.have.a.property('Release_service_program_created_for'); - expect(output).to.have.a.property('Allow_static_storage_reinitialization'); - expect(output).to.have.a.property('Conversion_required'); - expect(output).to.have.a.property('All_creation_data'); - expect(output).to.have.a.property('Conversion_details'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Paging_pool'); - expect(output).to.have.a.property('Paging_amount'); - done(); - }); + it('returns service program info', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const obj = new iObj(connection); + + obj.retrSrvPgmInfo('QZSRVSSL', 'QHTTPSVR', (output) => { + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Service_program_name'); + expect(output).to.have.a.property('Service_program_name'); + expect(output).to.have.a.property('Service_program_owner'); + expect(output).to.have.a.property('Service_program_attribute'); + expect(output).to.have.a.property('Creation_date_and_time'); + expect(output).to.have.a.property('Export_source_file_name'); + expect(output).to.have.a.property('Export_source_file_library_name'); + expect(output).to.have.a.property('Export_source_file_member_name'); + expect(output).to.have.a.property('Activation_group_attribute'); + expect(output).to.have.a.property('Current_export_signature'); + expect(output).to.have.a.property('User_profile'); + expect(output).to.have.a.property('Observable_information_compressed'); + expect(output).to.have.a.property('Run-time_information_compressed'); + expect(output).to.have.a.property('Run-time_information_compressed'); + expect(output).to.have.a.property('Service_program_CCSID'); + expect(output).to.have.a.property('Number_of_modules'); + expect(output).to.have.a.property('Number_of_service_programs'); + expect(output).to.have.a.property('Number_of_copyrights'); + expect(output).to.have.a.property('Text_description'); + expect(output).to.have.a.property('Shared_activation_group'); + expect(output).to.have.a.property('Allow_update'); + expect(output).to.have.a.property('Number_of_unresolved_references'); + expect(output).to.have.a.property('Use_adopted_authority'); + expect(output).to.have.a.property('Allow_bound_*SRVPGM_library_name_update'); + expect(output).to.have.a.property('Profiling_data'); + expect(output).to.have.a.property('Teraspace_storage_enabled_modules'); + expect(output).to.have.a.property('Storage_model'); + expect(output).to.have.a.property('Uses_argument_optimization_(ARGOPT)'); + expect(output).to.have.a.property('Reserved_\'00\'X'); + expect(output).to.have.a.property('Service_program_state'); + expect(output).to.have.a.property('Service_program_domain'); + expect(output).to.have.a.property('Associated_space_size'); + expect(output).to.have.a.property('Static_storage_size'); + expect(output).to.have.a.property('Service_program_size'); + expect(output).to.have.a.property('Release_service_program_created_on'); + expect(output).to.have.a.property('Earliest_release_service_program_can_run'); + expect(output).to.have.a.property('Release_service_program_created_for'); + expect(output).to.have.a.property('Allow_static_storage_reinitialization'); + expect(output).to.have.a.property('Conversion_required'); + expect(output).to.have.a.property('All_creation_data'); + expect(output).to.have.a.property('Conversion_details'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Paging_pool'); + expect(output).to.have.a.property('Paging_amount'); + done(); }); }); }); describe('retrUserInfo', () => { - transports.forEach((transport) => { - it(`returns specified user profile info using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const obj = new iObj(connection); - - obj.retrUserInfo('QSYS', (output) => { - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('User_profile_name'); - expect(output).to.have.a.property('Previous_sign-on_date_and_time'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Sign-on_attempts_not_valid'); - expect(output).to.have.a.property('Status'); - expect(output).to.have.a.property('Password_change_date'); - expect(output).to.have.a.property('No_password_indicator'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Password_expiration_interval'); - expect(output).to.have.a.property('Date_password_expires'); - expect(output).to.have.a.property('Days_until_password_expires'); - expect(output).to.have.a.property('Set_password_to_expire'); - expect(output).to.have.a.property('Display_sign-on_information'); - expect(output).to.have.a.property('Local_password_management'); - expect(output).to.have.a.property('Block_password_change'); - done(); - }); + it('returns specified user profile info', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const obj = new iObj(connection); + + obj.retrUserInfo('QSYS', (output) => { + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('User_profile_name'); + expect(output).to.have.a.property('Previous_sign-on_date_and_time'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Sign-on_attempts_not_valid'); + expect(output).to.have.a.property('Status'); + expect(output).to.have.a.property('Password_change_date'); + expect(output).to.have.a.property('No_password_indicator'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Password_expiration_interval'); + expect(output).to.have.a.property('Date_password_expires'); + expect(output).to.have.a.property('Days_until_password_expires'); + expect(output).to.have.a.property('Set_password_to_expire'); + expect(output).to.have.a.property('Display_sign-on_information'); + expect(output).to.have.a.property('Local_password_management'); + expect(output).to.have.a.property('Block_password_change'); + done(); }); }); }); describe('retrUsrAuthToObj', () => { - transports.forEach((transport) => { - it(`retrieves info for users who are authorized to an object using ${transport.name} transpsort`, (done) => { - const connection = transport.me; - - const obj = new iObj(connection); - - obj.retrUserAuthToObj('/home', (output) => { - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Profile_name'); - expect(output).to.have.a.property('User_or_group_indicator'); - expect(output).to.have.a.property('Data_authority'); - expect(output).to.have.a.property('Authorization_list_management'); - expect(output).to.have.a.property('Object_management'); - expect(output).to.have.a.property('Object_existence'); - expect(output).to.have.a.property('Object_alter'); - expect(output).to.have.a.property('Object_reference'); - expect(output).to.have.a.property('Reserved'); - expect(output).to.have.a.property('Object_operational'); - expect(output).to.have.a.property('Data_read'); - expect(output).to.have.a.property('Data_add'); - expect(output).to.have.a.property('Data_update'); - expect(output).to.have.a.property('Data_delete'); - expect(output).to.have.a.property('Data_execute'); - done(); - }); + it(`retrieves info for users who are authorized to an object using ${config.transport} transpsort`, (done) => { + const connection = new iConn(database, username, password, restOptions); + + const obj = new iObj(connection); + + obj.retrUserAuthToObj('/home', (output) => { + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Profile_name'); + expect(output).to.have.a.property('User_or_group_indicator'); + expect(output).to.have.a.property('Data_authority'); + expect(output).to.have.a.property('Authorization_list_management'); + expect(output).to.have.a.property('Object_management'); + expect(output).to.have.a.property('Object_existence'); + expect(output).to.have.a.property('Object_alter'); + expect(output).to.have.a.property('Object_reference'); + expect(output).to.have.a.property('Reserved'); + expect(output).to.have.a.property('Object_operational'); + expect(output).to.have.a.property('Data_read'); + expect(output).to.have.a.property('Data_add'); + expect(output).to.have.a.property('Data_update'); + expect(output).to.have.a.property('Data_delete'); + expect(output).to.have.a.property('Data_execute'); + done(); }); }); }); describe('addToLibraryList', () => { - transports.forEach((transport) => { - it(`appends lib to user's lib list using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('appends lib to user\'s lib list', (done) => { + const connection = new iConn(database, username, password, restOptions); - const obj = new iObj(connection); + const obj = new iObj(connection); - obj.addToLibraryList('QHTTPSVR', (output) => { - expect(output).to.be.a('boolean').and.to.equal(true); - done(); - }); + obj.addToLibraryList('QHTTPSVR', (output) => { + expect(output).to.be.a('boolean').and.to.equal(true); + done(); }); }); }); diff --git a/test/functional/deprecated/iPgmFunctional.js b/test/functional/deprecated/iPgmFunctional.js index 185885bc..80a123b9 100644 --- a/test/functional/deprecated/iPgmFunctional.js +++ b/test/functional/deprecated/iPgmFunctional.js @@ -20,52 +20,59 @@ const { expect } = require('chai'); const { parseString } = require('xml2js'); -const { iPgm } = require('../../../lib/itoolkit'); -const { returnTransportsDeprecated } = require('../../../lib/utils'); - -// Set Env variables or set values here. -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT || 80, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', -}; - - -const transports = returnTransportsDeprecated(opt); +const { iPgm, iConn } = require('../../../lib/itoolkit'); +const { config, printConfig } = require('../config'); + +// deprecated tests are in place to test compatability using deprecated classes and functions +// these tests use deprecated iConn Class to create a connnection +// iConn only supported idb and rest transports +if (config.transport !== 'idb' && config.transport !== 'rest') { + throw new Error('Only idb and rest transports are available for deprecated tests'); +} + +const { database, username, password } = config.transportOptions; + +let restOptions = null; +if (config.transport === 'rest') { + restOptions = { + hodt: config.host, + port: config.port || 80, + path: config.path, + }; +} describe('iPgm Functional Tests', () => { + before(() => { + printConfig(); + }); + describe('Test iPgm()', () => { - transports.forEach((transport) => { - it(`calls QWCRSVAL program checks if it ran successfully using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const program = new iPgm('QWCRSVAL', { lib: 'QSYS' }); - - const outBuf = [ - [0, '10i0'], - [0, '10i0'], - ['', '36h'], - ['', '10A'], - ['', '1A'], - ['', '1A'], - [0, '10i0'], - [0, '10i0'], - ]; - program.addParam(outBuf, { io: 'out' }); - program.addParam(66, '10i0'); - program.addParam(1, '10i0'); - program.addParam('QCCSID', '10A'); - program.addParam(this.errno, { io: 'both', len: 'rec2' }); - connection.add(program); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.pgm[0].success[0]).to.include('+++ success QSYS QWCRSVAL'); - done(); - }); + it('calls QWCRSVAL program checks if it ran successfully', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const program = new iPgm('QWCRSVAL', { lib: 'QSYS' }); + + const outBuf = [ + [0, '10i0'], + [0, '10i0'], + ['', '36h'], + ['', '10A'], + ['', '1A'], + ['', '1A'], + [0, '10i0'], + [0, '10i0'], + ]; + program.addParam(outBuf, { io: 'out' }); + program.addParam(66, '10i0'); + program.addParam(1, '10i0'); + program.addParam('QCCSID', '10A'); + program.addParam(this.errno, { io: 'both', len: 'rec2' }); + connection.add(program); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.pgm[0].success[0]).to.include('+++ success QSYS QWCRSVAL'); + done(); }); }); }); @@ -73,36 +80,34 @@ describe('iPgm Functional Tests', () => { describe('Test iPgm()', () => { - transports.forEach((transport) => { - it(`calls QWCRSVAL program and returns arbitrarily named parameter using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const program = new iPgm('QWCRSVAL', { lib: 'QSYS' }); - - const outBuf = [ - [0, '10i0'], - [0, '10i0'], - ['', '36h'], - ['', '10A'], - ['', '1A'], - ['', '1A'], - [0, '10i0'], - [0, '10i0'], - ]; - program.addParam(outBuf, { io: 'out' }); - program.addParam(66, '10i0'); - program.addParam(1, '10i0'); - program.addParam('QCCSID', '10A'); - const paramValue = 'errno'; - - program.addParam(this.errno, { io: 'both', len: 'rec2', name: paramValue }); - connection.add(program); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.pgm[0].success[0]).to.include('+++ success QSYS QWCRSVAL'); - done(); - }); + it('calls QWCRSVAL program and returns arbitrarily named parameter', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const program = new iPgm('QWCRSVAL', { lib: 'QSYS' }); + + const outBuf = [ + [0, '10i0'], + [0, '10i0'], + ['', '36h'], + ['', '10A'], + ['', '1A'], + ['', '1A'], + [0, '10i0'], + [0, '10i0'], + ]; + program.addParam(outBuf, { io: 'out' }); + program.addParam(66, '10i0'); + program.addParam(1, '10i0'); + program.addParam('QCCSID', '10A'); + const paramValue = 'errno'; + + program.addParam(this.errno, { io: 'both', len: 'rec2', name: paramValue }); + connection.add(program); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.pgm[0].success[0]).to.include('+++ success QSYS QWCRSVAL'); + done(); }); }); }); @@ -111,23 +116,21 @@ describe('iPgm Functional Tests', () => { describe.skip('Test iPgm()', () => { // ZZSRV6 program requires XMLSERVICE built with tests // Skip for now, we need to add before hook to check if ZZSRV6 is available - transports.forEach((transport) => { - it.skip(`Should be successful with addReturn arbitrary attribute specified using using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const program = new iPgm('ZZSRV6', { lib: 'XMLSERVICE', func: 'ZZVARY4' }); - - program.addParam('Gill', '10A', { varying: '4' }); - const testValue = 'NEW_NAME'; - program.addReturn('0', '20A', { varying: '4', name: testValue }); - connection.add(program); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.pgm[0].success[0]).to.include('+++ success'); - expect(result.myscript.pgm[0].return[0].data[0]._).to.equal('my name is Gill'); - done(); - }); + it.skip('Should be successful with addReturn arbitrary attribute specified using', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const program = new iPgm('ZZSRV6', { lib: 'XMLSERVICE', func: 'ZZVARY4' }); + + program.addParam('Gill', '10A', { varying: '4' }); + const testValue = 'NEW_NAME'; + program.addReturn('0', '20A', { varying: '4', name: testValue }); + connection.add(program); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.pgm[0].success[0]).to.include('+++ success'); + expect(result.myscript.pgm[0].return[0].data[0]._).to.equal('my name is Gill'); + done(); }); }); }); diff --git a/test/functional/deprecated/iProdFunctional.js b/test/functional/deprecated/iProdFunctional.js index 14803e79..d3a38c61 100644 --- a/test/functional/deprecated/iProdFunctional.js +++ b/test/functional/deprecated/iProdFunctional.js @@ -20,24 +20,35 @@ const { expect } = require('chai'); const { iConn, iProd } = require('../../../lib/itoolkit'); -const { returnTransportsDeprecated } = require('../../../lib/utils'); +const { config, printConfig } = require('../config'); -// Set Env variables or set values here. -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT || 80, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', -}; +// deprecated tests are in place to test compatability using deprecated classes and functions +// these tests use deprecated iConn Class to create a connnection +// iConn only supported idb and rest transports +if (config.transport !== 'idb' && config.transport !== 'rest') { + throw new Error('Only idb and rest transports are available for deprecated tests'); +} -const transports = returnTransportsDeprecated(opt); +const { database, username, password } = config.transportOptions; + +let restOptions = null; + +if (config.transport === 'rest') { + restOptions = { + hodt: config.host, + port: config.port || 80, + path: config.path, + }; +} describe('iProd Functional Tests', () => { + before(() => { + printConfig(); + }); + describe('constructor', () => { it('creates and returns an instance of iProd', () => { - const connection = new iConn(opt.database, opt.user, opt.password); + const connection = new iConn(database, config.user, password); const prod = new iProd(connection); @@ -46,78 +57,74 @@ describe('iProd Functional Tests', () => { }); describe('getPTFInfo', () => { - transports.forEach((transport) => { - it(`returns info for specified ptf using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const prod = new iProd(connection); - - prod.getPTFInfo('SI67726', (ptf) => { - expect(ptf).to.be.an('Object'); - expect(ptf).to.have.a.property('Product_ID'); - expect(ptf).to.have.a.property('PTF_ID'); - expect(ptf).to.have.a.property('Release_level'); - expect(ptf).to.have.a.property('Product_option'); - expect(ptf).to.have.a.property('Load_ID'); - expect(ptf).to.have.a.property('Loaded_status'); - expect(ptf).to.have.a.property('Cover_letter_status'); - expect(ptf).to.have.a.property('On-order_status'); - expect(ptf).to.have.a.property('Save_file_status'); - expect(ptf).to.have.a.property('File_name'); - expect(ptf).to.have.a.property('File_library_name'); - expect(ptf).to.have.a.property('PTF_type'); - expect(ptf).to.have.a.property('IPL_action'); - expect(ptf).to.have.a.property('Action_pending'); - expect(ptf).to.have.a.property('Action_required'); - expect(ptf).to.have.a.property('PTF_is_released'); - expect(ptf).to.have.a.property('Target_release'); - expect(ptf).to.have.a.property('Superseding_PTF'); - expect(ptf).to.have.a.property('Current_IPL_source'); - expect(ptf).to.have.a.property('Minimum_level'); - expect(ptf).to.have.a.property('Maximum_level'); - expect(ptf).to.have.a.property('Format_information_available'); - expect(ptf).to.have.a.property('Status_date_and_time'); - expect(ptf).to.have.a.property('Licensed_Internal_Code_group'); - expect(ptf).to.have.a.property('Superseded_by_PTF_ID'); - expect(ptf).to.have.a.property('Current_server_IPL_source'); - expect(ptf).to.have.a.property('Server_IPL_required'); - expect(ptf).to.have.a.property('Creation_date_and_time'); - expect(ptf).to.have.a.property('Technology_refresh_PTF'); - expect(ptf).to.have.a.property('Reserved'); - done(); - }); + it('returns info for specified ptf', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const prod = new iProd(connection); + + prod.getPTFInfo('SI67726', (ptf) => { + expect(ptf).to.be.an('Object'); + expect(ptf).to.have.a.property('Product_ID'); + expect(ptf).to.have.a.property('PTF_ID'); + expect(ptf).to.have.a.property('Release_level'); + expect(ptf).to.have.a.property('Product_option'); + expect(ptf).to.have.a.property('Load_ID'); + expect(ptf).to.have.a.property('Loaded_status'); + expect(ptf).to.have.a.property('Cover_letter_status'); + expect(ptf).to.have.a.property('On-order_status'); + expect(ptf).to.have.a.property('Save_file_status'); + expect(ptf).to.have.a.property('File_name'); + expect(ptf).to.have.a.property('File_library_name'); + expect(ptf).to.have.a.property('PTF_type'); + expect(ptf).to.have.a.property('IPL_action'); + expect(ptf).to.have.a.property('Action_pending'); + expect(ptf).to.have.a.property('Action_required'); + expect(ptf).to.have.a.property('PTF_is_released'); + expect(ptf).to.have.a.property('Target_release'); + expect(ptf).to.have.a.property('Superseding_PTF'); + expect(ptf).to.have.a.property('Current_IPL_source'); + expect(ptf).to.have.a.property('Minimum_level'); + expect(ptf).to.have.a.property('Maximum_level'); + expect(ptf).to.have.a.property('Format_information_available'); + expect(ptf).to.have.a.property('Status_date_and_time'); + expect(ptf).to.have.a.property('Licensed_Internal_Code_group'); + expect(ptf).to.have.a.property('Superseded_by_PTF_ID'); + expect(ptf).to.have.a.property('Current_server_IPL_source'); + expect(ptf).to.have.a.property('Server_IPL_required'); + expect(ptf).to.have.a.property('Creation_date_and_time'); + expect(ptf).to.have.a.property('Technology_refresh_PTF'); + expect(ptf).to.have.a.property('Reserved'); + done(); }); }); }); describe('getProductInfo', () => { - transports.forEach((transport) => { - it(`returns info for specified product using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('returns info for specified product', (done) => { + const connection = new iConn(database, username, password, restOptions); - const prod = new iProd(connection); + const prod = new iProd(connection); - prod.getProductInfo('5770DG1', (product) => { - expect(product).to.be.an('Object'); - expect(product).to.have.a.property('Reserved'); - expect(product).to.have.a.property('Product_ID'); - expect(product).to.have.a.property('Release_level'); - expect(product).to.have.a.property('Product_option'); - expect(product).to.have.a.property('Load_ID'); - expect(product).to.have.a.property('Symbolic_load_state'); - expect(product).to.have.a.property('Load_error_indicator'); - expect(product).to.have.a.property('Load_state'); - expect(product).to.have.a.property('Supported_flag'); - expect(product).to.have.a.property('Registration_type'); - expect(product).to.have.a.property('Registration_value'); - expect(product).to.have.a.property('Offset_to_additional_information'); - expect(product).to.have.a.property('Primary_language_load_identifier'); - expect(product).to.have.a.property('Minimum_target_release'); - expect(product).to.have.a.property('Minimum_VRM_of_*BASE_required_by_option'); - expect(product).to.have.a.property('Requirements_met_between_base_and_option_value'); - expect(product).to.have.a.property('Level'); - done(); - }); + prod.getProductInfo('5770DG1', (product) => { + expect(product).to.be.an('Object'); + expect(product).to.have.a.property('Reserved'); + expect(product).to.have.a.property('Product_ID'); + expect(product).to.have.a.property('Release_level'); + expect(product).to.have.a.property('Product_option'); + expect(product).to.have.a.property('Load_ID'); + expect(product).to.have.a.property('Symbolic_load_state'); + expect(product).to.have.a.property('Load_error_indicator'); + expect(product).to.have.a.property('Load_state'); + expect(product).to.have.a.property('Supported_flag'); + expect(product).to.have.a.property('Registration_type'); + expect(product).to.have.a.property('Registration_value'); + expect(product).to.have.a.property('Offset_to_additional_information'); + expect(product).to.have.a.property('Primary_language_load_identifier'); + expect(product).to.have.a.property('Minimum_target_release'); + expect(product).to.have.a.property('Minimum_VRM_of_*BASE_required_by_option'); + expect(product).to.have.a.property('Requirements_met_between_base_and_option_value'); + expect(product).to.have.a.property('Level'); + done(); }); }); }); @@ -125,33 +132,31 @@ describe('iProd Functional Tests', () => { // REST transport currently failing with 414 URI Too Long response code // The requested URL's length exceeds the capacity limit for this server describe('getInstalledProducts', () => { - transports.forEach((transport) => { - // eslint-disable-next-line func-names - it(`returns info for installed products using ${transport.name} transport`, function (done) { - const connection = transport.me; - - const prod = new iProd(connection); - - prod.getInstalledProducts((products) => { - expect(products).to.be.an('Array'); - expect(products.length).to.be.greaterThan(0); - - products.forEach((product) => { - expect(product).to.be.an('Object'); - expect(product).to.have.a.property('Product_ID'); - expect(product).to.have.a.property('Product_option'); - expect(product).to.have.a.property('Release_level'); - expect(product).to.have.a.property('Description_text_message_ID'); - expect(product).to.have.a.property('Description_text_object_name'); - expect(product).to.have.a.property('Description_text_library_name'); - expect(product).to.have.a.property('Installed_flag'); - expect(product).to.have.a.property('Supported_flag'); - expect(product).to.have.a.property('Registration_type'); - expect(product).to.have.a.property('Registration_value'); - expect(product).to.have.a.property('Description_text'); - }); - done(); + // eslint-disable-next-line func-names + it('returns info for installed products', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const prod = new iProd(connection); + + prod.getInstalledProducts((products) => { + expect(products).to.be.an('Array'); + expect(products.length).to.be.greaterThan(0); + + products.forEach((product) => { + expect(product).to.be.an('Object'); + expect(product).to.have.a.property('Product_ID'); + expect(product).to.have.a.property('Product_option'); + expect(product).to.have.a.property('Release_level'); + expect(product).to.have.a.property('Description_text_message_ID'); + expect(product).to.have.a.property('Description_text_object_name'); + expect(product).to.have.a.property('Description_text_library_name'); + expect(product).to.have.a.property('Installed_flag'); + expect(product).to.have.a.property('Supported_flag'); + expect(product).to.have.a.property('Registration_type'); + expect(product).to.have.a.property('Registration_value'); + expect(product).to.have.a.property('Description_text'); }); + done(); }); }); }); diff --git a/test/functional/deprecated/iSqlFunctional.js b/test/functional/deprecated/iSqlFunctional.js index f158be82..3909555b 100644 --- a/test/functional/deprecated/iSqlFunctional.js +++ b/test/functional/deprecated/iSqlFunctional.js @@ -21,395 +21,382 @@ const { expect } = require('chai'); const { parseString } = require('xml2js'); -const { iSql } = require('../../../lib/itoolkit'); -const { returnTransportsDeprecated } = require('../../../lib/utils'); +const { iSql, iConn } = require('../../../lib/itoolkit'); +const { config, printConfig } = require('../config'); -// Set Env variables or set values here. -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT || 80, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', -}; +// deprecated tests are in place to test compatability using deprecated classes and functions +// these tests use deprecated iConn Class to create a connnection +// iConn only supported idb and rest transports +if (config.transport !== 'idb' && config.transport !== 'rest') { + throw new Error('Only idb and rest transports are available for deprecated tests'); +} -const transports = returnTransportsDeprecated(opt); +const { database, username, password } = config.transportOptions; + +let restOptions = null; + +if (config.transport === 'rest') { + restOptions = { + hodt: config.host, + port: config.port || 80, + path: config.path, + }; +} describe('iSql Functional Tests', () => { + before(() => { + printConfig(); + }); + describe('prepare & execute', () => { - transports.forEach((transport) => { - it(`prepares & executes stored procedure then fetch results using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - - sql.prepare('call qsys2.tcpip_info()'); - sql.execute(); - sql.fetch(); - sql.free(); - connection.add(sql); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - const sqlNode = result.myscript.sql[0]; - expect(sqlNode.prepare[0].success[0]).to.include('+++ success'); - expect(sqlNode.execute[0].success[0]).to.include('+++ success'); - expect(sqlNode.fetch[0].success[0]).to.include('+++ success'); - expect(sqlNode.free[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].fetch[0].row[0]; - expect(data[0].$.desc).to.equal('HOSTNAME'); - expect(data[1].$.desc).to.equal('VRM'); - expect(data[2].$.desc).to.equal('DBGROUP'); - expect(data[3].$.desc).to.equal('IPTYPE'); - expect(data[4].$.desc).to.equal('IPADDR'); - expect(data[5].$.desc).to.equal('PORT'); - done(); - }); + it('prepares & executes stored procedure then fetch results', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + + sql.prepare('call qsys2.tcpip_info()'); + sql.execute(); + sql.fetch(); + sql.free(); + connection.add(sql); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + const sqlNode = result.myscript.sql[0]; + expect(sqlNode.prepare[0].success[0]).to.include('+++ success'); + expect(sqlNode.execute[0].success[0]).to.include('+++ success'); + expect(sqlNode.fetch[0].success[0]).to.include('+++ success'); + expect(sqlNode.free[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].fetch[0].row[0]; + expect(data[0].$.desc).to.equal('HOSTNAME'); + expect(data[1].$.desc).to.equal('VRM'); + expect(data[2].$.desc).to.equal('DBGROUP'); + expect(data[3].$.desc).to.equal('IPTYPE'); + expect(data[4].$.desc).to.equal('IPADDR'); + expect(data[5].$.desc).to.equal('PORT'); + done(); }); }); }); }); describe('addQuery & fetch', () => { - transports.forEach((transport) => { - it(`runs a query and fetches results using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - - sql.addQuery('SELECT LSTNAM, STATE FROM QIWS.QCUSTCDT'); - sql.fetch(); - sql.free(); - connection.add(sql); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - const sqlNode = result.myscript.sql[0]; - expect(sqlNode.query[0].success[0]).to.include('+++ success'); - expect(sqlNode.fetch[0].success[0]).to.include('+++ success'); - expect(sqlNode.free[0].success[0]).to.include('+++ success'); - expect(sqlNode.fetch[0].row[0].data[0].$.desc).to.equal('LSTNAM'); - expect(sqlNode.fetch[0].row[0].data[1].$.desc).to.equal('STATE'); - done(); - }); + it('runs a query and fetches results', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + + sql.addQuery('SELECT LSTNAM, STATE FROM QIWS.QCUSTCDT'); + sql.fetch(); + sql.free(); + connection.add(sql); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + const sqlNode = result.myscript.sql[0]; + expect(sqlNode.query[0].success[0]).to.include('+++ success'); + expect(sqlNode.fetch[0].success[0]).to.include('+++ success'); + expect(sqlNode.free[0].success[0]).to.include('+++ success'); + expect(sqlNode.fetch[0].row[0].data[0].$.desc).to.equal('LSTNAM'); + expect(sqlNode.fetch[0].row[0].data[1].$.desc).to.equal('STATE'); + done(); }); }); }); }); describe('added test to ensure issue #11 was resolved', () => { - transports.forEach((transport) => { - it(`should parse SQL result set empty data tags correctly using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - - sql.addQuery('SELECT \'\' AS BLANK, STATE FROM QIWS.QCUSTCDT'); - sql.fetch(); - sql.free(); - connection.add(sql); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - const sqlNode = result.myscript.sql[0]; - expect(sqlNode.query[0].success[0]).to.include('+++ success'); - expect(sqlNode.fetch[0].success[0]).to.include('+++ success'); - expect(sqlNode.free[0].success[0]).to.include('+++ success'); - expect(sqlNode.fetch[0].row[0].data[0].$.desc).to.equal('BLANK'); - // xml2js no inner data gets parsed as undefined. - expect(sqlNode.fetch[0].row[0].data[0]._).to.equal(undefined); - done(); - }); + it('should parse SQL result set empty data tags correctly', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + + sql.addQuery('SELECT \'\' AS BLANK, STATE FROM QIWS.QCUSTCDT'); + sql.fetch(); + sql.free(); + connection.add(sql); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + const sqlNode = result.myscript.sql[0]; + expect(sqlNode.query[0].success[0]).to.include('+++ success'); + expect(sqlNode.fetch[0].success[0]).to.include('+++ success'); + expect(sqlNode.free[0].success[0]).to.include('+++ success'); + expect(sqlNode.fetch[0].row[0].data[0].$.desc).to.equal('BLANK'); + // xml2js no inner data gets parsed as undefined. + expect(sqlNode.fetch[0].row[0].data[0]._).to.equal(undefined); + done(); }); }); }); }); describe('tables', () => { - transports.forEach((transport) => { - it(`returns meta data for specified table using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // [catalog, schema, table, table type] - sql.tables(['', 'QIWS', 'QCUSTCDT', '']); - connection.add(sql.toXML()); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].tables[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].tables[0].row[0]; - expect(data[0].$.desc).to.equal('TABLE_CAT'); - expect(data[1].$.desc).to.equal('TABLE_SCHEM'); - expect(data[2].$.desc).to.equal('TABLE_NAME'); - expect(data[3].$.desc).to.equal('TABLE_TYPE'); - expect(data[4].$.desc).to.equal('REMARKS'); - done(); - }); + it('returns meta data for specified table', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + // [catalog, schema, table, table type] + sql.tables(['', 'QIWS', 'QCUSTCDT', '']); + connection.add(sql.toXML()); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].tables[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].tables[0].row[0]; + expect(data[0].$.desc).to.equal('TABLE_CAT'); + expect(data[1].$.desc).to.equal('TABLE_SCHEM'); + expect(data[2].$.desc).to.equal('TABLE_NAME'); + expect(data[3].$.desc).to.equal('TABLE_TYPE'); + expect(data[4].$.desc).to.equal('REMARKS'); + done(); }); }); }); }); describe('tablePriv', () => { - transports.forEach((transport) => { - it(`returns privilege data for a table using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // [catalog, schema, table] - sql.tablePriv(['', 'QIWS', 'QCUSTCDT']); - connection.add(sql.toXML()); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].tablepriv[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].tablepriv[0].row[0]; - expect(data[0].$.desc).to.equal('TABLE_CAT'); - expect(data[1].$.desc).to.equal('TABLE_SCHEM'); - expect(data[2].$.desc).to.equal('TABLE_NAME'); - expect(data[3].$.desc).to.equal('GRANTOR'); - expect(data[4].$.desc).to.equal('GRANTEE'); - expect(data[5].$.desc).to.equal('PRIVILEGE'); - expect(data[6].$.desc).to.equal('IS_GRANTABLE'); - done(); - }); + it('returns privilege data for a table', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + // [catalog, schema, table] + sql.tablePriv(['', 'QIWS', 'QCUSTCDT']); + connection.add(sql.toXML()); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].tablepriv[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].tablepriv[0].row[0]; + expect(data[0].$.desc).to.equal('TABLE_CAT'); + expect(data[1].$.desc).to.equal('TABLE_SCHEM'); + expect(data[2].$.desc).to.equal('TABLE_NAME'); + expect(data[3].$.desc).to.equal('GRANTOR'); + expect(data[4].$.desc).to.equal('GRANTEE'); + expect(data[5].$.desc).to.equal('PRIVILEGE'); + expect(data[6].$.desc).to.equal('IS_GRANTABLE'); + done(); }); }); }); }); describe('columns', () => { - transports.forEach((transport) => { - it(`returns meta data for a column using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // catalog, schema, table, column - sql.columns(['', 'QIWS', 'QCUSTCDT', 'CUSNUM']); - connection.add(sql.toXML()); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].columns[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].columns[0].row[0]; - expect(data[0].$.desc).to.equal('TABLE_CAT'); - expect(data[1].$.desc).to.equal('TABLE_SCHEM'); - expect(data[2].$.desc).to.equal('TABLE_NAME'); - expect(data[3].$.desc).to.equal('COLUMN_NAME'); - expect(data[4].$.desc).to.equal('DATA_TYPE'); - expect(data[5].$.desc).to.equal('TYPE_NAME'); - expect(data[6].$.desc).to.equal('COLUMN_SIZE'); - expect(data[7].$.desc).to.equal('BUFFER_LENGTH'); - expect(data[8].$.desc).to.equal('DECIMAL_DIGITS'); - expect(data[9].$.desc).to.equal('NUM_PREC_RADIX'); - expect(data[10].$.desc).to.equal('NULLABLE'); - expect(data[11].$.desc).to.equal('REMARKS'); - expect(data[12].$.desc).to.equal('COLUMN_DEF'); - expect(data[13].$.desc).to.equal('SQL_DATA_TYPE'); - expect(data[14].$.desc).to.equal('SQL_DATETIME_SUB'); - expect(data[15].$.desc).to.equal('CHAR_OCTET_LENGTH'); - expect(data[16].$.desc).to.equal('ORDINAL_POSITION'); - expect(data[17].$.desc).to.equal('IS_NULLABLE'); - done(); - }); + it('returns meta data for a column', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + // catalog, schema, table, column + sql.columns(['', 'QIWS', 'QCUSTCDT', 'CUSNUM']); + connection.add(sql.toXML()); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].columns[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].columns[0].row[0]; + expect(data[0].$.desc).to.equal('TABLE_CAT'); + expect(data[1].$.desc).to.equal('TABLE_SCHEM'); + expect(data[2].$.desc).to.equal('TABLE_NAME'); + expect(data[3].$.desc).to.equal('COLUMN_NAME'); + expect(data[4].$.desc).to.equal('DATA_TYPE'); + expect(data[5].$.desc).to.equal('TYPE_NAME'); + expect(data[6].$.desc).to.equal('COLUMN_SIZE'); + expect(data[7].$.desc).to.equal('BUFFER_LENGTH'); + expect(data[8].$.desc).to.equal('DECIMAL_DIGITS'); + expect(data[9].$.desc).to.equal('NUM_PREC_RADIX'); + expect(data[10].$.desc).to.equal('NULLABLE'); + expect(data[11].$.desc).to.equal('REMARKS'); + expect(data[12].$.desc).to.equal('COLUMN_DEF'); + expect(data[13].$.desc).to.equal('SQL_DATA_TYPE'); + expect(data[14].$.desc).to.equal('SQL_DATETIME_SUB'); + expect(data[15].$.desc).to.equal('CHAR_OCTET_LENGTH'); + expect(data[16].$.desc).to.equal('ORDINAL_POSITION'); + expect(data[17].$.desc).to.equal('IS_NULLABLE'); + done(); }); }); }); }); describe('columnPriv', () => { - transports.forEach((transport) => { - it(`returns privilege data for a column using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - - sql.columnPriv(['', 'QIWS', 'QCUSTCDT', 'BALDUE']); - - connection.add(sql.toXML()); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].columnpriv[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].columnpriv[0].row[0]; - expect(data[0].$.desc).to.equal('TABLE_CAT'); - expect(data[1].$.desc).to.equal('TABLE_SCHEM'); - expect(data[2].$.desc).to.equal('TABLE_NAME'); - expect(data[3].$.desc).to.equal('COLUMN_NAME'); - expect(data[4].$.desc).to.equal('GRANTOR'); - expect(data[5].$.desc).to.equal('GRANTEE'); - expect(data[6].$.desc).to.equal('PRIVILEGE'); - expect(data[7].$.desc).to.equal('IS_GRANTABLE'); - done(); - }); + it('returns privilege data for a column', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + + sql.columnPriv(['', 'QIWS', 'QCUSTCDT', 'BALDUE']); + + connection.add(sql.toXML()); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].columnpriv[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].columnpriv[0].row[0]; + expect(data[0].$.desc).to.equal('TABLE_CAT'); + expect(data[1].$.desc).to.equal('TABLE_SCHEM'); + expect(data[2].$.desc).to.equal('TABLE_NAME'); + expect(data[3].$.desc).to.equal('COLUMN_NAME'); + expect(data[4].$.desc).to.equal('GRANTOR'); + expect(data[5].$.desc).to.equal('GRANTEE'); + expect(data[6].$.desc).to.equal('PRIVILEGE'); + expect(data[7].$.desc).to.equal('IS_GRANTABLE'); + done(); }); }); }); }); describe('procedures', () => { - transports.forEach((transport) => { - it(`returns meta data on for a procedure using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // [catalog, schema, procedure] - sql.procedures(['', 'QSYS2', 'TCPIP_INFO']); - connection.add(sql.toXML()); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].procedures[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].procedures[0].row[0]; - expect(data[0].$.desc).to.equal('PROCEDURE_CAT'); - expect(data[1].$.desc).to.equal('PROCEDURE_SCHEM'); - expect(data[2].$.desc).to.equal('PROCEDURE_NAME'); - expect(data[3].$.desc).to.equal('NUM_INPUT_PARAMS'); - expect(data[4].$.desc).to.equal('NUM_OUTPUT_PARAMS'); - expect(data[5].$.desc).to.equal('NUM_RESULT_SETS'); - expect(data[6].$.desc).to.equal('REMARKS'); - expect(data[7].$.desc).to.equal('PROCEDURE_TYPE'); - done(); - }); + it('returns meta data on for a procedure', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + // [catalog, schema, procedure] + sql.procedures(['', 'QSYS2', 'TCPIP_INFO']); + connection.add(sql.toXML()); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].procedures[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].procedures[0].row[0]; + expect(data[0].$.desc).to.equal('PROCEDURE_CAT'); + expect(data[1].$.desc).to.equal('PROCEDURE_SCHEM'); + expect(data[2].$.desc).to.equal('PROCEDURE_NAME'); + expect(data[3].$.desc).to.equal('NUM_INPUT_PARAMS'); + expect(data[4].$.desc).to.equal('NUM_OUTPUT_PARAMS'); + expect(data[5].$.desc).to.equal('NUM_RESULT_SETS'); + expect(data[6].$.desc).to.equal('REMARKS'); + expect(data[7].$.desc).to.equal('PROCEDURE_TYPE'); + done(); }); }); }); }); describe('pColumns', () => { - transports.forEach((transport) => { - it(`returns meta data for procedure column using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // [catalog, schema, procedure, column] - sql.pColumns(['', 'QSYS2', 'QCMDEXC', 'COMMAND']); - connection.add(sql.toXML()); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].pcolumns[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].pcolumns[0].row[0]; - expect(data[0].$.desc).to.equal('PROCEDURE_CAT'); - expect(data[1].$.desc).to.equal('PROCEDURE_SCHEM'); - expect(data[2].$.desc).to.equal('PROCEDURE_NAME'); - expect(data[3].$.desc).to.equal('COLUMN_NAME'); - expect(data[4].$.desc).to.equal('COLUMN_TYPE'); - expect(data[5].$.desc).to.equal('DATA_TYPE'); - expect(data[6].$.desc).to.equal('TYPE_NAME'); - expect(data[7].$.desc).to.equal('COLUMN_SIZE'); - expect(data[8].$.desc).to.equal('BUFFER_LENGTH'); - expect(data[9].$.desc).to.equal('DECIMAL_DIGITS'); - expect(data[10].$.desc).to.equal('NUM_PREC_RADIX'); - expect(data[11].$.desc).to.equal('NULLABLE'); - expect(data[12].$.desc).to.equal('REMARKS'); - expect(data[13].$.desc).to.equal('COLUMN_DEF'); - expect(data[14].$.desc).to.equal('SQL_DATA_TYPE'); - expect(data[15].$.desc).to.equal('SQL_DATETIME_SUB'); - expect(data[16].$.desc).to.equal('CHAR_OCTET_LENGTH'); - expect(data[17].$.desc).to.equal('ORDINAL_POSITION'); - expect(data[18].$.desc).to.equal('IS_NULLABLE'); - done(); - }); + it('returns meta data for procedure column', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + // [catalog, schema, procedure, column] + sql.pColumns(['', 'QSYS2', 'QCMDEXC', 'COMMAND']); + connection.add(sql.toXML()); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].pcolumns[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].pcolumns[0].row[0]; + expect(data[0].$.desc).to.equal('PROCEDURE_CAT'); + expect(data[1].$.desc).to.equal('PROCEDURE_SCHEM'); + expect(data[2].$.desc).to.equal('PROCEDURE_NAME'); + expect(data[3].$.desc).to.equal('COLUMN_NAME'); + expect(data[4].$.desc).to.equal('COLUMN_TYPE'); + expect(data[5].$.desc).to.equal('DATA_TYPE'); + expect(data[6].$.desc).to.equal('TYPE_NAME'); + expect(data[7].$.desc).to.equal('COLUMN_SIZE'); + expect(data[8].$.desc).to.equal('BUFFER_LENGTH'); + expect(data[9].$.desc).to.equal('DECIMAL_DIGITS'); + expect(data[10].$.desc).to.equal('NUM_PREC_RADIX'); + expect(data[11].$.desc).to.equal('NULLABLE'); + expect(data[12].$.desc).to.equal('REMARKS'); + expect(data[13].$.desc).to.equal('COLUMN_DEF'); + expect(data[14].$.desc).to.equal('SQL_DATA_TYPE'); + expect(data[15].$.desc).to.equal('SQL_DATETIME_SUB'); + expect(data[16].$.desc).to.equal('CHAR_OCTET_LENGTH'); + expect(data[17].$.desc).to.equal('ORDINAL_POSITION'); + expect(data[18].$.desc).to.equal('IS_NULLABLE'); + done(); }); }); }); }); describe('primaryKeys', () => { - transports.forEach((transport) => { - it(`returns meta data for a primary key using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // [catalog, schema, table] - sql.primaryKeys(['', 'QUSRSYS', 'QASZRAIRX']); - connection.add(sql.toXML()); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].primarykeys[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].primarykeys[0].row[0]; - expect(data[0].$.desc).to.equal('TABLE_CAT'); - expect(data[1].$.desc).to.equal('TABLE_SCHEM'); - expect(data[2].$.desc).to.equal('TABLE_NAME'); - expect(data[3].$.desc).to.equal('COLUMN_NAME'); - expect(data[4].$.desc).to.equal('KEY_SEQ'); - expect(data[5].$.desc).to.equal('PK_NAME'); - done(); - }); + it('returns meta data for a primary key', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + // [catalog, schema, table] + sql.primaryKeys(['', 'QUSRSYS', 'QASZRAIRX']); + connection.add(sql.toXML()); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].primarykeys[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].primarykeys[0].row[0]; + expect(data[0].$.desc).to.equal('TABLE_CAT'); + expect(data[1].$.desc).to.equal('TABLE_SCHEM'); + expect(data[2].$.desc).to.equal('TABLE_NAME'); + expect(data[3].$.desc).to.equal('COLUMN_NAME'); + expect(data[4].$.desc).to.equal('KEY_SEQ'); + expect(data[5].$.desc).to.equal('PK_NAME'); + done(); }); }); }); }); describe('foreignKeys', () => { - transports.forEach((transport) => { - it(`returns meta data for a foreign key using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // pk: [catalog, schema, table] - // fk: [catalog, schema, table] - sql.foreignKeys(['', 'QUSRSYS', 'QASZRAIRC', '', 'QUSRSYS', 'QASZRAIRX']); - connection.add(sql.toXML()); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].foreignkeys[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].foreignkeys[0].row[0]; - expect(data[0].$.desc).to.equal('PKTABLE_CAT'); - expect(data[1].$.desc).to.equal('PKTABLE_SCHEM'); - expect(data[2].$.desc).to.equal('PKTABLE_NAME'); - expect(data[3].$.desc).to.equal('PKCOLUMN_NAME'); - expect(data[4].$.desc).to.equal('FKTABLE_CAT'); - expect(data[5].$.desc).to.equal('FKTABLE_SCHEM'); - expect(data[6].$.desc).to.equal('FKTABLE_NAME'); - expect(data[7].$.desc).to.equal('FKCOLUMN_NAME'); - expect(data[8].$.desc).to.equal('KEY_SEQ'); - expect(data[9].$.desc).to.equal('UPDATE_RULE'); - expect(data[10].$.desc).to.equal('DELETE_RULE'); - expect(data[11].$.desc).to.equal('FK_NAME'); - expect(data[12].$.desc).to.equal('PK_NAME'); - expect(data[13].$.desc).to.equal('DEFERRABILITY'); - done(); - }); + it('returns meta data for a foreign key', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + // pk: [catalog, schema, table] + // fk: [catalog, schema, table] + sql.foreignKeys(['', 'QUSRSYS', 'QASZRAIRC', '', 'QUSRSYS', 'QASZRAIRX']); + connection.add(sql.toXML()); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].foreignkeys[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].foreignkeys[0].row[0]; + expect(data[0].$.desc).to.equal('PKTABLE_CAT'); + expect(data[1].$.desc).to.equal('PKTABLE_SCHEM'); + expect(data[2].$.desc).to.equal('PKTABLE_NAME'); + expect(data[3].$.desc).to.equal('PKCOLUMN_NAME'); + expect(data[4].$.desc).to.equal('FKTABLE_CAT'); + expect(data[5].$.desc).to.equal('FKTABLE_SCHEM'); + expect(data[6].$.desc).to.equal('FKTABLE_NAME'); + expect(data[7].$.desc).to.equal('FKCOLUMN_NAME'); + expect(data[8].$.desc).to.equal('KEY_SEQ'); + expect(data[9].$.desc).to.equal('UPDATE_RULE'); + expect(data[10].$.desc).to.equal('DELETE_RULE'); + expect(data[11].$.desc).to.equal('FK_NAME'); + expect(data[12].$.desc).to.equal('PK_NAME'); + expect(data[13].$.desc).to.equal('DEFERRABILITY'); + done(); }); }); }); }); describe('statistics', () => { - transports.forEach((transport) => { - it(`returns stats info for table using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - - sql.statistics(['', 'QIWS', 'QCUSTCDT', 'all']); - connection.add(sql.toXML()); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].statistics[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].statistics[0].row[0]; - expect(data[0].$.desc).to.equal('TABLE_CAT'); - expect(data[1].$.desc).to.equal('TABLE_SCHEM'); - expect(data[2].$.desc).to.equal('TABLE_NAME'); - expect(data[3].$.desc).to.equal('NON_UNIQUE'); - expect(data[4].$.desc).to.equal('INDEX_QUALIFIER'); - expect(data[5].$.desc).to.equal('INDEX_NAME'); - expect(data[6].$.desc).to.equal('TYPE'); - expect(data[7].$.desc).to.equal('ORDINAL_POSITION'); - expect(data[8].$.desc).to.equal('COLUMN_NAME'); - expect(data[9].$.desc).to.equal('ASC_OR_DESC'); - expect(data[10].$.desc).to.equal('CARDINALITY'); - expect(data[11].$.desc).to.equal('PAGES'); - expect(data[12].$.desc).to.equal('FILTER_CONDITION'); - done(); - }); + it('returns stats info for table', (done) => { + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + + sql.statistics(['', 'QIWS', 'QCUSTCDT', 'all']); + connection.add(sql.toXML()); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].statistics[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].statistics[0].row[0]; + expect(data[0].$.desc).to.equal('TABLE_CAT'); + expect(data[1].$.desc).to.equal('TABLE_SCHEM'); + expect(data[2].$.desc).to.equal('TABLE_NAME'); + expect(data[3].$.desc).to.equal('NON_UNIQUE'); + expect(data[4].$.desc).to.equal('INDEX_QUALIFIER'); + expect(data[5].$.desc).to.equal('INDEX_NAME'); + expect(data[6].$.desc).to.equal('TYPE'); + expect(data[7].$.desc).to.equal('ORDINAL_POSITION'); + expect(data[8].$.desc).to.equal('COLUMN_NAME'); + expect(data[9].$.desc).to.equal('ASC_OR_DESC'); + expect(data[10].$.desc).to.equal('CARDINALITY'); + expect(data[11].$.desc).to.equal('PAGES'); + expect(data[12].$.desc).to.equal('FILTER_CONDITION'); + done(); }); }); }); @@ -418,23 +405,21 @@ describe('iSql Functional Tests', () => { describe.skip('special', () => { // TODO: find passing case // Below test fails with error code 9- argument value not valid - transports.forEach((transport) => { - it.skip(`returns meta data for special columns using ${transport.name} transport`, (done) => { - // [catalog, schema, table, row | transaction |session, no | nullable] - const connection = transport.me; - - const sql = new iSql(); - - sql.special(['', 'QUSRSYS', 'QASZRAIRX', 'row', 'no'], { error: 'on' }); - connection.add(sql.toXML()); - connection.debug(true); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - // TODO add more assertions - expect(result).to.be.an('object'); - done(); - }); + it.skip('returns meta data for special columns', (done) => { + // [catalog, schema, table, row | transaction |session, no | nullable] + const connection = new iConn(database, username, password, restOptions); + + const sql = new iSql(); + + sql.special(['', 'QUSRSYS', 'QASZRAIRX', 'row', 'no'], { error: 'on' }); + connection.add(sql.toXML()); + connection.debug(true); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + // TODO add more assertions + expect(result).to.be.an('object'); + done(); }); }); }); @@ -442,28 +427,26 @@ describe('iSql Functional Tests', () => { describe.skip('rowCount', () => { // Skip for now need to create a table for this test to insert to. - transports.forEach((transport) => { - it.skip(`returns the number of rows affected by statement using ${transport.name} transport`, (done) => { - const connection = transport.me; + it.skip('returns the number of rows affected by statement', (done) => { + const connection = new iConn(database, username, password, restOptions); - const sql = new iSql(); + const sql = new iSql(); - const insert = 'INSERT INTO QIWS.QCUSTCDT (CUSNUM,LSTNAM,INIT,STREET,CITY,STATE,ZIPCOD,CDTLMT,CHGCOD,BALDUE,CDTDUE) ' + const insert = 'INSERT INTO QIWS.QCUSTCDT (CUSNUM,LSTNAM,INIT,STREET,CITY,STATE,ZIPCOD,CDTLMT,CHGCOD,BALDUE,CDTDUE) ' + 'VALUES (8798,\'TURNER\',\'TT\',\'MAIN\',\'NYC\',\'NY\',10001, 500, 3, 40.00, 0.00) with NONE'; - sql.addQuery(insert); - sql.rowCount(); - sql.free(); - connection.add(sql.toXML()); - connection.run((xmlOut) => { - parseString(xmlOut, (parseError, result) => { - const sqlNode = result.myscript.sql[0]; - expect(parseError).to.equal(null); - expect(sqlNode.query[0].success[0]).to.include('+++ success'); - expect(sqlNode.free[0].success[0]).to.include('+++ success'); - expect(sqlNode.rowcount[0]._).to.equal('1'); - done(); - }); + sql.addQuery(insert); + sql.rowCount(); + sql.free(); + connection.add(sql.toXML()); + connection.run((xmlOut) => { + parseString(xmlOut, (parseError, result) => { + const sqlNode = result.myscript.sql[0]; + expect(parseError).to.equal(null); + expect(sqlNode.query[0].success[0]).to.include('+++ success'); + expect(sqlNode.free[0].success[0]).to.include('+++ success'); + expect(sqlNode.rowcount[0]._).to.equal('1'); + done(); }); }); }); diff --git a/test/functional/deprecated/iUserSpaceFunctional.js b/test/functional/deprecated/iUserSpaceFunctional.js index b0829601..d46105e4 100644 --- a/test/functional/deprecated/iUserSpaceFunctional.js +++ b/test/functional/deprecated/iUserSpaceFunctional.js @@ -20,25 +20,37 @@ const { expect } = require('chai'); const { iConn, iUserSpace } = require('../../../lib/itoolkit'); -const { returnTransportsDeprecated } = require('../../../lib/utils'); - -// Set Env variables or set values here. -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT || 80, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', -}; +const { config, printConfig } = require('../config'); + +// deprecated tests are in place to test compatability using deprecated classes and functions +// these tests use deprecated iConn Class to create a connnection +// iConn only supported idb and rest transports +if (config.transport !== 'idb' && config.transport !== 'rest') { + throw new Error('Only idb and rest transports are available for deprecated tests'); +} + +const { database, username, password } = config.transportOptions; + +let restOptions = null; + +if (config.transport === 'rest') { + restOptions = { + hodt: config.host, + port: config.port || 80, + path: config.path, + }; +} const lib = 'NODETKTEST'; -const transports = returnTransportsDeprecated(opt); describe('iUserSpace Functional Tests', () => { + before(() => { + printConfig(); + }); + describe('constructor', () => { it('returns an instance of iUserSpace', () => { - const connection = new iConn(opt.database, opt.user, opt.password); + const connection = new iConn(database, config.user, password); const userSpace = new iUserSpace(connection); @@ -47,76 +59,67 @@ describe('iUserSpace Functional Tests', () => { }); describe('createUserSpace', () => { - transports.forEach((transport) => { - it(`creates a user space using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('creates a user space', (done) => { + const connection = new iConn(database, username, password, restOptions); - const userSpace = new iUserSpace(connection); + const userSpace = new iUserSpace(connection); - const description = 'Node toolkit test user space'; + const description = 'Node toolkit test user space'; - const userSpaceName = `USP${(transport.name).toUpperCase()}`; + const userSpaceName = `USP${(config.transport).toUpperCase()}`; - userSpace.createUserSpace(userSpaceName, lib, 'LOG', 50, '*EXCLUDE', - description, (output) => { - expect(output).to.be.a('boolean').and.to.equal(true); - done(); - }); - }); + userSpace.createUserSpace(userSpaceName, lib, 'LOG', 50, '*EXCLUDE', + description, (output) => { + expect(output).to.be.a('boolean').and.to.equal(true); + done(); + }); }); }); describe('setUserSpaceData', () => { - transports.forEach((transport) => { - it(`sets data within the user space using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('sets data within the user space', (done) => { + const connection = new iConn(database, username, password, restOptions); - const userSpace = new iUserSpace(connection); + const userSpace = new iUserSpace(connection); - const msg = 'Hello from userspace!'; + const msg = 'Hello from userspace!'; - const userSpaceName = `USP${(transport.name).toUpperCase()}`; + const userSpaceName = `USP${(config.transport).toUpperCase()}`; - userSpace.setUserSpaceData(userSpaceName, lib, msg.length, msg, - (output) => { - expect(output).to.be.a('boolean').and.to.equal(true); - done(); - }); - }); + userSpace.setUserSpaceData(userSpaceName, lib, msg.length, msg, + (output) => { + expect(output).to.be.a('boolean').and.to.equal(true); + done(); + }); }); }); describe('getUserSpaceData', () => { - transports.forEach((transport) => { - it(`returns specified length of data using ${transport.name} transport`, - (done) => { - const connection = transport.me; + it('returns specified length of data', (done) => { + const connection = new iConn(database, username, password, restOptions); - const userSpace = new iUserSpace(connection); + const userSpace = new iUserSpace(connection); - const userSpaceName = `USP${(transport.name).toUpperCase()}`; + const userSpaceName = `USP${(config.transport).toUpperCase()}`; - userSpace.getUserSpaceData(userSpaceName, lib, 21, (output) => { - expect(output).to.be.a('string').and.to.equal('Hello from userspace!'); - done(); - }); - }); + userSpace.getUserSpaceData(userSpaceName, lib, 21, (output) => { + expect(output).to.be.a('string').and.to.equal('Hello from userspace!'); + done(); + }); }); }); describe('deleteUserSpace', () => { - transports.forEach((transport) => { - it(`removes a user space using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('removes a user space', (done) => { + const connection = new iConn(database, username, password, restOptions); - const userSpace = new iUserSpace(connection); + const userSpace = new iUserSpace(connection); - const userSpaceName = `USP${(transport.name).toUpperCase()}`; + const userSpaceName = `USP${(config.transport).toUpperCase()}`; - userSpace.deleteUserSpace(userSpaceName, lib, (output) => { - expect(output).to.be.a('boolean').and.to.equal(true); - done(); - }); + userSpace.deleteUserSpace(userSpaceName, lib, (output) => { + expect(output).to.be.a('boolean').and.to.equal(true); + done(); }); }); }); diff --git a/test/functional/deprecated/iWorkFunctional.js b/test/functional/deprecated/iWorkFunctional.js index 9960289b..b7daafcd 100644 --- a/test/functional/deprecated/iWorkFunctional.js +++ b/test/functional/deprecated/iWorkFunctional.js @@ -20,24 +20,36 @@ const { expect } = require('chai'); const { iConn, iWork } = require('../../../lib/itoolkit'); -const { returnTransportsDeprecated } = require('../../../lib/utils'); +const { config, printConfig } = require('../config'); +const { checkObjectExists } = require('../checkObjectExists'); -// Set Env variables or set values here. -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT || 80, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', -}; +// deprecated tests are in place to test compatability using deprecated classes and functions +// these tests use deprecated iConn Class to create a connnection +// iConn only supported idb and rest transports +if (config.transport !== 'idb' && config.transport !== 'rest') { + throw new Error('Only idb and rest transports are available for deprecated tests'); +} -const transports = returnTransportsDeprecated(opt); +const { database, username, password } = config.transportOptions; + +let restOptions = null; + +if (config.transport === 'rest') { + restOptions = { + hodt: config.host, + port: config.port || 80, + path: config.path, + }; +} describe('iWork Functional Tests', () => { + before(() => { + printConfig(); + }); + describe('constructor', () => { it('creates and returns an instance of iWork', () => { - const connection = new iConn(opt.database, opt.user, opt.password); + const connection = new iConn(database, config.user, password); const work = new iWork(connection); @@ -46,225 +58,177 @@ describe('iWork Functional Tests', () => { }); describe('getSysValue', () => { - transports.forEach((transport) => { - it(`returns the value of system variable using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('returns the value of system variable', (done) => { + const connection = new iConn(database, username, password, restOptions); - const work = new iWork(connection); + const work = new iWork(connection); - work.getSysValue('QCENTURY', (output) => { - expect(output).to.be.a('string').and.to.equal('1'); - done(); - }); + work.getSysValue('QCENTURY', (output) => { + expect(output).to.be.a('string').and.to.equal('1'); + done(); }); }); }); describe('getSysStatus', () => { - transports.forEach((transport) => { - it('returns basic system status information about the signed-on users ' - + `and batch jobs using ${transport.name} transport`, - (done) => { - const connection = transport.me; - const work = new iWork(connection); + it('returns basic system status information about the signed-on users ' + + 'and batch jobs', + (done) => { + const connection = new iConn(database, username, password, restOptions); + const work = new iWork(connection); - work.getSysStatus((output) => { - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Current_date_and_time'); - expect(output).to.have.a.property('System_name'); - expect(output).to.have.a.property('Users_currently_signed_on'); - expect(output).to.have.a.property('Users_temporarily_signed_off_(disconnected)'); - expect(output).to.have.a.property('Users_suspended_by_system_request'); - expect(output).to.have.a.property('Users_suspended_by_group_jobs'); - expect(output).to.have.a.property('Users_signed_off_with_printer_output_waiting_to_print'); - expect(output).to.have.a.property('Batch_jobs_waiting_for_messages'); - expect(output).to.have.a.property('Batch_jobs_running'); - expect(output).to.have.a.property('Batch_jobs_held_while_running'); - expect(output).to.have.a.property('Batch_jobs_ending'); - expect(output).to.have.a.property('Batch_jobs_waiting_to_run_or_already_scheduled'); - expect(output).to.have.a.property('Batch_jobs_held_on_a_job_queue'); - expect(output).to.have.a.property('Batch_jobs_on_a_held_job_queue'); - expect(output).to.have.a.property('Batch_jobs_on_an_unassigned_job_queue'); - expect(output).to.have.a.property('Batch_jobs_ended_with_printer_output_waiting_to_print'); - done(); - }); + work.getSysStatus((output) => { + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Current_date_and_time'); + expect(output).to.have.a.property('System_name'); + expect(output).to.have.a.property('Users_currently_signed_on'); + expect(output).to.have.a.property('Users_temporarily_signed_off_(disconnected)'); + expect(output).to.have.a.property('Users_suspended_by_system_request'); + expect(output).to.have.a.property('Users_suspended_by_group_jobs'); + expect(output).to.have.a.property('Users_signed_off_with_printer_output_waiting_to_print'); + expect(output).to.have.a.property('Batch_jobs_waiting_for_messages'); + expect(output).to.have.a.property('Batch_jobs_running'); + expect(output).to.have.a.property('Batch_jobs_held_while_running'); + expect(output).to.have.a.property('Batch_jobs_ending'); + expect(output).to.have.a.property('Batch_jobs_waiting_to_run_or_already_scheduled'); + expect(output).to.have.a.property('Batch_jobs_held_on_a_job_queue'); + expect(output).to.have.a.property('Batch_jobs_on_a_held_job_queue'); + expect(output).to.have.a.property('Batch_jobs_on_an_unassigned_job_queue'); + expect(output).to.have.a.property('Batch_jobs_ended_with_printer_output_waiting_to_print'); + done(); }); }); }); describe('getSysStatusExt', () => { - transports.forEach((transport) => { - it(`returns more detailed system status info using ${transport.name} transport`, - (done) => { - const connection = transport.me; + it('returns more detailed system status info', + (done) => { + const connection = new iConn(database, username, password, restOptions); - const work = new iWork(connection); + const work = new iWork(connection); - work.getSysStatusExt((output) => { - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Current_date_and_time'); - expect(output).to.have.a.property('System_name'); - expect(output).to.have.a.property('Elapsed_time'); - expect(output).to.have.a.property('Restricted_state_flag'); - expect(output).to.have.a.property('%_processing_unit_used'); - expect(output).to.have.a.property('Jobs_in_system'); - expect(output).to.have.a.property('%_permanent_addresses'); - expect(output).to.have.a.property('%_temporary_addresses'); - expect(output).to.have.a.property('System_ASP'); - expect(output).to.have.a.property('%_system_ASP_used'); - expect(output).to.have.a.property('Total_auxiliary_storage'); - expect(output).to.have.a.property('Current_unprotected_storage_used'); - expect(output).to.have.a.property('Maximum_unprotected_storage_used'); - expect(output).to.have.a.property('%_DB_capability'); - expect(output).to.have.a.property('Main_storage_size'); - expect(output).to.have.a.property('Number_of_partitions'); - expect(output).to.have.a.property('Partition_identifier'); - expect(output).to.have.a.property('Current_processing_capacity'); - expect(output).to.have.a.property('Processor_sharing_attribute'); - expect(output).to.have.a.property('Number_of_processors'); - expect(output).to.have.a.property('Active_jobs_in_system'); - expect(output).to.have.a.property('Active_threads_in_system'); - expect(output).to.have.a.property('Maximum_jobs_in_system'); - expect(output).to.have.a.property('%_temporary_256MB_segments_used'); - expect(output).to.have.a.property('%_temporary_4GB_segments_used'); - expect(output).to.have.a.property('%_permanent_256MB_segments_used'); - expect(output).to.have.a.property('%_permanent_4GB_segments_used'); - expect(output).to.have.a.property('%_current_interactive_performance'); - expect(output).to.have.a.property('%_uncapped_CPU_capacity_used'); - expect(output).to.have.a.property('%_shared_processor_pool_used'); - expect(output).to.have.a.property('Main_storage_size_(long)'); - done(); - }); + work.getSysStatusExt((output) => { + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Current_date_and_time'); + expect(output).to.have.a.property('System_name'); + expect(output).to.have.a.property('Elapsed_time'); + expect(output).to.have.a.property('Restricted_state_flag'); + expect(output).to.have.a.property('%_processing_unit_used'); + expect(output).to.have.a.property('Jobs_in_system'); + expect(output).to.have.a.property('%_permanent_addresses'); + expect(output).to.have.a.property('%_temporary_addresses'); + expect(output).to.have.a.property('System_ASP'); + expect(output).to.have.a.property('%_system_ASP_used'); + expect(output).to.have.a.property('Total_auxiliary_storage'); + expect(output).to.have.a.property('Current_unprotected_storage_used'); + expect(output).to.have.a.property('Maximum_unprotected_storage_used'); + expect(output).to.have.a.property('%_DB_capability'); + expect(output).to.have.a.property('Main_storage_size'); + expect(output).to.have.a.property('Number_of_partitions'); + expect(output).to.have.a.property('Partition_identifier'); + expect(output).to.have.a.property('Current_processing_capacity'); + expect(output).to.have.a.property('Processor_sharing_attribute'); + expect(output).to.have.a.property('Number_of_processors'); + expect(output).to.have.a.property('Active_jobs_in_system'); + expect(output).to.have.a.property('Active_threads_in_system'); + expect(output).to.have.a.property('Maximum_jobs_in_system'); + expect(output).to.have.a.property('%_temporary_256MB_segments_used'); + expect(output).to.have.a.property('%_temporary_4GB_segments_used'); + expect(output).to.have.a.property('%_permanent_256MB_segments_used'); + expect(output).to.have.a.property('%_permanent_4GB_segments_used'); + expect(output).to.have.a.property('%_current_interactive_performance'); + expect(output).to.have.a.property('%_uncapped_CPU_capacity_used'); + expect(output).to.have.a.property('%_shared_processor_pool_used'); + expect(output).to.have.a.property('Main_storage_size_(long)'); + done(); }); - }); + }); }); describe('getJobStatus', () => { - transports.forEach((transport) => { - it(`returns status of specified job using ${transport.name} transport`, - (done) => { - const connection = transport.me; - - const work = new iWork(connection); - - work.getJobStatus('000000', (output) => { - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Job_status'); - expect(output).to.have.a.property('Fully_qualified_job_name'); - done(); - }); - }); - }); - }); - - describe('getJobInfo', () => { - transports.forEach((transport) => { - it(`returns info on specfed job using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('returns status of specified job', + (done) => { + const connection = new iConn(database, username, password, restOptions); const work = new iWork(connection); - work.getJobInfo('SCPF', 'QSYS', '000000', (output) => { + work.getJobStatus('000000', (output) => { expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Job_name'); - expect(output).to.have.a.property('User_name'); - expect(output).to.have.a.property('Job_number'); expect(output).to.have.a.property('Job_status'); - expect(output).to.have.a.property('Job_type'); - expect(output).to.have.a.property('Job_subtype'); - expect(output).to.have.a.property('Subsystem_description_name'); - expect(output).to.have.a.property('Run_priority_(job)'); - expect(output).to.have.a.property('System_pool_identifier'); - expect(output).to.have.a.property('Processing_unit_time_used,_if_less_than_2,147,483,647_milliseconds'); - expect(output).to.have.a.property('Number_of_auxiliary_I/O_requests,_if_less_than_2,147,483,647'); - expect(output).to.have.a.property('Number_of_interactive_transactions'); - expect(output).to.have.a.property('Response_time_total'); - expect(output).to.have.a.property('Function_type'); - expect(output).to.have.a.property('Function_name'); - expect(output).to.have.a.property('Active_job_status'); - expect(output).to.have.a.property('Number_of_database_lock_waits'); - expect(output).to.have.a.property('Number_of_internal_machine_lock_waits'); - expect(output).to.have.a.property('Number_of_nondatabase_lock_waits'); - expect(output).to.have.a.property('Time_spent_on_database_lock_waits'); - expect(output).to.have.a.property('Time_spent_on_internal_machine_lock_waits'); - expect(output).to.have.a.property('Time_spent_on_nondatabase_lock_waits'); - expect(output).to.have.a.property('Current_system_pool_identifier'); - expect(output).to.have.a.property('Thread_count'); - expect(output).to.have.a.property('Processing_unit_time_used_-_total_for_the_job'); - expect(output).to.have.a.property('Number_of_auxiliary_I/O_requests'); - expect(output).to.have.a.property('Processing_unit_time_used_for_database_-_total_for_the_job'); - expect(output).to.have.a.property('Page_faults'); - expect(output).to.have.a.property('Active_job_status_for_jobs_ending'); - expect(output).to.have.a.property('Memory_pool_name'); - expect(output).to.have.a.property('Message_reply'); - expect(output).to.have.a.property('Message_key,_when_active_job_waiting_for_a_message'); - expect(output).to.have.a.property('Message_queue_name,_when_active_job_waiting_for_a_message'); - expect(output).to.have.a.property('Message_queue_library_name,_when_active_job_waiting_for_a_message'); - expect(output).to.have.a.property('Message_queue_library_ASP_device_name,_when_active_job_waiting_for_a_message'); + expect(output).to.have.a.property('Fully_qualified_job_name'); done(); }); }); - }); }); - describe('getDataArea', () => { - before('init lib, data area, and add data', async () => { - // eslint-disable-next-line global-require - const { DBPool } = require('idb-pconnector'); - const pool = new DBPool({ url: '*LOCAL' }, { incrementSize: 2 }); - - const qcmdexec = 'CALL QSYS2.QCMDEXC(?)'; - const lib = 'NODETKTEST'; - const dataArea = 'TESTDA'; - - const createLib = `CRTLIB LIB(${lib}) TYPE(*TEST) TEXT('Used to test' Node.js toolkit')`; - - const createDataArea = `CRTDTAARA DTAARA(${lib}/${dataArea}) TYPE(*CHAR) ` - + 'TEXT(\'TEST DATA AREA FOR NODE TOOLKIT\') ' - + 'VALUE(\'Hello From Test Data Area!\')'; - - const findLib = 'SELECT SCHEMA_NAME FROM qsys2.sysschemas WHERE SCHEMA_NAME = \'NODETKTEST\''; - - const findDataArea = `SELECT OBJNAME FROM TABLE (QSYS2.OBJECT_STATISTICS('${lib}', '*DTAARA')) AS X`; + describe('getJobInfo', () => { + it('returns info on specfed job', (done) => { + const connection = new iConn(database, username, password, restOptions); - const libResult = await pool.runSql(findLib); + const work = new iWork(connection); - const dataAreaResult = await pool.runSql(findDataArea); + work.getJobInfo('SCPF', 'QSYS', '000000', (output) => { + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Job_name'); + expect(output).to.have.a.property('User_name'); + expect(output).to.have.a.property('Job_number'); + expect(output).to.have.a.property('Job_status'); + expect(output).to.have.a.property('Job_type'); + expect(output).to.have.a.property('Job_subtype'); + expect(output).to.have.a.property('Subsystem_description_name'); + expect(output).to.have.a.property('Run_priority_(job)'); + expect(output).to.have.a.property('System_pool_identifier'); + expect(output).to.have.a.property('Processing_unit_time_used,_if_less_than_2,147,483,647_milliseconds'); + expect(output).to.have.a.property('Number_of_auxiliary_I/O_requests,_if_less_than_2,147,483,647'); + expect(output).to.have.a.property('Number_of_interactive_transactions'); + expect(output).to.have.a.property('Response_time_total'); + expect(output).to.have.a.property('Function_type'); + expect(output).to.have.a.property('Function_name'); + expect(output).to.have.a.property('Active_job_status'); + expect(output).to.have.a.property('Number_of_database_lock_waits'); + expect(output).to.have.a.property('Number_of_internal_machine_lock_waits'); + expect(output).to.have.a.property('Number_of_nondatabase_lock_waits'); + expect(output).to.have.a.property('Time_spent_on_database_lock_waits'); + expect(output).to.have.a.property('Time_spent_on_internal_machine_lock_waits'); + expect(output).to.have.a.property('Time_spent_on_nondatabase_lock_waits'); + expect(output).to.have.a.property('Current_system_pool_identifier'); + expect(output).to.have.a.property('Thread_count'); + expect(output).to.have.a.property('Processing_unit_time_used_-_total_for_the_job'); + expect(output).to.have.a.property('Number_of_auxiliary_I/O_requests'); + expect(output).to.have.a.property('Processing_unit_time_used_for_database_-_total_for_the_job'); + expect(output).to.have.a.property('Page_faults'); + expect(output).to.have.a.property('Active_job_status_for_jobs_ending'); + expect(output).to.have.a.property('Memory_pool_name'); + expect(output).to.have.a.property('Message_reply'); + expect(output).to.have.a.property('Message_key,_when_active_job_waiting_for_a_message'); + expect(output).to.have.a.property('Message_queue_name,_when_active_job_waiting_for_a_message'); + expect(output).to.have.a.property('Message_queue_library_name,_when_active_job_waiting_for_a_message'); + expect(output).to.have.a.property('Message_queue_library_ASP_device_name,_when_active_job_waiting_for_a_message'); + done(); + }); + }); + }); - if (!libResult.length) { - await pool.prepareExecute(qcmdexec, [createLib]).catch((error) => { - // eslint-disable-next-line no-console - console.log('Unable to Create Lib!'); - throw error; - }); - // eslint-disable-next-line no-console - console.log('CREATED LIB!'); - } - if (!dataAreaResult.length) { - await pool.prepareExecute(qcmdexec, [createDataArea]).catch((error) => { - // eslint-disable-next-line no-console - console.log('Unable to Create DA!'); - throw error; - }); - // eslint-disable-next-line no-console - console.log('CREATED DA!'); - } + describe('getDataArea', () => { + before('init lib, data area, and add data', (done) => { + checkObjectExists(config, '*DTAARA', (error) => { + if (error) { throw error; } + done(); + }); }); - transports.forEach((transport) => { - it(`returns contents of a data area using ${transport.name} transport`, (done) => { - const connection = transport.me; + it('returns contents of a data area', (done) => { + const connection = new iConn(database, username, password, restOptions); - const work = new iWork(connection); + const work = new iWork(connection); - work.getDataArea('NODETKTEST', 'TESTDA', 20, (output) => { - expect(output).to.be.an('Object'); - expect(output).to.have.a.property('Type_of_value_returned'); - expect(output).to.have.a.property('Library_name'); - expect(output).to.have.a.property('Length_of_value_returned'); - expect(output).to.have.a.property('Number_of_decimal_positions'); - expect(output).to.have.a.property('Value'); - done(); - }); + work.getDataArea('NODETKTEST', 'TESTDA', 20, (output) => { + expect(output).to.be.an('Object'); + expect(output).to.have.a.property('Type_of_value_returned'); + expect(output).to.have.a.property('Library_name'); + expect(output).to.have.a.property('Length_of_value_returned'); + expect(output).to.have.a.property('Number_of_decimal_positions'); + expect(output).to.have.a.property('Value'); + done(); }); }); }); diff --git a/test/functional/iSqlFunctional.js b/test/functional/iSqlFunctional.js index 69b2dfda..b6136920 100644 --- a/test/functional/iSqlFunctional.js +++ b/test/functional/iSqlFunctional.js @@ -20,417 +20,376 @@ const { expect } = require('chai'); const { parseString } = require('xml2js'); -const { readFileSync } = require('fs'); -const { iSql } = require('../../lib/itoolkit'); -const { returnTransports } = require('../../lib/utils'); - -// Set Env variables or set values here. -let privateKey; -if (process.env.TKPK) { - privateKey = readFileSync(process.env.TKPK, 'utf-8'); -} -const opt = { - database: process.env.TKDB || '*LOCAL', - username: process.env.TKUSER || '', - password: process.env.TKPASS || '', - host: process.env.TKHOST || 'localhost', - port: process.env.TKPORT, - path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm', - privateKey, - passphrase: process.env.TKPHRASE, - verbose: !!process.env.TKVERBOSE, - dsn: process.env.TKDSN, -}; - -const transports = returnTransports(opt); +const { iSql, Connection } = require('../../lib/itoolkit'); +const { config, printConfig } = require('./config'); describe('iSql Functional Tests', () => { + before(() => { + printConfig(); + }); + describe('prepare & execute', () => { - transports.forEach((transport) => { - it(`prepares & executes stored procedure then fetch results using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - - sql.prepare('call qsys2.tcpip_info()'); - sql.execute(); - sql.fetch(); - sql.free(); - connection.add(sql); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - const sqlNode = result.myscript.sql[0]; - expect(sqlNode.prepare[0].success[0]).to.include('+++ success'); - expect(sqlNode.execute[0].success[0]).to.include('+++ success'); - expect(sqlNode.fetch[0].success[0]).to.include('+++ success'); - expect(sqlNode.free[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].fetch[0].row[0]; - expect(data[0].$.desc).to.equal('HOSTNAME'); - expect(data[1].$.desc).to.equal('VRM'); - expect(data[2].$.desc).to.equal('DBGROUP'); - expect(data[3].$.desc).to.equal('IPTYPE'); - expect(data[4].$.desc).to.equal('IPADDR'); - expect(data[5].$.desc).to.equal('PORT'); - done(); - }); + it('prepares & executes stored procedure then fetch results', (done) => { + const connection = new Connection(config); + + const sql = new iSql(); + + sql.prepare('call qsys2.tcpip_info()'); + sql.execute(); + sql.fetch(); + sql.free(); + connection.add(sql); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + const sqlNode = result.myscript.sql[0]; + expect(sqlNode.prepare[0].success[0]).to.include('+++ success'); + expect(sqlNode.execute[0].success[0]).to.include('+++ success'); + expect(sqlNode.fetch[0].success[0]).to.include('+++ success'); + expect(sqlNode.free[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].fetch[0].row[0]; + expect(data[0].$.desc).to.equal('HOSTNAME'); + expect(data[1].$.desc).to.equal('VRM'); + expect(data[2].$.desc).to.equal('DBGROUP'); + expect(data[3].$.desc).to.equal('IPTYPE'); + expect(data[4].$.desc).to.equal('IPADDR'); + expect(data[5].$.desc).to.equal('PORT'); + done(); }); }); }); }); describe('addQuery & fetch', () => { - transports.forEach((transport) => { - it(`runs a query and fetches results using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - - sql.addQuery('SELECT LSTNAM, STATE FROM QIWS.QCUSTCDT'); - sql.fetch(); - sql.free(); - connection.add(sql); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - const sqlNode = result.myscript.sql[0]; - expect(sqlNode.query[0].success[0]).to.include('+++ success'); - expect(sqlNode.fetch[0].success[0]).to.include('+++ success'); - expect(sqlNode.free[0].success[0]).to.include('+++ success'); - expect(sqlNode.fetch[0].row[0].data[0].$.desc).to.equal('LSTNAM'); - expect(sqlNode.fetch[0].row[0].data[1].$.desc).to.equal('STATE'); - done(); - }); + it('runs a query and fetches results', (done) => { + const connection = new Connection(config); + + const sql = new iSql(); + + sql.addQuery('SELECT LSTNAM, STATE FROM QIWS.QCUSTCDT'); + sql.fetch(); + sql.free(); + connection.add(sql); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + const sqlNode = result.myscript.sql[0]; + expect(sqlNode.query[0].success[0]).to.include('+++ success'); + expect(sqlNode.fetch[0].success[0]).to.include('+++ success'); + expect(sqlNode.free[0].success[0]).to.include('+++ success'); + expect(sqlNode.fetch[0].row[0].data[0].$.desc).to.equal('LSTNAM'); + expect(sqlNode.fetch[0].row[0].data[1].$.desc).to.equal('STATE'); + done(); }); }); }); }); describe('added test to ensure issue #11 was resolved', () => { - transports.forEach((transport) => { - it(`should parse SQL result set empty data tags correctly using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - - sql.addQuery('SELECT \'\' AS BLANK, STATE FROM QIWS.QCUSTCDT'); - sql.fetch(); - sql.free(); - connection.add(sql); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - const sqlNode = result.myscript.sql[0]; - expect(sqlNode.query[0].success[0]).to.include('+++ success'); - expect(sqlNode.fetch[0].success[0]).to.include('+++ success'); - expect(sqlNode.free[0].success[0]).to.include('+++ success'); - expect(sqlNode.fetch[0].row[0].data[0].$.desc).to.equal('BLANK'); - // xml2js no inner data gets parsed as undefined. - expect(sqlNode.fetch[0].row[0].data[0]._).to.equal(undefined); - done(); - }); + it('should parse SQL result set empty data tags correctly', (done) => { + const connection = new Connection(config); + + const sql = new iSql(); + + sql.addQuery('SELECT \'\' AS BLANK, STATE FROM QIWS.QCUSTCDT'); + sql.fetch(); + sql.free(); + connection.add(sql); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + const sqlNode = result.myscript.sql[0]; + expect(sqlNode.query[0].success[0]).to.include('+++ success'); + expect(sqlNode.fetch[0].success[0]).to.include('+++ success'); + expect(sqlNode.free[0].success[0]).to.include('+++ success'); + expect(sqlNode.fetch[0].row[0].data[0].$.desc).to.equal('BLANK'); + // xml2js no inner data gets parsed as undefined. + expect(sqlNode.fetch[0].row[0].data[0]._).to.equal(undefined); + done(); }); }); }); }); describe('tables', () => { - transports.forEach((transport) => { - it(`returns meta data for specified table using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // [catalog, schema, table, table type] - sql.tables(['', 'QIWS', 'QCUSTCDT', '']); - connection.add(sql.toXML()); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].tables[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].tables[0].row[0]; - expect(data[0].$.desc).to.equal('TABLE_CAT'); - expect(data[1].$.desc).to.equal('TABLE_SCHEM'); - expect(data[2].$.desc).to.equal('TABLE_NAME'); - expect(data[3].$.desc).to.equal('TABLE_TYPE'); - expect(data[4].$.desc).to.equal('REMARKS'); - done(); - }); + it('returns meta data for specified table', (done) => { + const connection = new Connection(config); + + const sql = new iSql(); + // [catalog, schema, table, table type] + sql.tables(['', 'QIWS', 'QCUSTCDT', '']); + connection.add(sql.toXML()); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].tables[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].tables[0].row[0]; + expect(data[0].$.desc).to.equal('TABLE_CAT'); + expect(data[1].$.desc).to.equal('TABLE_SCHEM'); + expect(data[2].$.desc).to.equal('TABLE_NAME'); + expect(data[3].$.desc).to.equal('TABLE_TYPE'); + expect(data[4].$.desc).to.equal('REMARKS'); + done(); }); }); }); }); describe('tablePriv', () => { - transports.forEach((transport) => { - it(`returns privilege data for a table using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // [catalog, schema, table] - sql.tablePriv(['', 'QIWS', 'QCUSTCDT']); - connection.add(sql.toXML()); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].tablepriv[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].tablepriv[0].row[0]; - expect(data[0].$.desc).to.equal('TABLE_CAT'); - expect(data[1].$.desc).to.equal('TABLE_SCHEM'); - expect(data[2].$.desc).to.equal('TABLE_NAME'); - expect(data[3].$.desc).to.equal('GRANTOR'); - expect(data[4].$.desc).to.equal('GRANTEE'); - expect(data[5].$.desc).to.equal('PRIVILEGE'); - expect(data[6].$.desc).to.equal('IS_GRANTABLE'); - done(); - }); + it('returns privilege data for a table', (done) => { + const connection = new Connection(config); + + const sql = new iSql(); + // [catalog, schema, table] + sql.tablePriv(['', 'QIWS', 'QCUSTCDT']); + connection.add(sql.toXML()); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].tablepriv[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].tablepriv[0].row[0]; + expect(data[0].$.desc).to.equal('TABLE_CAT'); + expect(data[1].$.desc).to.equal('TABLE_SCHEM'); + expect(data[2].$.desc).to.equal('TABLE_NAME'); + expect(data[3].$.desc).to.equal('GRANTOR'); + expect(data[4].$.desc).to.equal('GRANTEE'); + expect(data[5].$.desc).to.equal('PRIVILEGE'); + expect(data[6].$.desc).to.equal('IS_GRANTABLE'); + done(); }); }); }); }); describe('columns', () => { - transports.forEach((transport) => { - it(`returns meta data for a column using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // catalog, schema, table, column - sql.columns(['', 'QIWS', 'QCUSTCDT', 'CUSNUM']); - connection.add(sql.toXML()); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].columns[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].columns[0].row[0]; - expect(data[0].$.desc).to.equal('TABLE_CAT'); - expect(data[1].$.desc).to.equal('TABLE_SCHEM'); - expect(data[2].$.desc).to.equal('TABLE_NAME'); - expect(data[3].$.desc).to.equal('COLUMN_NAME'); - expect(data[4].$.desc).to.equal('DATA_TYPE'); - expect(data[5].$.desc).to.equal('TYPE_NAME'); - expect(data[6].$.desc).to.equal('COLUMN_SIZE'); - expect(data[7].$.desc).to.equal('BUFFER_LENGTH'); - expect(data[8].$.desc).to.equal('DECIMAL_DIGITS'); - expect(data[9].$.desc).to.equal('NUM_PREC_RADIX'); - expect(data[10].$.desc).to.equal('NULLABLE'); - expect(data[11].$.desc).to.equal('REMARKS'); - expect(data[12].$.desc).to.equal('COLUMN_DEF'); - expect(data[13].$.desc).to.equal('SQL_DATA_TYPE'); - expect(data[14].$.desc).to.equal('SQL_DATETIME_SUB'); - expect(data[15].$.desc).to.equal('CHAR_OCTET_LENGTH'); - expect(data[16].$.desc).to.equal('ORDINAL_POSITION'); - expect(data[17].$.desc).to.equal('IS_NULLABLE'); - done(); - }); + it('returns meta data for a column', (done) => { + const connection = new Connection(config); + + const sql = new iSql(); + // catalog, schema, table, column + sql.columns(['', 'QIWS', 'QCUSTCDT', 'CUSNUM']); + connection.add(sql.toXML()); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].columns[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].columns[0].row[0]; + expect(data[0].$.desc).to.equal('TABLE_CAT'); + expect(data[1].$.desc).to.equal('TABLE_SCHEM'); + expect(data[2].$.desc).to.equal('TABLE_NAME'); + expect(data[3].$.desc).to.equal('COLUMN_NAME'); + expect(data[4].$.desc).to.equal('DATA_TYPE'); + expect(data[5].$.desc).to.equal('TYPE_NAME'); + expect(data[6].$.desc).to.equal('COLUMN_SIZE'); + expect(data[7].$.desc).to.equal('BUFFER_LENGTH'); + expect(data[8].$.desc).to.equal('DECIMAL_DIGITS'); + expect(data[9].$.desc).to.equal('NUM_PREC_RADIX'); + expect(data[10].$.desc).to.equal('NULLABLE'); + expect(data[11].$.desc).to.equal('REMARKS'); + expect(data[12].$.desc).to.equal('COLUMN_DEF'); + expect(data[13].$.desc).to.equal('SQL_DATA_TYPE'); + expect(data[14].$.desc).to.equal('SQL_DATETIME_SUB'); + expect(data[15].$.desc).to.equal('CHAR_OCTET_LENGTH'); + expect(data[16].$.desc).to.equal('ORDINAL_POSITION'); + expect(data[17].$.desc).to.equal('IS_NULLABLE'); + done(); }); }); }); }); describe('columnPriv', () => { - transports.forEach((transport) => { - it(`returns privilege data for a column using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - - sql.columnPriv(['', 'QIWS', 'QCUSTCDT', 'BALDUE']); - - connection.add(sql.toXML()); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].columnpriv[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].columnpriv[0].row[0]; - expect(data[0].$.desc).to.equal('TABLE_CAT'); - expect(data[1].$.desc).to.equal('TABLE_SCHEM'); - expect(data[2].$.desc).to.equal('TABLE_NAME'); - expect(data[3].$.desc).to.equal('COLUMN_NAME'); - expect(data[4].$.desc).to.equal('GRANTOR'); - expect(data[5].$.desc).to.equal('GRANTEE'); - expect(data[6].$.desc).to.equal('PRIVILEGE'); - expect(data[7].$.desc).to.equal('IS_GRANTABLE'); - done(); - }); + it('returns privilege data for a column', (done) => { + const connection = new Connection(config); + + const sql = new iSql(); + + sql.columnPriv(['', 'QIWS', 'QCUSTCDT', 'BALDUE']); + + connection.add(sql.toXML()); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].columnpriv[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].columnpriv[0].row[0]; + expect(data[0].$.desc).to.equal('TABLE_CAT'); + expect(data[1].$.desc).to.equal('TABLE_SCHEM'); + expect(data[2].$.desc).to.equal('TABLE_NAME'); + expect(data[3].$.desc).to.equal('COLUMN_NAME'); + expect(data[4].$.desc).to.equal('GRANTOR'); + expect(data[5].$.desc).to.equal('GRANTEE'); + expect(data[6].$.desc).to.equal('PRIVILEGE'); + expect(data[7].$.desc).to.equal('IS_GRANTABLE'); + done(); }); }); }); }); describe('procedures', () => { - transports.forEach((transport) => { - it(`returns meta data on for a procedure using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // [catalog, schema, procedure] - sql.procedures(['', 'QSYS2', 'TCPIP_INFO']); - connection.add(sql.toXML()); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].procedures[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].procedures[0].row[0]; - expect(data[0].$.desc).to.equal('PROCEDURE_CAT'); - expect(data[1].$.desc).to.equal('PROCEDURE_SCHEM'); - expect(data[2].$.desc).to.equal('PROCEDURE_NAME'); - expect(data[3].$.desc).to.equal('NUM_INPUT_PARAMS'); - expect(data[4].$.desc).to.equal('NUM_OUTPUT_PARAMS'); - expect(data[5].$.desc).to.equal('NUM_RESULT_SETS'); - expect(data[6].$.desc).to.equal('REMARKS'); - expect(data[7].$.desc).to.equal('PROCEDURE_TYPE'); - done(); - }); + it('returns meta data on for a procedure', (done) => { + const connection = new Connection(config); + + const sql = new iSql(); + // [catalog, schema, procedure] + sql.procedures(['', 'QSYS2', 'TCPIP_INFO']); + connection.add(sql.toXML()); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].procedures[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].procedures[0].row[0]; + expect(data[0].$.desc).to.equal('PROCEDURE_CAT'); + expect(data[1].$.desc).to.equal('PROCEDURE_SCHEM'); + expect(data[2].$.desc).to.equal('PROCEDURE_NAME'); + expect(data[3].$.desc).to.equal('NUM_INPUT_PARAMS'); + expect(data[4].$.desc).to.equal('NUM_OUTPUT_PARAMS'); + expect(data[5].$.desc).to.equal('NUM_RESULT_SETS'); + expect(data[6].$.desc).to.equal('REMARKS'); + expect(data[7].$.desc).to.equal('PROCEDURE_TYPE'); + done(); }); }); }); }); describe('pColumns', () => { - transports.forEach((transport) => { - it(`returns meta data for procedure column using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // [catalog, schema, procedure, column] - sql.pColumns(['', 'QSYS2', 'QCMDEXC', 'COMMAND']); - connection.add(sql.toXML()); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].pcolumns[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].pcolumns[0].row[0]; - expect(data[0].$.desc).to.equal('PROCEDURE_CAT'); - expect(data[1].$.desc).to.equal('PROCEDURE_SCHEM'); - expect(data[2].$.desc).to.equal('PROCEDURE_NAME'); - expect(data[3].$.desc).to.equal('COLUMN_NAME'); - expect(data[4].$.desc).to.equal('COLUMN_TYPE'); - expect(data[5].$.desc).to.equal('DATA_TYPE'); - expect(data[6].$.desc).to.equal('TYPE_NAME'); - expect(data[7].$.desc).to.equal('COLUMN_SIZE'); - expect(data[8].$.desc).to.equal('BUFFER_LENGTH'); - expect(data[9].$.desc).to.equal('DECIMAL_DIGITS'); - expect(data[10].$.desc).to.equal('NUM_PREC_RADIX'); - expect(data[11].$.desc).to.equal('NULLABLE'); - expect(data[12].$.desc).to.equal('REMARKS'); - expect(data[13].$.desc).to.equal('COLUMN_DEF'); - expect(data[14].$.desc).to.equal('SQL_DATA_TYPE'); - expect(data[15].$.desc).to.equal('SQL_DATETIME_SUB'); - expect(data[16].$.desc).to.equal('CHAR_OCTET_LENGTH'); - expect(data[17].$.desc).to.equal('ORDINAL_POSITION'); - expect(data[18].$.desc).to.equal('IS_NULLABLE'); - done(); - }); + it('returns meta data for procedure column', (done) => { + const connection = new Connection(config); + + const sql = new iSql(); + // [catalog, schema, procedure, column] + sql.pColumns(['', 'QSYS2', 'QCMDEXC', 'COMMAND']); + connection.add(sql.toXML()); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].pcolumns[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].pcolumns[0].row[0]; + expect(data[0].$.desc).to.equal('PROCEDURE_CAT'); + expect(data[1].$.desc).to.equal('PROCEDURE_SCHEM'); + expect(data[2].$.desc).to.equal('PROCEDURE_NAME'); + expect(data[3].$.desc).to.equal('COLUMN_NAME'); + expect(data[4].$.desc).to.equal('COLUMN_TYPE'); + expect(data[5].$.desc).to.equal('DATA_TYPE'); + expect(data[6].$.desc).to.equal('TYPE_NAME'); + expect(data[7].$.desc).to.equal('COLUMN_SIZE'); + expect(data[8].$.desc).to.equal('BUFFER_LENGTH'); + expect(data[9].$.desc).to.equal('DECIMAL_DIGITS'); + expect(data[10].$.desc).to.equal('NUM_PREC_RADIX'); + expect(data[11].$.desc).to.equal('NULLABLE'); + expect(data[12].$.desc).to.equal('REMARKS'); + expect(data[13].$.desc).to.equal('COLUMN_DEF'); + expect(data[14].$.desc).to.equal('SQL_DATA_TYPE'); + expect(data[15].$.desc).to.equal('SQL_DATETIME_SUB'); + expect(data[16].$.desc).to.equal('CHAR_OCTET_LENGTH'); + expect(data[17].$.desc).to.equal('ORDINAL_POSITION'); + expect(data[18].$.desc).to.equal('IS_NULLABLE'); + done(); }); }); }); }); describe('primaryKeys', () => { - transports.forEach((transport) => { - it(`returns meta data for a primary key using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // [catalog, schema, table] - sql.primaryKeys(['', 'QUSRSYS', 'QASZRAIRX']); - connection.add(sql.toXML()); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].primarykeys[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].primarykeys[0].row[0]; - expect(data[0].$.desc).to.equal('TABLE_CAT'); - expect(data[1].$.desc).to.equal('TABLE_SCHEM'); - expect(data[2].$.desc).to.equal('TABLE_NAME'); - expect(data[3].$.desc).to.equal('COLUMN_NAME'); - expect(data[4].$.desc).to.equal('KEY_SEQ'); - expect(data[5].$.desc).to.equal('PK_NAME'); - done(); - }); + it('returns meta data for a primary key', (done) => { + const connection = new Connection(config); + + const sql = new iSql(); + // [catalog, schema, table] + sql.primaryKeys(['', 'QUSRSYS', 'QASZRAIRX']); + connection.add(sql.toXML()); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].primarykeys[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].primarykeys[0].row[0]; + expect(data[0].$.desc).to.equal('TABLE_CAT'); + expect(data[1].$.desc).to.equal('TABLE_SCHEM'); + expect(data[2].$.desc).to.equal('TABLE_NAME'); + expect(data[3].$.desc).to.equal('COLUMN_NAME'); + expect(data[4].$.desc).to.equal('KEY_SEQ'); + expect(data[5].$.desc).to.equal('PK_NAME'); + done(); }); }); }); }); describe('foreignKeys', () => { - transports.forEach((transport) => { - it(`returns meta data for a foreign key using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - // pk: [catalog, schema, table] - // fk: [catalog, schema, table] - sql.foreignKeys(['', 'QUSRSYS', 'QASZRAIRC', '', 'QUSRSYS', 'QASZRAIRX']); - connection.add(sql.toXML()); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].foreignkeys[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].foreignkeys[0].row[0]; - expect(data[0].$.desc).to.equal('PKTABLE_CAT'); - expect(data[1].$.desc).to.equal('PKTABLE_SCHEM'); - expect(data[2].$.desc).to.equal('PKTABLE_NAME'); - expect(data[3].$.desc).to.equal('PKCOLUMN_NAME'); - expect(data[4].$.desc).to.equal('FKTABLE_CAT'); - expect(data[5].$.desc).to.equal('FKTABLE_SCHEM'); - expect(data[6].$.desc).to.equal('FKTABLE_NAME'); - expect(data[7].$.desc).to.equal('FKCOLUMN_NAME'); - expect(data[8].$.desc).to.equal('KEY_SEQ'); - expect(data[9].$.desc).to.equal('UPDATE_RULE'); - expect(data[10].$.desc).to.equal('DELETE_RULE'); - expect(data[11].$.desc).to.equal('FK_NAME'); - expect(data[12].$.desc).to.equal('PK_NAME'); - expect(data[13].$.desc).to.equal('DEFERRABILITY'); - done(); - }); + it('returns meta data for a foreign key', (done) => { + const connection = new Connection(config); + + const sql = new iSql(); + // pk: [catalog, schema, table] + // fk: [catalog, schema, table] + sql.foreignKeys(['', 'QUSRSYS', 'QASZRAIRC', '', 'QUSRSYS', 'QASZRAIRX']); + connection.add(sql.toXML()); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].foreignkeys[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].foreignkeys[0].row[0]; + expect(data[0].$.desc).to.equal('PKTABLE_CAT'); + expect(data[1].$.desc).to.equal('PKTABLE_SCHEM'); + expect(data[2].$.desc).to.equal('PKTABLE_NAME'); + expect(data[3].$.desc).to.equal('PKCOLUMN_NAME'); + expect(data[4].$.desc).to.equal('FKTABLE_CAT'); + expect(data[5].$.desc).to.equal('FKTABLE_SCHEM'); + expect(data[6].$.desc).to.equal('FKTABLE_NAME'); + expect(data[7].$.desc).to.equal('FKCOLUMN_NAME'); + expect(data[8].$.desc).to.equal('KEY_SEQ'); + expect(data[9].$.desc).to.equal('UPDATE_RULE'); + expect(data[10].$.desc).to.equal('DELETE_RULE'); + expect(data[11].$.desc).to.equal('FK_NAME'); + expect(data[12].$.desc).to.equal('PK_NAME'); + expect(data[13].$.desc).to.equal('DEFERRABILITY'); + done(); }); }); }); }); describe('statistics', () => { - transports.forEach((transport) => { - it(`returns stats info for table using ${transport.name} transport`, (done) => { - const connection = transport.me; - - const sql = new iSql(); - - sql.statistics(['', 'QIWS', 'QCUSTCDT', 'all']); - connection.add(sql.toXML()); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - expect(result.myscript.sql[0].statistics[0].success[0]).to.include('+++ success'); - const { data } = result.myscript.sql[0].statistics[0].row[0]; - expect(data[0].$.desc).to.equal('TABLE_CAT'); - expect(data[1].$.desc).to.equal('TABLE_SCHEM'); - expect(data[2].$.desc).to.equal('TABLE_NAME'); - expect(data[3].$.desc).to.equal('NON_UNIQUE'); - expect(data[4].$.desc).to.equal('INDEX_QUALIFIER'); - expect(data[5].$.desc).to.equal('INDEX_NAME'); - expect(data[6].$.desc).to.equal('TYPE'); - expect(data[7].$.desc).to.equal('ORDINAL_POSITION'); - expect(data[8].$.desc).to.equal('COLUMN_NAME'); - expect(data[9].$.desc).to.equal('ASC_OR_DESC'); - expect(data[10].$.desc).to.equal('CARDINALITY'); - expect(data[11].$.desc).to.equal('PAGES'); - expect(data[12].$.desc).to.equal('FILTER_CONDITION'); - done(); - }); + it('returns stats info for table', (done) => { + const connection = new Connection(config); + + const sql = new iSql(); + + sql.statistics(['', 'QIWS', 'QCUSTCDT', 'all']); + connection.add(sql.toXML()); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + expect(result.myscript.sql[0].statistics[0].success[0]).to.include('+++ success'); + const { data } = result.myscript.sql[0].statistics[0].row[0]; + expect(data[0].$.desc).to.equal('TABLE_CAT'); + expect(data[1].$.desc).to.equal('TABLE_SCHEM'); + expect(data[2].$.desc).to.equal('TABLE_NAME'); + expect(data[3].$.desc).to.equal('NON_UNIQUE'); + expect(data[4].$.desc).to.equal('INDEX_QUALIFIER'); + expect(data[5].$.desc).to.equal('INDEX_NAME'); + expect(data[6].$.desc).to.equal('TYPE'); + expect(data[7].$.desc).to.equal('ORDINAL_POSITION'); + expect(data[8].$.desc).to.equal('COLUMN_NAME'); + expect(data[9].$.desc).to.equal('ASC_OR_DESC'); + expect(data[10].$.desc).to.equal('CARDINALITY'); + expect(data[11].$.desc).to.equal('PAGES'); + expect(data[12].$.desc).to.equal('FILTER_CONDITION'); + done(); }); }); }); @@ -439,24 +398,22 @@ describe('iSql Functional Tests', () => { describe.skip('special', () => { // TODO: find passing case // Below test fails with error code 9- argument value not valid - transports.forEach((transport) => { - it.skip(`returns meta data for special columns using ${transport.name} transport`, (done) => { - // [catalog, schema, table, row | transaction |session, no | nullable] - const connection = transport.me; - - const sql = new iSql(); - - sql.special(['', 'QUSRSYS', 'QASZRAIRX', 'row', 'no'], { error: 'on' }); - connection.add(sql.toXML()); - connection.debug(true); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - expect(parseError).to.equal(null); - // TODO add more assertions - expect(result).to.be.an('object'); - done(); - }); + it.skip('returns meta data for special columns', (done) => { + // [catalog, schema, table, row | transaction |session, no | nullable] + const connection = new Connection(config); + + const sql = new iSql(); + + sql.special(['', 'QUSRSYS', 'QASZRAIRX', 'row', 'no'], { error: 'on' }); + connection.add(sql.toXML()); + connection.debug(true); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + expect(parseError).to.equal(null); + // TODO add more assertions + expect(result).to.be.an('object'); + done(); }); }); }); @@ -464,29 +421,27 @@ describe('iSql Functional Tests', () => { describe.skip('rowCount', () => { // Skip for now need to create a table for this test to insert to. - transports.forEach((transport) => { - it.skip(`returns the number of rows affected by statement using ${transport.name} transport`, (done) => { - const connection = transport.me; + it.skip('returns the number of rows affected by statement', (done) => { + const connection = new Connection(config); - const sql = new iSql(); + const sql = new iSql(); - const insert = 'INSERT INTO QIWS.QCUSTCDT (CUSNUM,LSTNAM,INIT,STREET,CITY,STATE,ZIPCOD,CDTLMT,CHGCOD,BALDUE,CDTDUE) ' + const insert = 'INSERT INTO QIWS.QCUSTCDT (CUSNUM,LSTNAM,INIT,STREET,CITY,STATE,ZIPCOD,CDTLMT,CHGCOD,BALDUE,CDTDUE) ' + 'VALUES (8798,\'TURNER\',\'TT\',\'MAIN\',\'NYC\',\'NY\',10001, 500, 3, 40.00, 0.00) with NONE'; - sql.addQuery(insert); - sql.rowCount(); - sql.free(); - connection.add(sql.toXML()); - connection.run((error, xmlOut) => { - expect(error).to.equal(null); - parseString(xmlOut, (parseError, result) => { - const sqlNode = result.myscript.sql[0]; - expect(parseError).to.equal(null); - expect(sqlNode.query[0].success[0]).to.include('+++ success'); - expect(sqlNode.free[0].success[0]).to.include('+++ success'); - expect(sqlNode.rowcount[0]._).to.equal('1'); - done(); - }); + sql.addQuery(insert); + sql.rowCount(); + sql.free(); + connection.add(sql.toXML()); + connection.run((error, xmlOut) => { + expect(error).to.equal(null); + parseString(xmlOut, (parseError, result) => { + const sqlNode = result.myscript.sql[0]; + expect(parseError).to.equal(null); + expect(sqlNode.query[0].success[0]).to.include('+++ success'); + expect(sqlNode.free[0].success[0]).to.include('+++ success'); + expect(sqlNode.rowcount[0]._).to.equal('1'); + done(); }); }); });