aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-bdd/stepDefinitions
diff options
context:
space:
mode:
authorilanap <ilanap@amdocs.com>2018-02-19 10:36:26 +0200
committerilanap <ilanap@amdocs.com>2018-02-19 13:48:50 +0200
commitbd76c092d9929aa69682767855ba47b1ccc627d8 (patch)
tree57c7321e1fc8aeaaa6d6ea7214ca236c2a5b161e /openecomp-bdd/stepDefinitions
parent3437fc9044b05d53d20c2d5ca0cb5b0705bff155 (diff)
Fix for adding BDD prefixes for for download
Change-Id: Id796408470330300f79120ba5d39987989aff206 Issue-ID: SDC-990 Signed-off-by: ilanap <ilanap@amdocs.com>
Diffstat (limited to 'openecomp-bdd/stepDefinitions')
-rw-r--r--openecomp-bdd/stepDefinitions/Utils.js13
-rw-r--r--openecomp-bdd/stepDefinitions/world.js47
2 files changed, 40 insertions, 20 deletions
diff --git a/openecomp-bdd/stepDefinitions/Utils.js b/openecomp-bdd/stepDefinitions/Utils.js
index 08d0a2b10f..4a54ebe3a7 100644
--- a/openecomp-bdd/stepDefinitions/Utils.js
+++ b/openecomp-bdd/stepDefinitions/Utils.js
@@ -17,8 +17,8 @@ const request = require('request');
const fs = require('fs');
require('node-zip');
-function _request(context, method, path, data, isBinary=false, prefix='onboarding') {
- let server = context.server + '/' + context.prefix[prefix];
+function _request(context, method, path, data, isBinary=false, type='onboarding') {
+ let server = context.getUrlForType(type);
let options = {
method: method,
@@ -99,13 +99,14 @@ function _request(context, method, path, data, isBinary=false, prefix='onboardin
});
}
-function download(context, path, filePath, callback){
- let options = {
+function download(context, path, filePath, callback, type='onboarding') {
+ let server = context.getUrlForType(type);
+ let options = {
method: 'GET',
- url: context.onboarding_server + path,
+ url: server + path,
headers: context.headers
};
- var file = fs.createWriteStream(filePath);
+ var file = fs.createWriteStream(filePath);
var r = request(options).pipe(file);
r.on('error', function (err) {
console.log(err);
diff --git a/openecomp-bdd/stepDefinitions/world.js b/openecomp-bdd/stepDefinitions/world.js
index ba6d57a09b..fd7250548d 100644
--- a/openecomp-bdd/stepDefinitions/world.js
+++ b/openecomp-bdd/stepDefinitions/world.js
@@ -15,6 +15,10 @@
*/
const { setWorldConstructor } = require('cucumber');
const config = require('../config.json');
+let localDevConfig = {};
+try {
+ localDevConfig = require('../devConfig.json');
+} catch (e) {}
var {setDefaultTimeout} = require('cucumber');
/**
@@ -32,19 +36,18 @@ var {setDefaultTimeout} = require('cucumber');
**/
class CustomWorld {
constructor(options) {
- this.context = {}
- if (options.parameters && options.parameters.server) {
- this.context.server = options.parameters.server;
- } else if (process.env.SERVER) {
- this.context.server = process.env.SERVER;
+ this.context = {};
+ this.context.headers = {};
+ if (localDevConfig.user) {
+ this.context.headers['USER_ID'] = localDevConfig.user;
} else {
- this.context.server = config.server;
+ this.context.headers['USER_ID'] = process.env.USER;
+ }
+ if (localDevConfig.server) {
+ this.context.server = localDevConfig.server;
+ } else {
+ this.context.server = process.env.SERVER;
}
- this.context.server = (config.protocol + '://' + this.context.server + ':' + config.port);
-
-
- this.context.headers = {};
- this.context.headers['USER_ID'] = 'cs0008';
this.context.vlm = {id: null, versionId: null};
this.context.vsp = {id: null, versionId: null};
@@ -55,15 +58,31 @@ class CustomWorld {
this.context.inputData = null;
this.context.responseData = null;
+ this.context.defaultServerType = 'onboarding';
+
this.context.prefix = config.prefix;
+ this.context.port = config.port;
+ this.context.protocol = config.protocol;
this.setServer = function(server) {
- this.context.server = (config.protocol + '://' + this.context.server + ':' + config.port);
- }
+ this.context.server = server;
+ };
+
+ let context = this.context;
+ this.context.getUrlForType = (function(type) {
+ var that = context;
+ return function(type) {
+ let typeData = that[type];
+ return (config.protocol + '://' +
+ that.server + ':' +
+ typeData.port + '/' +
+ typeData.prefix);
+ }
+ })();
setDefaultTimeout(60 * 1000);
}
}
-setWorldConstructor(CustomWorld)
+setWorldConstructor(CustomWorld);