itoolkit 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -8
- package/lib/CommandCall.js +2 -16
- package/lib/Connection.js +2 -17
- package/lib/Deprecated.js +5 -26
- package/lib/ProgramCall.js +4 -18
- package/lib/itoolkit.js +2 -16
- package/lib/transports/httpTransport.js +4 -18
- package/lib/transports/idbTransport.js +24 -26
- package/lib/transports/odbcTransport.js +16 -16
- package/lib/transports/sshTransport.js +5 -20
- package/package.json +23 -16
- package/.eslintrc.js +0 -13
- package/.gitattributes +0 -2
- package/.readthedocs.yml +0 -16
- package/CHANGELOG.md +0 -195
- package/contributors.txt +0 -2
- package/test/README.md +0 -46
- package/test/functional/CommandCallFunctional.js +0 -79
- package/test/functional/ProgramCallFunctional.js +0 -166
- package/test/functional/checkObjectExists.js +0 -182
- package/test/functional/config.js +0 -35
- package/test/functional/deprecated/commandsFunctional.js +0 -99
- package/test/functional/deprecated/iDataQueueFunctional.js +0 -104
- package/test/functional/deprecated/iNetworkFunctional.js +0 -160
- package/test/functional/deprecated/iObjFunctional.js +0 -350
- package/test/functional/deprecated/iPgmFunctional.js +0 -140
- package/test/functional/deprecated/iProdFunctional.js +0 -161
- package/test/functional/deprecated/iSqlFunctional.js +0 -455
- package/test/functional/deprecated/iUserSpaceFunctional.js +0 -127
- package/test/functional/deprecated/iWorkFunctional.js +0 -236
- package/test/functional/iDataQueueFunctional.js +0 -84
- package/test/functional/iNetworkFunctional.js +0 -133
- package/test/functional/iObjFunctional.js +0 -327
- package/test/functional/iProdFunctional.js +0 -135
- package/test/functional/iSqlFunctional.js +0 -449
- package/test/functional/iUserSpaceFunctional.js +0 -123
- package/test/functional/iWorkFunctional.js +0 -219
- package/test/unit/CommandCallUnit.js +0 -88
- package/test/unit/ConnectionUnit.js +0 -195
- package/test/unit/ProgamCallUnit.js +0 -279
- package/test/unit/deprecated/commandsUnit.js +0 -88
- package/test/unit/deprecated/iConnUnit.js +0 -162
- package/test/unit/deprecated/iPgmUnit.js +0 -207
- package/test/unit/deprecated/iSqlUnit.js +0 -442
- package/test/unit/deprecated/xmlToJsonUnit.js +0 -203
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
const lib = 'NODETKTEST';
|
|
2
|
-
const createLib = `CRTLIB LIB(${lib}) TYPE(*TEST) TEXT('Used to test Node.js toolkit')`;
|
|
3
|
-
const findLib = `SELECT SCHEMA_NAME FROM qsys2.sysschemas WHERE SCHEMA_NAME = '${lib}'`;
|
|
4
|
-
|
|
5
|
-
function checkObjectExistsSSH(config, object = {}, callback) {
|
|
6
|
-
/* eslint-disable global-require */
|
|
7
|
-
const { Client } = require('ssh2');
|
|
8
|
-
|
|
9
|
-
const client = new Client();
|
|
10
|
-
const checkLibCommand = `system 'CHKOBJ OBJ(QSYS/${lib}) OBJTYPE(*LIB)'`;
|
|
11
|
-
const checkObjectCommand = `system 'CHKOBJ OBJ(${lib}/${object.name}) OBJTYPE(${object.type})'`;
|
|
12
|
-
|
|
13
|
-
// if client.connect has an error it will be handled here
|
|
14
|
-
client.on('error', (error) => {
|
|
15
|
-
callback(error, false);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
client.on('ready', () => {
|
|
19
|
-
client.exec(checkLibCommand, (checkLibError, checkLibStream) => {
|
|
20
|
-
/* eslint-disable no-console */
|
|
21
|
-
console.log(`executing ${checkLibCommand}`);
|
|
22
|
-
if (checkLibError) {
|
|
23
|
-
callback(checkLibError, false);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
checkLibStream.stderr.on('data', (data) => {
|
|
27
|
-
console.log(`STDERR: ${data}`);
|
|
28
|
-
});
|
|
29
|
-
checkLibStream.on('exit', (checkLibCode) => {
|
|
30
|
-
if (checkLibCode !== 0) {
|
|
31
|
-
if (config.verbose) { console.log(`Command exited abnormally with code: ${checkLibCode}`); }
|
|
32
|
-
const libError = new Error(`${lib} lib was not found!\nCreate it by running: ${createLib}`);
|
|
33
|
-
client.end();
|
|
34
|
-
client.destroy();
|
|
35
|
-
callback(libError, false);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
client.exec(checkObjectCommand, (checkObjectError, checkObjectStream) => {
|
|
39
|
-
if (config.verbose) { console.log(`executing ${checkObjectCommand}`); }
|
|
40
|
-
if (checkObjectError) {
|
|
41
|
-
client.end();
|
|
42
|
-
client.destroy();
|
|
43
|
-
callback(checkLibError, false);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
checkObjectStream.stderr.on('data', (data) => {
|
|
47
|
-
console.log(`STDERR: ${data}`);
|
|
48
|
-
});
|
|
49
|
-
checkObjectStream.on('exit', (checkObjectCode) => {
|
|
50
|
-
if (checkObjectCode !== 0) {
|
|
51
|
-
client.end();
|
|
52
|
-
client.destroy();
|
|
53
|
-
console.log(`Command exited abnormally with code: ${checkObjectCode}`);
|
|
54
|
-
const objectError = new Error(`${object.name} was not found!\nCreate it by running: ${object.createObject}`);
|
|
55
|
-
callback(objectError);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
client.end();
|
|
59
|
-
client.destroy();
|
|
60
|
-
callback(null, true);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
client.connect(config);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function checkObjectExistsODBC(config, object = {}, callback) {
|
|
71
|
-
const odbc = require('odbc');
|
|
72
|
-
|
|
73
|
-
const connectionString = config.dsn || `DRIVER=IBM i Access ODBC Driver;SYSTEM=${config.host};UID=${config.username};PWD=${config.password};`;
|
|
74
|
-
|
|
75
|
-
odbc.connect(connectionString, (connectError, connection) => {
|
|
76
|
-
if (connectError) {
|
|
77
|
-
callback(connectError, false);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
connection.query(findLib, (findLibError, libResult) => {
|
|
81
|
-
if (findLibError) {
|
|
82
|
-
callback(findLibError, false);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (config.verbose) {
|
|
86
|
-
console.log('find lib result set: ', libResult);
|
|
87
|
-
}
|
|
88
|
-
if (!libResult.length) {
|
|
89
|
-
const libError = new Error(`${lib} lib was not found!\nCreate it by running:${createLib}`);
|
|
90
|
-
callback(libError, false);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
connection.query(object.findObject, (findObjectError, result) => {
|
|
94
|
-
if (findObjectError) {
|
|
95
|
-
callback(findObjectError, false);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (config.verbose) {
|
|
99
|
-
console.log('find lib result set: ', result);
|
|
100
|
-
}
|
|
101
|
-
if (!result.length) {
|
|
102
|
-
const resultError = new Error(`${object.name} was not found! Create it by running: ${object.createObject}`);
|
|
103
|
-
callback(resultError, false);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
callback(null, true);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function checkObjectExistsIDB(config, object = {}, callback) {
|
|
113
|
-
const { dbconn, dbstmt } = require('idb-connector');
|
|
114
|
-
|
|
115
|
-
/* eslint-disable new-cap */
|
|
116
|
-
const connection = new dbconn();
|
|
117
|
-
connection.conn('*LOCAL');
|
|
118
|
-
const statement = new dbstmt(connection);
|
|
119
|
-
|
|
120
|
-
statement.exec(findLib, (libResult, error) => {
|
|
121
|
-
if (error) {
|
|
122
|
-
callback(error, null);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
if (config.verbose) {
|
|
126
|
-
console.log('find lib result set: ', libResult);
|
|
127
|
-
}
|
|
128
|
-
if (!libResult.length) {
|
|
129
|
-
const libError = new Error(`${lib} lib was not found! Create it by running: ${createLib}`);
|
|
130
|
-
callback(libError, null);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
statement.closeCursor();
|
|
134
|
-
statement.exec(object.findObject, (result, findObjecError) => {
|
|
135
|
-
if (findObjecError) {
|
|
136
|
-
callback(findObjecError, null);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
if (config.verbose) {
|
|
140
|
-
console.log('find object result set: ', result);
|
|
141
|
-
}
|
|
142
|
-
if (!result.length) {
|
|
143
|
-
const resultError = new Error(`${object.name} was not found! Create it by running: ${object.createObject}`);
|
|
144
|
-
callback(resultError, null);
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
statement.close();
|
|
148
|
-
connection.disconn();
|
|
149
|
-
connection.close();
|
|
150
|
-
callback(null, true);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function checkObjectExists(config, name, type, callback) {
|
|
156
|
-
const object = { type };
|
|
157
|
-
|
|
158
|
-
if (type === '*DTAARA') {
|
|
159
|
-
object.name = name;
|
|
160
|
-
object.createObject = `CRTDTAARA DTAARA(${lib}/${name}) TYPE(*CHAR) TEXT('TEST DATA AREA FOR NODE TOOLKIT') VALUE('Hello From Test Data Area!')`;
|
|
161
|
-
} else if (type === '*DTAQ') {
|
|
162
|
-
object.name = name;
|
|
163
|
-
object.createObject = `CRTDTAQ DTAQ(${lib}/${name}) MAXLEN(100) AUT(*EXCLUDE) TEXT('TEST DQ FOR NODE TOOLKIT TESTS')`;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
object.findObject = `SELECT OBJNAME FROM TABLE (QSYS2.OBJECT_STATISTICS('${lib}', '${type}')) AS X WHERE OBJNAME = '${name}'`;
|
|
167
|
-
// eslint-disable-next-line no-param-reassign
|
|
168
|
-
config.transportOptions.verbose = config.verbose;
|
|
169
|
-
|
|
170
|
-
if (config.transport === 'idb') {
|
|
171
|
-
checkObjectExistsIDB(config.transportOptions, object, callback);
|
|
172
|
-
} else if (config.transport === 'odbc') {
|
|
173
|
-
checkObjectExistsODBC(config.transportOptions, object, callback);
|
|
174
|
-
} else if (config.transport === 'ssh') {
|
|
175
|
-
checkObjectExistsSSH(config.transportOptions, object, callback);
|
|
176
|
-
} else {
|
|
177
|
-
// we cannot check object existence using the rest transport
|
|
178
|
-
callback(null, true);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
module.exports.checkObjectExists = checkObjectExists;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const { readFileSync } = require('fs');
|
|
2
|
-
|
|
3
|
-
let privateKey;
|
|
4
|
-
if (process.env.TKPK) {
|
|
5
|
-
privateKey = readFileSync(process.env.TKPK, 'utf-8');
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const config = {
|
|
9
|
-
transport: process.env.TKTRANSPORT || 'ssh',
|
|
10
|
-
verbose: !!process.env.TKVERBOSE,
|
|
11
|
-
transportOptions: {
|
|
12
|
-
database: process.env.TKDB || '*LOCAL',
|
|
13
|
-
username: process.env.TKUSER || '',
|
|
14
|
-
password: process.env.TKPASS || '',
|
|
15
|
-
host: process.env.TKHOST || 'localhost',
|
|
16
|
-
port: process.env.TKPORT,
|
|
17
|
-
path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm',
|
|
18
|
-
url: process.env.TKURL,
|
|
19
|
-
privateKey,
|
|
20
|
-
// passphrase is used by the ssh transport to decrypt the private key
|
|
21
|
-
passphrase: process.env.TKPHRASE,
|
|
22
|
-
dsn: process.env.TKDSN,
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function printConfig() {
|
|
27
|
-
/* eslint-disable no-console */
|
|
28
|
-
console.log('-----------------------');
|
|
29
|
-
console.log('transport:', config.transport);
|
|
30
|
-
console.log(`verbose: ${config.verbose ? 'on' : 'off'}`);
|
|
31
|
-
console.log('-----------------------');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
module.exports.config = config;
|
|
35
|
-
module.exports.printConfig = printConfig;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
// Copyright (c) International Business Machines Corp. 2019
|
|
2
|
-
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
|
-
// associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
-
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
-
// furnished to do so, subject to the following conditions:
|
|
8
|
-
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
-
// substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
-
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
17
|
-
|
|
18
|
-
/* eslint-env mocha */
|
|
19
|
-
/* eslint-disable new-cap */
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const { expect } = require('chai');
|
|
23
|
-
const { parseString } = require('xml2js');
|
|
24
|
-
const {
|
|
25
|
-
iCmd, iSh, iQsh, iConn,
|
|
26
|
-
} = require('../../../lib/itoolkit');
|
|
27
|
-
|
|
28
|
-
const { config, printConfig } = require('../config');
|
|
29
|
-
|
|
30
|
-
// deprecated tests are in place to test compatability using deprecated classes and functions
|
|
31
|
-
// these tests use deprecated iConn Class to create a connnection
|
|
32
|
-
// iConn only supported idb and rest transports
|
|
33
|
-
if (config.transport !== 'idb' && config.transport !== 'rest') {
|
|
34
|
-
throw new Error('Only idb and rest transports are available for deprecated tests');
|
|
35
|
-
}
|
|
36
|
-
const {
|
|
37
|
-
database, username, password, host, port = 80, path,
|
|
38
|
-
} = config.transportOptions;
|
|
39
|
-
|
|
40
|
-
let restOptions = null;
|
|
41
|
-
if (config.transport === 'rest') {
|
|
42
|
-
restOptions = {
|
|
43
|
-
host,
|
|
44
|
-
port,
|
|
45
|
-
path,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
describe('iSh, iCmd, iQsh, Functional Tests', () => {
|
|
50
|
-
before(() => {
|
|
51
|
-
printConfig();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe('iCmd()', () => {
|
|
55
|
-
it('calls CL command', (done) => {
|
|
56
|
-
const connection = new iConn(database, username, password, restOptions);
|
|
57
|
-
connection.add(iCmd('RTVJOBA USRLIBL(?) SYSLIBL(?)'));
|
|
58
|
-
connection.run((xmlOut) => {
|
|
59
|
-
parseString(xmlOut, (parseError, result) => {
|
|
60
|
-
expect(parseError).to.equal(null);
|
|
61
|
-
expect(result.myscript.cmd[0].success[0]).to.include('+++ success RTVJOBA USRLIBL(?) SYSLIBL(?)');
|
|
62
|
-
done();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('iSh()', () => {
|
|
69
|
-
it('calls PASE shell command', (done) => {
|
|
70
|
-
const connection = new iConn(database, username, password, restOptions);
|
|
71
|
-
connection.add(iSh('system -i wrksyssts'));
|
|
72
|
-
connection.run((xmlOut) => {
|
|
73
|
-
// xs does not return success property for sh or qsh command calls
|
|
74
|
-
// but on error sh or qsh node will not have any inner data
|
|
75
|
-
parseString(xmlOut, (parseError, result) => {
|
|
76
|
-
expect(parseError).to.equal(null);
|
|
77
|
-
expect(result.myscript.sh[0]._).to.match(/(System\sStatus\sInformation)/);
|
|
78
|
-
done();
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
describe('iQsh()', () => {
|
|
85
|
-
it('calls QSH command', (done) => {
|
|
86
|
-
const connection = new iConn(database, username, password, restOptions);
|
|
87
|
-
connection.add(iQsh('system wrksyssts'));
|
|
88
|
-
connection.run((xmlOut) => {
|
|
89
|
-
// xs does not return success property for sh or qsh command calls
|
|
90
|
-
// but on error sh or qsh node will not have any inner data
|
|
91
|
-
parseString(xmlOut, (parseError, result) => {
|
|
92
|
-
expect(parseError).to.equal(null);
|
|
93
|
-
expect(result.myscript.qsh[0]._).to.match(/(System\sStatus\sInformation)/);
|
|
94
|
-
done();
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
});
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
// Copyright (c) International Business Machines Corp. 2019
|
|
2
|
-
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
|
-
// associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
-
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
-
// furnished to do so, subject to the following conditions:
|
|
8
|
-
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
-
// substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
-
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
17
|
-
|
|
18
|
-
/* eslint-env mocha */
|
|
19
|
-
/* eslint-disable new-cap */
|
|
20
|
-
|
|
21
|
-
const { expect } = require('chai');
|
|
22
|
-
const { iConn, iDataQueue } = require('../../../lib/itoolkit');
|
|
23
|
-
const { config, printConfig } = require('../config');
|
|
24
|
-
const { checkObjectExists } = require('../checkObjectExists');
|
|
25
|
-
|
|
26
|
-
// deprecated tests are in place to test compatability using deprecated classes and functions
|
|
27
|
-
// these tests use deprecated iConn Class to create a connnection.
|
|
28
|
-
// iConn only supported idb and rest transports
|
|
29
|
-
if (config.transport !== 'idb' && config.transport !== 'rest') {
|
|
30
|
-
throw new Error('Only idb and rest transports are available for deprecated tests');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const {
|
|
34
|
-
database, username, password, host, port = 80, path,
|
|
35
|
-
} = config.transportOptions;
|
|
36
|
-
|
|
37
|
-
let restOptions = null;
|
|
38
|
-
if (config.transport === 'rest') {
|
|
39
|
-
restOptions = {
|
|
40
|
-
host,
|
|
41
|
-
port,
|
|
42
|
-
path,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const lib = 'NODETKTEST'; const dqName = 'TESTQ';
|
|
47
|
-
|
|
48
|
-
describe('iDataQueue Functional Tests', () => {
|
|
49
|
-
before('check if data queue exists for tests', (done) => {
|
|
50
|
-
printConfig();
|
|
51
|
-
checkObjectExists(config, dqName, '*DTAQ', (error) => {
|
|
52
|
-
if (error) { throw error; }
|
|
53
|
-
done();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('constructor', () => {
|
|
58
|
-
it('creates and returns an instance of iDataQueue', () => {
|
|
59
|
-
const connection = new iConn(database, config.user, password);
|
|
60
|
-
|
|
61
|
-
const dq = new iDataQueue(connection);
|
|
62
|
-
expect(dq).to.be.instanceOf(iDataQueue);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
describe('sendToDataQueue', () => {
|
|
67
|
-
it('sends data to specified DQ', (done) => {
|
|
68
|
-
const connection = new iConn(database, username, password, restOptions);
|
|
69
|
-
|
|
70
|
-
const dq = new iDataQueue(connection);
|
|
71
|
-
|
|
72
|
-
dq.sendToDataQueue(dqName, lib, 'Hello from DQ!', (output) => {
|
|
73
|
-
expect(output).to.equal(true);
|
|
74
|
-
done();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('receiveFromDataQueue', () => {
|
|
80
|
-
it('receives data from specfied DQ', (done) => {
|
|
81
|
-
const connection = new iConn(database, username, password, restOptions);
|
|
82
|
-
|
|
83
|
-
const dq = new iDataQueue(connection);
|
|
84
|
-
|
|
85
|
-
dq.receiveFromDataQueue(dqName, lib, 100, (output) => {
|
|
86
|
-
expect(output).to.be.a('string').and.to.equal('Hello from DQ!');
|
|
87
|
-
done();
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe('clearDataQueue', () => {
|
|
93
|
-
it('clears the specifed DQ', (done) => {
|
|
94
|
-
const connection = new iConn(database, username, password, restOptions);
|
|
95
|
-
|
|
96
|
-
const dq = new iDataQueue(connection);
|
|
97
|
-
|
|
98
|
-
dq.clearDataQueue(dqName, lib, (output) => {
|
|
99
|
-
expect(output).to.equal(true);
|
|
100
|
-
done();
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
});
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
// Copyright (c) International Business Machines Corp. 2019
|
|
2
|
-
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
|
-
// associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
-
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
-
// furnished to do so, subject to the following conditions:
|
|
8
|
-
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
-
// substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
-
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
17
|
-
|
|
18
|
-
/* eslint-env mocha */
|
|
19
|
-
/* eslint-disable new-cap */
|
|
20
|
-
|
|
21
|
-
const { expect } = require('chai');
|
|
22
|
-
const { iConn, iNetwork } = require('../../../lib/itoolkit');
|
|
23
|
-
const { config, printConfig } = require('../config');
|
|
24
|
-
|
|
25
|
-
// deprecated tests are in place to test compatability using deprecated classes and functions
|
|
26
|
-
// these tests use deprecated iConn Class to create a connnection
|
|
27
|
-
// iConn only supported idb and rest transports
|
|
28
|
-
if (config.transport !== 'idb' && config.transport !== 'rest') {
|
|
29
|
-
throw new Error('Only idb and rest transports are available for deprecated tests');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const {
|
|
33
|
-
database, username, password, host, port = 80, path,
|
|
34
|
-
} = config.transportOptions;
|
|
35
|
-
|
|
36
|
-
let restOptions = null;
|
|
37
|
-
if (config.transport === 'rest') {
|
|
38
|
-
restOptions = {
|
|
39
|
-
host,
|
|
40
|
-
port,
|
|
41
|
-
path,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
describe('iNetwork Functional Tests', () => {
|
|
46
|
-
before(() => {
|
|
47
|
-
printConfig();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe('constructor', () => {
|
|
51
|
-
it('creates and returns an instance of iNetwork', () => {
|
|
52
|
-
const connection = new iConn(database, config.user, password);
|
|
53
|
-
|
|
54
|
-
const net = new iNetwork(connection);
|
|
55
|
-
|
|
56
|
-
expect(net).to.be.instanceOf(iNetwork);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
describe('getTCPIPAttr', () => {
|
|
61
|
-
it('retrieves TCP/IP Attributes', (done) => {
|
|
62
|
-
const connection = new iConn(database, username, password, restOptions);
|
|
63
|
-
|
|
64
|
-
const net = new iNetwork(connection);
|
|
65
|
-
|
|
66
|
-
net.getTCPIPAttr((output) => {
|
|
67
|
-
expect(output).to.be.an('Object');
|
|
68
|
-
expect(output).to.have.a.property('TCP/IPv4_stack_status');
|
|
69
|
-
expect(output).to.have.a.property('How_long_active');
|
|
70
|
-
expect(output).to.have.a.property('When_last_started_-_date');
|
|
71
|
-
expect(output).to.have.a.property('When_last_started_-_time');
|
|
72
|
-
expect(output).to.have.a.property('When_last_ended_-_date');
|
|
73
|
-
expect(output).to.have.a.property('When_last_ended_-_time');
|
|
74
|
-
expect(output).to.have.a.property('Who_last_started_-_job_name');
|
|
75
|
-
expect(output).to.have.a.property('Who_last_started_-_job_user_name');
|
|
76
|
-
expect(output).to.have.a.property('Who_last_started_-_job_number');
|
|
77
|
-
expect(output).to.have.a.property('Who_last_started_-_internal_job_identifier');
|
|
78
|
-
expect(output).to.have.a.property('Who_last_ended_-_job_name');
|
|
79
|
-
expect(output).to.have.a.property('Who_last_ended_-_job_user_name');
|
|
80
|
-
expect(output).to.have.a.property('Who_last_ended_-_job_number');
|
|
81
|
-
expect(output).to.have.a.property('Who_last_ended_-_internal_job_identifier');
|
|
82
|
-
expect(output).to.have.a.property('Offset_to_additional_information');
|
|
83
|
-
expect(output).to.have.a.property('Length_of_additional_information');
|
|
84
|
-
expect(output).to.have.a.property('Limited_mode');
|
|
85
|
-
expect(output).to.have.a.property('Offset_to_list_of_Internet_addresses');
|
|
86
|
-
expect(output).to.have.a.property('Number_of_Internet_addresses');
|
|
87
|
-
expect(output).to.have.a.property('Entry_length_for_list_of_Internet_addresses');
|
|
88
|
-
expect(output).to.have.a.property('DNS_protocol');
|
|
89
|
-
expect(output).to.have.a.property('Retries');
|
|
90
|
-
expect(output).to.have.a.property('Time_interval');
|
|
91
|
-
expect(output).to.have.a.property('Search_order');
|
|
92
|
-
expect(output).to.have.a.property('Initial_domain_name_server');
|
|
93
|
-
expect(output).to.have.a.property('DNS_listening_port');
|
|
94
|
-
expect(output).to.have.a.property('Host_name');
|
|
95
|
-
expect(output).to.have.a.property('Domain_name');
|
|
96
|
-
expect(output).to.have.a.property('Domain_search_list');
|
|
97
|
-
done();
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
describe('getNetInterfaceData', () => {
|
|
103
|
-
it('retrieves IPv4 network interface info', (done) => {
|
|
104
|
-
const connection = new iConn(database, username, password, restOptions);
|
|
105
|
-
|
|
106
|
-
const net = new iNetwork(connection);
|
|
107
|
-
|
|
108
|
-
net.getNetInterfaceData('127.0.0.1', (output) => {
|
|
109
|
-
expect(output).to.be.an('Object');
|
|
110
|
-
expect(output).to.have.a.property('Internet_address');
|
|
111
|
-
expect(output).to.have.a.property('Internet_address_binary');
|
|
112
|
-
expect(output).to.have.a.property('Network_address');
|
|
113
|
-
expect(output).to.have.a.property('Network_address_binary');
|
|
114
|
-
expect(output).to.have.a.property('Line_description');
|
|
115
|
-
expect(output).to.have.a.property('Interface_status');
|
|
116
|
-
expect(output).to.have.a.property('Interface_type_of_service');
|
|
117
|
-
expect(output).to.have.a.property('Interface_MTU');
|
|
118
|
-
expect(output).to.have.a.property('Interface_line_type');
|
|
119
|
-
expect(output).to.have.a.property('Host_address');
|
|
120
|
-
expect(output).to.have.a.property('Host_address_binary');
|
|
121
|
-
expect(output).to.have.a.property('Interface_subnet_mask');
|
|
122
|
-
expect(output).to.have.a.property('Interface_subnet_mask_binary');
|
|
123
|
-
expect(output).to.have.a.property('Directed_broadcast_address');
|
|
124
|
-
expect(output).to.have.a.property('Directed_broadcast_address_binary');
|
|
125
|
-
expect(output).to.have.a.property('Change_date');
|
|
126
|
-
expect(output).to.have.a.property('Change_time');
|
|
127
|
-
expect(output).to.have.a.property('Associated_local_interface');
|
|
128
|
-
expect(output).to.have.a.property('Associated_local_interface_binary');
|
|
129
|
-
expect(output).to.have.a.property('Packet_rules');
|
|
130
|
-
expect(output).to.have.a.property('Change_status');
|
|
131
|
-
expect(output).to.have.a.property('Automatic_start');
|
|
132
|
-
expect(output).to.have.a.property('TRLAN_bit_sequencing');
|
|
133
|
-
expect(output).to.have.a.property('Interface_type');
|
|
134
|
-
expect(output).to.have.a.property('Proxy_ARP_allowed');
|
|
135
|
-
expect(output).to.have.a.property('Proxy_ARP_enabled');
|
|
136
|
-
expect(output).to.have.a.property('Configured_MTU');
|
|
137
|
-
expect(output).to.have.a.property('Network_name');
|
|
138
|
-
expect(output).to.have.a.property('Interface_name');
|
|
139
|
-
expect(output).to.have.a.property('Alias_name');
|
|
140
|
-
expect(output).to.have.a.property('Interface_description');
|
|
141
|
-
expect(output).to.have.a.property('Offset_to_preferred_interface_list');
|
|
142
|
-
expect(output).to.have.a.property('Number_of_entries_in_preferred_interface_list');
|
|
143
|
-
expect(output).to.have.a.property('Length_of_one_preferred_interface_list_entry');
|
|
144
|
-
expect(output).to.have.a.property('DHCP_created');
|
|
145
|
-
expect(output).to.have.a.property('DHCP_dynamic_DNS_updates');
|
|
146
|
-
expect(output).to.have.a.property('DHCP_lease_expiration');
|
|
147
|
-
expect(output).to.have.a.property('DHCP_lease_expiration_-_date');
|
|
148
|
-
expect(output).to.have.a.property('DHCP_lease_expiration_-_time');
|
|
149
|
-
expect(output).to.have.a.property('DHCP_lease_obtained');
|
|
150
|
-
expect(output).to.have.a.property('DHCP_lease_obtained_-_date');
|
|
151
|
-
expect(output).to.have.a.property('DHCP_lease_obtained_-_time');
|
|
152
|
-
expect(output).to.have.a.property('Use_DHCP_unique_identifier');
|
|
153
|
-
expect(output).to.have.a.property('DHCP_server_IP_address');
|
|
154
|
-
expect(output).to.have.a.property('Preferred_interface_Internet_address');
|
|
155
|
-
expect(output).to.have.a.property('Preferred_interface_Internet_address_binary');
|
|
156
|
-
done();
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
});
|