From ad3c41b5693b4f0b2a151e9c3221551e24f8264d Mon Sep 17 00:00:00 2001 From: ilanap Date: Wed, 25 Apr 2018 13:39:19 +0300 Subject: Fix for BDD multiple servers Change-Id: Ibfc9813e471d4ac2509ee5e62828a07661cc704e Issue-ID: SDC-1262 Signed-off-by: ilanap --- .../stepDefinitions/Collaboration_Steps.js | 2 +- openecomp-bdd/stepDefinitions/Utils.js | 4 +-- openecomp-bdd/stepDefinitions/VF_steps.js | 2 +- openecomp-bdd/stepDefinitions/world.js | 36 +++++++++++++--------- 4 files changed, 26 insertions(+), 18 deletions(-) (limited to 'openecomp-bdd/stepDefinitions') diff --git a/openecomp-bdd/stepDefinitions/Collaboration_Steps.js b/openecomp-bdd/stepDefinitions/Collaboration_Steps.js index 5b5062cf34..c4de758300 100644 --- a/openecomp-bdd/stepDefinitions/Collaboration_Steps.js +++ b/openecomp-bdd/stepDefinitions/Collaboration_Steps.js @@ -109,5 +109,5 @@ When('I want to get the permissions for this Item', function() { * @step I want to set the user to {string} **/ When('I want to set the user to {string}', function(string) { - this.context.headers.USER_ID = string; + this.context.headers['onboarding'].USER_ID = string; }); diff --git a/openecomp-bdd/stepDefinitions/Utils.js b/openecomp-bdd/stepDefinitions/Utils.js index 46534072f2..66e959f6e5 100644 --- a/openecomp-bdd/stepDefinitions/Utils.js +++ b/openecomp-bdd/stepDefinitions/Utils.js @@ -23,7 +23,7 @@ function _request(context, method, path, data, isBinary=false, type='onboarding' let options = { method: method, url: server + path, - headers: context.headers + headers: context.headers[type] }; console.log('--> Calling REST ' + options.method +' url: ' + options.url); @@ -106,7 +106,7 @@ function download(context, path, filePath, callback, type='onboarding') { let options = { method: 'GET', url: server + path, - headers: context.headers + headers: context.headers[type] }; console.log('--> Calling REST download url: ' + options.url); diff --git a/openecomp-bdd/stepDefinitions/VF_steps.js b/openecomp-bdd/stepDefinitions/VF_steps.js index 268c371687..3411a25fcb 100644 --- a/openecomp-bdd/stepDefinitions/VF_steps.js +++ b/openecomp-bdd/stepDefinitions/VF_steps.js @@ -29,7 +29,7 @@ Then('I want to create a VF for this Item', function () { return util.request(this.context, 'GET', '/vendor-software-products/' + this.context.item.id + '/versions/' + this.context.item.versionId).then(result => { this.context.inputData = util.getJSONFromFile('resources/json/createVF.json'); // start replacing stuff - this.context.inputData.contactId = this.context.headers["USER_ID"]; + this.context.inputData.contactId = this.context.headers['vf']["USER_ID"]; this.context.inputData.categories[0].uniqueId = result.data.category; this.context.inputData.categories[0].subcategories[0].uniqueId = result.data.subCategory; this.context.inputData.description = result.data.description; diff --git a/openecomp-bdd/stepDefinitions/world.js b/openecomp-bdd/stepDefinitions/world.js index 75f93afb89..0ffcc8e39c 100644 --- a/openecomp-bdd/stepDefinitions/world.js +++ b/openecomp-bdd/stepDefinitions/world.js @@ -14,13 +14,24 @@ * limitations under the License. */ const { setWorldConstructor } = require('cucumber'); -const config = require('../config.json'); -let localDevConfig = {}; +const _ = require('lodash'); + +let config = require('../config.json'); +let localConfig = {}; try { - localDevConfig = require('../devConfig.json'); -} catch (e) {} + localConfig = require('../devConfig.json'); +} catch (e) { + try { + localConfig = require('../jenkinsConfig.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.
@@ -38,15 +49,12 @@ class CustomWorld { constructor(options) { this.context = {}; this.context.headers = {}; - if (localDevConfig.user) { - this.context.headers['USER_ID'] = localDevConfig.user; - } else { - this.context.headers['USER_ID'] = process.env.USER; - } - if (localDevConfig.server) { - this.context.server = localDevConfig.server; - } else { - this.context.server = process.env.SERVER; + 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}; @@ -69,7 +77,7 @@ class CustomWorld { return function(type) { let typeData = _config[type]; let _url = _config.protocol + '://' + - _server + ':' + + typeData.server + ':' + typeData.port + '/' + typeData.prefix; return _url; -- cgit 1.2.3-korg