summaryrefslogtreecommitdiffstats
path: root/cucumber-js-test-apis-ci/stepDefinitions
diff options
context:
space:
mode:
authorilanap <ilanap@amdocs.com>2019-08-04 10:16:33 +0300
committerilanap <ilanap@amdocs.com>2019-08-04 10:16:33 +0300
commit061ca938ca6998b4ec33a862c763854259cfeab1 (patch)
tree824a0e4d9c21ed0f38d9dd497882e20687b7d1c0 /cucumber-js-test-apis-ci/stepDefinitions
parent610ff24fb145dc64e73a12d51901446b7b8be245 (diff)
Issue-ID: SDC-2483
Adding https support for cucumber tests and slight refactoring Signed-off-by: ilanap <ilanap@amdocs.com> Change-Id: Ib772d18cd4278238571daf54bcb6372c553d6e4b
Diffstat (limited to 'cucumber-js-test-apis-ci/stepDefinitions')
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/ActivitySpec_steps.js2
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/Collaboration_Steps.js2
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/General_Steps.js2
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/GlobalTypes.js4
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/InputData_steps.js2
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/InterfaceOperationSteps.js22
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/Item_steps.js2
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/NetworkPackage_steps.js8
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/Questionnaire_steps.js2
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/REST_Steps.js2
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/Toggle_Steps.js2
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/Utils.js148
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/VF_steps.js4
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/VLM_steps.js2
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/VSP_steps.js6
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/world.js92
16 files changed, 31 insertions, 271 deletions
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/ActivitySpec_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/ActivitySpec_steps.js
index 7fe8ddf201..d12421bd90 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/ActivitySpec_steps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/ActivitySpec_steps.js
@@ -16,7 +16,7 @@
const {Then, When} = require('cucumber');
const assert = require('assert');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
const _ = require('lodash');
When('I want to create an ActivitySpec', function () {
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/Collaboration_Steps.js b/cucumber-js-test-apis-ci/stepDefinitions/Collaboration_Steps.js
index c4de758300..a0713c5b61 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/Collaboration_Steps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/Collaboration_Steps.js
@@ -15,7 +15,7 @@
*/
const {Then, When, Given} = require('cucumber');
const assert = require('assert');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
/**
* @module Collaboration
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/General_Steps.js b/cucumber-js-test-apis-ci/stepDefinitions/General_Steps.js
index 2076366595..e59d441e10 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/General_Steps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/General_Steps.js
@@ -20,7 +20,7 @@ const normalizeNewline = require('normalize-newline');
require('node-zip');
YAML = require('yamljs');
const fs = require('fs');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
function getPath(path, context) {
let compiled = _.template(path);
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/GlobalTypes.js b/cucumber-js-test-apis-ci/stepDefinitions/GlobalTypes.js
index 461fee74a7..f278a2ebb0 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/GlobalTypes.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/GlobalTypes.js
@@ -16,9 +16,9 @@
const {Then, When} = require('cucumber');
const assert = require('assert');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
When('I want to get interface lifecycle types', function () {
let path = '/catalog/interfaceLifecycleTypes';
- return util.request(this.context, 'GET', path, null, false, 'catalog');
+ return util.request(this.context, 'GET', path, null, 'catalog');
}); \ No newline at end of file
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/InputData_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/InputData_steps.js
index 57a374b9bb..782aeaec23 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/InputData_steps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/InputData_steps.js
@@ -17,7 +17,7 @@ const {Then, When, Given} = require('cucumber');
const assert = require('assert');
const _ = require('lodash');
const fs = require('fs');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
/**
* @module InputData
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/InterfaceOperationSteps.js b/cucumber-js-test-apis-ci/stepDefinitions/InterfaceOperationSteps.js
index 3e2321963c..ba716d0e4d 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/InterfaceOperationSteps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/InterfaceOperationSteps.js
@@ -15,7 +15,7 @@
*/
const {Then, When} = require('cucumber');
const assert = require('assert');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
When('I want to create a VF', function() {
@@ -27,7 +27,7 @@ When('I want to create a VF', function() {
var type = "resources";
let path = '/catalog/' + type;
- return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
+ return util.request(this.context, 'POST', path, inputData, 'catalog').then(result => {
this.context.component = {uniqueId : result.data.uniqueId, type : type, id : result.data.inputs[0].uniqueId};
});
});
@@ -41,7 +41,7 @@ When('I want to create a Service', function() {
var type = "services";
let path = '/catalog/' + type;
- return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
+ return util.request(this.context, 'POST', path, inputData, 'catalog').then(result => {
this.context.component = {uniqueId : result.data.uniqueId, type : type, id : result.data.inputs[0].uniqueId};
});
});
@@ -68,7 +68,7 @@ When('I want to create an Operation', function() {
inputData.interfaces.interface1.operations.delete.outputs.listToscaDataDefinition[0].name = util.random();
inputData.interfaces.interface1.operations.delete.description = operationName + " description";
- return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
+ return util.request(this.context, 'POST', path, inputData, 'catalog').then(result => {
{intOperations = result.data.interfaces[0].operations};
this.context.interface = { interfaceUniqueId : result.data.interfaces[0].uniqueId,
interfaceType : result.data.interfaces[0].type,
@@ -86,7 +86,7 @@ When('I want to update an Operation', function () {
inputData.interfaces.interface1.operations.delete.inputs.listToscaDataDefinition[0].inputId = this.context.component.id;
inputData.interfaces.interface1.operations.delete.outputs.listToscaDataDefinition[0].name = util.random();
- return util.request(this.context, 'PUT', path, inputData, false, 'catalog').then((result)=> {
+ return util.request(this.context, 'PUT', path, inputData, 'catalog').then((result)=> {
{intOperations = result.data.interfaces[0].operations};
this.context.interface = { interfaceUniqueId : result.data.interfaces[0].uniqueId,
interfaceType : result.data.interfaces[0].type,
@@ -98,7 +98,7 @@ When('I want to update an Operation', function () {
When('I want to get an Operation by Id', function () {
let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/interfaces/' +
this.context.interface.interfaceUniqueId + '/operations/' +this.context.interface.operationUniqueId ;
- return util.request(this.context, 'GET', path, null, false, 'catalog').then((result)=> {
+ return util.request(this.context, 'GET', path, null, 'catalog').then((result)=> {
{intOperations = result.data.interfaces[0].operations};
this.context.interface = { interfaceUniqueId : result.data.interfaces[0].uniqueId,
@@ -111,7 +111,7 @@ When('I want to get an Operation by Id', function () {
When('I want to list Operations', function () {
let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/filteredDataByParams?include=interfaces';
- return util.request(this.context, 'GET', path, null, false, 'catalog').then((result)=> {
+ return util.request(this.context, 'GET', path, null, 'catalog').then((result)=> {
});
});
@@ -119,14 +119,14 @@ When('I want to list Operations', function () {
When('I want to delete an Operation', function() {
let path = '/catalog/'+ this.context.component.type + '/'+ this.context.component.uniqueId +'/interfaces/' +
this.context.interface.interfaceUniqueId + '/operations/' +this.context.interface.operationUniqueId ;
- return util.request(this.context, 'DELETE', path, null, false, 'catalog');
+ return util.request(this.context, 'DELETE', path, null, 'catalog');
});
When('I want to checkin this component', function () {
let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/lifecycleState/CHECKIN' ;
let inputData = {userRemarks: 'checkin'};
- return util.request(this.context, 'POST', path, inputData, false, 'catalog').then((result)=> {
+ return util.request(this.context, 'POST', path, inputData, 'catalog').then((result)=> {
this.context.component = {uniqueId : result.data.uniqueId, type : this.context.component.type};
});
});
@@ -135,7 +135,7 @@ When('I want to checkin this component', function () {
Then('I want to submit this component', function () {
let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/lifecycleState/certificationRequest' ;
let inputData = {userRemarks: 'submit'};
- return util.request(this.context, 'POST', path, inputData, false, 'catalog').then((result)=> {
+ return util.request(this.context, 'POST', path, inputData, 'catalog').then((result)=> {
this.context.component = {uniqueId : result.data.uniqueId};
});
});
@@ -143,7 +143,7 @@ Then('I want to submit this component', function () {
Then('I want to certify this component', function () {
let path = '/catalog/'+ this.context.component.type +'/' + this.context.component.uniqueId + '/lifecycleState/certify' ;
let inputData = {userRemarks: 'certify'};
- return util.request(this.context, 'POST', path, inputData, false, 'catalog').then((result)=> {
+ return util.request(this.context, 'POST', path, inputData, 'catalog').then((result)=> {
this.context.component = {uniqueId : result.data.uniqueId};
});
}); \ No newline at end of file
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/Item_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/Item_steps.js
index 3ff7f20f73..6f2c0872af 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/Item_steps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/Item_steps.js
@@ -15,7 +15,7 @@
*/
const {Then, When} = require('cucumber');
const assert = require('assert');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
/**
* @module Item
* @description uses item id and version id from context
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/NetworkPackage_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/NetworkPackage_steps.js
index 731d5b8470..cdb5cbe07d 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/NetworkPackage_steps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/NetworkPackage_steps.js
@@ -15,7 +15,7 @@
*/
const {Then, When} = require('cucumber');
const assert = require('assert');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
const _ = require('lodash');
const fs = require('fs');
require('node-zip');
@@ -28,7 +28,7 @@ require('node-zip');
**/
Then('I want to upload a NetworkPackage for this VSP from path {string}', function (string) {
let path = '/vendor-software-products/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/orchestration-template-candidate';
- return util.request(this.context, 'POST', path, string, true);
+ return util.requestBinaryFormData(this.context, 'POST', path, string, 'upload');
});
/**
@@ -37,9 +37,9 @@ Then('I want to upload a NetworkPackage for this VSP from path {string}', functi
* @exampleFile Example_HEAT.feature
* @step I want to download the NetworkPackage for this VSP to path {string}
**/
-When('I want to download the NetworkPackage for this VSP to path {string}', function (string, callback) {
+When('I want to download the NetworkPackage for this VSP to path {string}', function (string) {
let path = '/vendor-software-products/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/orchestration-template-candidate';
- return [util.download(this.context, path, string, callback)];
+ return util.download(this.context, path, string);
});
/**
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/Questionnaire_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/Questionnaire_steps.js
index 2e169fadc8..8da747eadb 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/Questionnaire_steps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/Questionnaire_steps.js
@@ -15,7 +15,7 @@
*/
const {Then, When} = require('cucumber');
const assert = require('assert');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
const _ = require('lodash');
function getPath(path, context) {
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/REST_Steps.js b/cucumber-js-test-apis-ci/stepDefinitions/REST_Steps.js
index c3844124d7..4671f36db5 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/REST_Steps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/REST_Steps.js
@@ -15,7 +15,7 @@
*/
const {When} = require('cucumber');
const _ = require('lodash');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
_.templateSettings.interpolate = /{([\s\S]+?)}/g;
function getPath(path, context) {
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/Toggle_Steps.js b/cucumber-js-test-apis-ci/stepDefinitions/Toggle_Steps.js
index 16bcc2afb9..8b416fc07d 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/Toggle_Steps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/Toggle_Steps.js
@@ -16,7 +16,7 @@
const {Then, When, Given} = require('cucumber');
const assert = require('assert');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
/**
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/Utils.js b/cucumber-js-test-apis-ci/stepDefinitions/Utils.js
deleted file mode 100644
index 66e959f6e5..0000000000
--- a/cucumber-js-test-apis-ci/stepDefinitions/Utils.js
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright © 2016-2017 European Support Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-const request = require('request');
-const fs = require('fs');
-require('node-zip');
-
-function _request(context, method, path, data, isBinary=false, type='onboarding') {
- let server = context.getUrlForType(type);
-
- let options = {
- method: method,
- url: server + path,
- headers: context.headers[type]
- };
- console.log('--> Calling REST ' + options.method +' url: ' + options.url);
-
- return new Promise(function (resolve, reject) {
- if (method === 'POST' || method === 'PUT') {
- if (isBinary) {
- var formData = {
- upload: fs.createReadStream(data),
- };
- options.formData = formData;
- } else {
- options.json = data;
- }
- }
- request(options, function (err, result, data) {
- context.inputData = null;
- if (err) {
- console.error('Request URL: ' + result.request.uri.href);
- console.error('Request Method: ' + result.request.method);
- console.error('Response Status Code: ' +result.statusCode);
- console.log(err);
- reject(err);
- } else {
- let isExpected = (context.shouldFail) ? (result.statusCode != 200 && result.statusCode != 201) : (result.statusCode == 200 || result.statusCode == 201);
- if (!isExpected) {
- console.error('Request URL: ' + result.request.uri.href);
- console.error('Request Method: ' + result.request.method);
- console.error('Response Status Code: ' +result.statusCode);
- console.error(result.body);
- reject('Status Code was ' + result.statusCode);
- }
- if (context.shouldFail && context.errorCode) {
- if (typeof data === 'string' && data) {
- data = JSON.parse(data);
- }
- let errorCode = data.errorCode;
- let contextErrorCode = context.errorCode;
- context.errorCode = null;
- if (errorCode !== contextErrorCode) {
- reject('Error Code was ' + errorCode + ' instead of ' + contextErrorCode);
- }
- }
- if (context.shouldFail && context.errorMessage) {
- if (typeof data === 'string' && data) {
- data = JSON.parse(data);
- }
- let errorMessage = data.message;
- let contextErrorMessage = context.errorMessage;
- context.errorMessage = null;
- if (errorMessage !== contextErrorMessage) {
- reject('Error Message was ' + errorMessage + ' instead of ' + contextErrorMessage);
- }
- }
- if (context.shouldFail) {
- context.shouldFail = false;
- resolve({statusCode: result.statusCode, data: {}});
- return;
- }
- if (method === 'GET' && isBinary) {
- // downloading (NetworkPackage) files
- return ({
- blob: blobUtil.createBlob([data], {type: 'text/plain'}),
- headers: result.headers
- });
- } else {
- if (typeof data === 'string' && data) {
- data = JSON.parse(data);
- }
- context.responseData = data;
- context.inputData = data;
- resolve({statusCode: result.statusCode, data: data});
- }
- }
- });
- });
-}
-
-function download(context, path, filePath, callback, type='onboarding') {
- let server = context.getUrlForType(type);
- let options = {
- method: 'GET',
- url: server + path,
- headers: context.headers[type]
- };
- console.log('--> Calling REST download url: ' + options.url);
-
- var file = fs.createWriteStream(filePath);
- var r = request(options).pipe(file);
- r.on('error', function (err) {
- console.log(err);
- callback(err);
- });
- r.on('finish', function () {
- file.close();
- let zipFile = fs.readFileSync(filePath, 'binary');
- let zip = new JSZip(zipFile, {base64: false, checkCRC32: true});
- if (zip.files['MANIFEST.json']) {
- let manifestData = zip.files['MANIFEST.json']._data;
- manifestData = manifestData.replace(/\\n/g, '');
- context.responseData = JSON.parse(manifestData);
- }
- callback();
- });
-
-};
-
-function _random() {
- let d = new Date();
- return d.getTime().toString().split('').reverse().join('');
-}
-
-function _getJSONFromFile(file) {
- return JSON.parse(fs.readFileSync(file, 'utf8'));
-}
-
-
-module.exports = {
- request: _request,
- random : _random,
- getJSONFromFile: _getJSONFromFile,
- download: download
-};
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/VF_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/VF_steps.js
index a24a90b0a5..b753105e8a 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/VF_steps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/VF_steps.js
@@ -15,7 +15,7 @@
*/
const {Then, When} = require('cucumber');
const assert = require('assert');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
/**
@@ -37,7 +37,7 @@ Then('I want to create a VF for this Item', function () {
this.context.inputData.tags[0] = result.data.name;
this.context.inputData.vendorName = result.data.vendorName;
this.context.inputData.csarUUID = this.context.item.id;
- return util.request(this.context, 'POST', '/catalog/resources', this.context.inputData, false, 'catalog');
+ return util.request(this.context, 'POST', '/catalog/resources', this.context.inputData, 'catalog');
});
});
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/VLM_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/VLM_steps.js
index 35e78b2d97..9990bf2717 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/VLM_steps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/VLM_steps.js
@@ -15,7 +15,7 @@
*/
const {Then, When, Given} = require('cucumber');
const assert = require('assert');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
/**
* @module VLM
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/VSP_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/VSP_steps.js
index b9b928a7f6..2feb29d7a6 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/VSP_steps.js
+++ b/cucumber-js-test-apis-ci/stepDefinitions/VSP_steps.js
@@ -15,7 +15,7 @@
*/
const {Then, When} = require('cucumber');
const assert = require('assert');
-const util = require('./Utils.js');
+const util = require('../cucumber-common/utils/Utils.js');
const _ = require('lodash');
@@ -107,9 +107,9 @@ Then('I want to add a component', function () {
* @exampleFile Example_VSP.feature
* @step I want to get the package for this Item to path {string}
**/
-When('I want to get the package for this Item to path {string}', function (string, callback) {
+When('I want to get the package for this Item to path {string}', function (string) {
let path = '/vendor-software-products/packages/' + this.context.item.id;
- return [util.download(this.context, path, string, callback)];
+ return util.download(this.context, path, string);
});
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/world.js b/cucumber-js-test-apis-ci/stepDefinitions/world.js
deleted file mode 100644
index eaf48aa31f..0000000000
--- a/cucumber-js-test-apis-ci/stepDefinitions/world.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright © 2016-2017 European Support Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-const { setWorldConstructor } = require('cucumber');
-const _ = require('lodash');
-
-let config = require('../config.json');
-let localConfig = {};
-try {
- localConfig = require('../devConfig.json');
-} catch (e) {
- try {
- localConfig = require('../environments/dockerConfig.json');
- } catch (e) {
- console.error("no env configuration was found!");
- }
-}
-
-config = _.merge(config, localConfig);
-var {setDefaultTimeout} = require('cucumber');
-
-
-/**
- * @module Context
- * @description Context that is used per feature file and can be accessed as 'this.context' in all steps.<Br>
- *<Br>
- * Contains the following items:<br>
- * <li>this.context.server <ul>REST server and onboarding prefix including version. set either in configuration file or from the command line or SERVER environment variable</ul>
- * <li>this.context.vlm <ul>When a VLM has been created, this has the an id and versionId set to the correct IDs.</ul>
- * <li>this.context.vsp <ul>When a VSP has been created, this has the an id and versionId and componentId set to the correct IDs.</ul>
- * <li>this.context.item <ul>When a VLM or VSP has been created, this has the an id and versionId set to the correct IDs.</ul>
- * <li>this.context <ul>Object with properties that were saved in the steps.</ul>
- * <li>this.context.inputdata <ul><b>Automatically updated with the last responseData from the Rest call</b><br>Object with properties that were prepares in the steps.</ul>
- * <li>this.context.responseData <ul>Response from the last REST call.</ul>
- **/
-class CustomWorld {
- constructor(options) {
- this.context = {};
- this.context.headers = {};
- let typeName;
- for (typeName in config) {
- this.context.headers[typeName] = {};
- if (config[typeName].user) {
- this.context.headers[typeName]['USER_ID'] = config[typeName].user;
- }
- }
-
- this.context.vlm = {id: null, versionId: null};
- this.context.vsp = {id: null, versionId: null};
- this.context.item = {id: null, versionId: null, componentId: null};
-
- this.context.shouldFail = false;
- this.context.errorCode = null;
- this.context.inputData = null;
- this.context.responseData = null;
-
- this.context.defaultServerType = 'onboarding';
-
- this.config = config;
-
- let context = this.context;
- this.context.getUrlForType = (function(type) {
- var _server = context.server;
- var _config = config;
- return function(type) {
- let typeData = _config[type];
- let _url = _config.protocol + '://' +
- typeData.server + ':' +
- typeData.port + '/' +
- typeData.prefix;
- return _url;
- }
- })();
-
- setDefaultTimeout(60 * 1000);
- }
-}
-
-
-setWorldConstructor(CustomWorld);