UTest for SRIOV
[sdc.git] / openecomp-bdd / stepDefinitions / Utils.js
index 08d0a2b..66e959f 100644 (file)
@@ -17,14 +17,16 @@ 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,
                url: server + path,
-               headers: context.headers
+               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) {
@@ -99,13 +101,16 @@ 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,
-                       headers: context.headers
+                       url: server + path,
+                       headers: context.headers[type]
                };
-               var file = fs.createWriteStream(filePath);
+       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);