Skip to content

Commit e4aa348

Browse files
Merge pull request #131 from SmartBear/TSERV-2102-jprod-removal
TSERV-2102 JProd removal
2 parents 0c29837 + 9d28d2a commit e4aa348

2 files changed

Lines changed: 7 additions & 84 deletions

File tree

bin/license_functions.js

Lines changed: 6 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,13 @@ module.exports.dispatcher = function (args) {
1919
let shouldInstallSlm = args.includes("type=slm");
2020
if (shouldInstallSlm) {
2121
argsWithoutFilename = args.slice(1, args.length);
22-
} else {
23-
if (args.length < 2) {
24-
util.error("When installing a JPROD license licensefile or host:port is mandatory.")
25-
printModuleHelp();
26-
process.exit(1);
27-
}
28-
argsWithoutFilename = args.slice(1, args.length - 1);
2922
}
23+
3024
let options = util.optionsFromArgs(argsWithoutFilename, [
3125
'licenseServer',
3226
'accessKey',
33-
'type',
34-
'lastName',
35-
'firstName',
36-
'email']);
37-
installLicense(options, shouldInstallSlm ? null : args[args.length - 1]);
27+
'type']);
28+
installLicense(options);
3829
break;
3930
}
4031
case 'uninstall':
@@ -61,24 +52,13 @@ function printModuleHelp() {
6152
util.error("Usage: testengine license <command>");
6253
util.error("Commands: ");
6354
util.error(" info");
64-
util.error(" install type=<fixed|floating|slm> [lastName=<name>] [firstName=<firstName>] [email=<email-address>]");
65-
util.error(" [licenseServer=<slmLicenseServer] [accessKey=<slmAccessKey>] [<licensefile|host:port>]");
55+
util.error(" install type=slm [licenseServer=<slmLicenseServer] [accessKey=<slmAccessKey>]");
6656
util.error(" uninstall");
6757
util.error(" help");
6858
}
6959

70-
function installLicense(options, licenseOrLicenseServer) {
60+
function installLicense(options) {
7161
switch (options['type']) {
72-
case 'floating': {
73-
let mr = /([^:]*):([0-9]+)/g.exec(licenseOrLicenseServer);
74-
if (mr) {
75-
installFloatingLicense(mr[1], parseInt(mr[2]));
76-
}
77-
break;
78-
}
79-
case 'fixed':
80-
installFixedLicense(options, licenseOrLicenseServer);
81-
break;
8262
case 'slm':
8363
if (!options.accessKey && !options.licenseServer) {
8464
util.error("At least one of the options accessKey or licenseServer needs to be specified when installing" +
@@ -87,7 +67,7 @@ function installLicense(options, licenseOrLicenseServer) {
8767
installSlmLicense(options)
8868
break;
8969
default:
90-
util.printErrorAndExit("Error: Specifying fixed, floating or slm license is mandatory");
70+
util.printErrorAndExit("Error: Specifying slm license is mandatory");
9171
}
9272
}
9373

@@ -133,63 +113,6 @@ function uninstallLicense() {
133113
});
134114
}
135115

136-
function installFixedLicense(options, licenseFile) {
137-
let endPoint = config.server + '/api/v1/license';
138-
let activationInfo = {};
139-
for (let key of ['firstName', 'lastName', 'email']) {
140-
if (key in options) {
141-
activationInfo[key] = options[key];
142-
}
143-
}
144-
let readStream = fs.createReadStream(licenseFile);
145-
readStream.on('open', function () {
146-
let buffer = Buffer.from(JSON.stringify(activationInfo), 'utf8');
147-
request.post(endPoint)
148-
.auth(config.username, config.password)
149-
.accept('application/json')
150-
.type('multipart/form-data')
151-
.attach('file', licenseFile)
152-
.attach('activationInfo', buffer, "data.json")
153-
.end((err, result) => {
154-
if (err === null) {
155-
util.output("The following license was installed:");
156-
util.output(licenseInfoToString(result.body))
157-
} else {
158-
handleError(err, result)
159-
}
160-
});
161-
});
162-
readStream.on('error', function (err) {
163-
util.error("Error: " + err.message);
164-
let ext = path.extname(licenseFile).toLowerCase();
165-
if ((ext !== '.key') && (ext !== '.zip')) {
166-
util.error('"' + licenseFile + '" does not seem to be a .zip or .key file');
167-
}
168-
process.exit(1);
169-
});
170-
171-
}
172-
173-
function installFloatingLicense(licenseServerHost, licenseServerPort) {
174-
let endPoint = config.server + '/api/v1/license';
175-
let payload = {
176-
'host': licenseServerHost,
177-
'port': licenseServerPort
178-
};
179-
request.post(endPoint)
180-
.auth(config.username, config.password)
181-
.accept('application/json')
182-
.type('application/json')
183-
.send(payload)
184-
.end((err, result) => {
185-
if (err === null) {
186-
util.output("The following license was installed:");
187-
util.output(licenseInfoToString(result.body))
188-
} else {
189-
handleError(err, result);
190-
}
191-
});
192-
}
193116

194117
function showLicenseInfo() {
195118
let endPoint = config.server + '/api/v1/license';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "testengine-cli",
3-
"version": "1.11.0",
3+
"version": "1.12.0",
44
"description": "CLI for SmartBear ReadyAPI TestEngine",
55
"scripts": {
66
"testengine": "bin/testengine.js",

0 commit comments

Comments
 (0)