aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cucumber-js-test-apis-ci/config.json12
-rw-r--r--cucumber-js-test-apis-ci/cucumber-common/package.json37
-rw-r--r--cucumber-js-test-apis-ci/cucumber-common/plugins/README.md (renamed from cucumber-js-test-apis-ci/plugins/README.md)5
-rw-r--r--cucumber-js-test-apis-ci/cucumber-common/plugins/jsdoc_config.json (renamed from cucumber-js-test-apis-ci/plugins/jsdoc_config.json)3
-rw-r--r--cucumber-js-test-apis-ci/cucumber-common/plugins/reporter.js (renamed from cucumber-js-test-apis-ci/plugins/reporter.js)0
-rw-r--r--cucumber-js-test-apis-ci/cucumber-common/plugins/steps.js (renamed from cucumber-js-test-apis-ci/plugins/steps.js)0
-rw-r--r--cucumber-js-test-apis-ci/cucumber-common/stepDefinitions/world.js (renamed from cucumber-js-test-apis-ci/stepDefinitions/world.js)41
-rw-r--r--cucumber-js-test-apis-ci/cucumber-common/utils/UpdateTestConfig.js81
-rw-r--r--cucumber-js-test-apis-ci/cucumber-common/utils/Utils.js223
-rw-r--r--cucumber-js-test-apis-ci/cucumber.js2
-rw-r--r--cucumber-js-test-apis-ci/dev_pom.xml138
-rw-r--r--cucumber-js-test-apis-ci/docker/Dockerfile11
-rw-r--r--cucumber-js-test-apis-ci/docker/startup.sh7
-rw-r--r--cucumber-js-test-apis-ci/package.json8
-rw-r--r--cucumber-js-test-apis-ci/pom.xml155
-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
30 files changed, 575 insertions, 358 deletions
diff --git a/cucumber-js-test-apis-ci/config.json b/cucumber-js-test-apis-ci/config.json
index 00c6552482..fdee980b09 100644
--- a/cucumber-js-test-apis-ci/config.json
+++ b/cucumber-js-test-apis-ci/config.json
@@ -1,22 +1,28 @@
{
- "protocol" : "http",
-
"onboarding" : {
+ "protocol" : "http",
"port" : "onboarding.port",
"prefix" : "onboarding-api/v1.0",
"server" : "onboarding.server",
- "user" : "onboarding.user"
+ "user" : "onboarding.user",
+ "isDefault" : true
},
"catalog" : {
+ "protocol" : "http",
"port" : "CatalogBE.port",
"prefix" : "sdc2/rest/v1",
"server" : "CatalogBE.server",
"user" : "CatalogBE.user"
},
"activity_spec" : {
+ "protocol" : "http",
"port" : "activity-spec.port",
"prefix" : "activity-spec-api/v1.0",
"server" : "activity_spec.server",
"user" : "activity-spec.user"
+ },
+ "initData" : {
+ "vlm" : {"id": null, "versionId": null},
+ "vsp" : {"id": null, "versionId": null}
}
}
diff --git a/cucumber-js-test-apis-ci/cucumber-common/package.json b/cucumber-js-test-apis-ci/cucumber-common/package.json
new file mode 100644
index 0000000000..1efc8f12ad
--- /dev/null
+++ b/cucumber-js-test-apis-ci/cucumber-common/package.json
@@ -0,0 +1,37 @@
+{
+ "name": "cucumber-common",
+ "version": "1.0.14",
+ "description": "Cucumber common methods and utilities",
+ "repository": "",
+ "main": "index.js",
+ "directories": {
+ "doc": "docs"
+ },
+ "scripts": {
+ "test": "cucumber-js",
+ "test-and-report": "npm-run-all -c -s test cucumber-html-report",
+ "cucumber-html-report": "node plugins/reporter.js",
+ "cucumber-docs": "jsdoc ./stepDefinitions -c plugins/jsdoc_config.json --readme plugins/README.md"
+ },
+ "author": "",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "assert": "^1.4.1",
+ "btoa": "^1.2.1",
+ "cucumber": "^5.1.0",
+ "cucumber-html-reporter": "^4.0.4",
+ "docdash": "^1.0.2",
+ "find-up": "^4.1.0",
+ "jsdoc": "^3.5.5",
+ "jsdoc-one-page": "0.0.5",
+ "lodash": "^4.17.11",
+ "md5": "^2.2.1",
+ "needle": "^2.4.0",
+ "node-zip": "^1.1.1",
+ "normalize-newline": "^3.0.0",
+ "npm-run-all": "^4.1.2",
+ "request": "^2.83.0",
+ "yamljs": "^0.3.0"
+ },
+ "devDependencies": {}
+}
diff --git a/cucumber-js-test-apis-ci/plugins/README.md b/cucumber-js-test-apis-ci/cucumber-common/plugins/README.md
index a57d61b1bb..9eaeb8f3a6 100644
--- a/cucumber-js-test-apis-ci/plugins/README.md
+++ b/cucumber-js-test-apis-ci/cucumber-common/plugins/README.md
@@ -7,8 +7,9 @@ The Modules on the left contains all steps for particalar aress and/or explanati
<li> Copy the config.json to devConfig.json
<li> Replace the server and user values with the correct values
<h3>How to run with Maven</h3>
-<li>"mvn clean install -f dev_pom.xml" will install npm if needed, download all modules and create the documentation under the "docs" folder
-<li>"mvn test-and-report" will run all tests in the features folder and create an HTML report under the "reports" folder
+<li>"mvn clean install" will install npm if needed, download all modules
+<li> run "mvn install -DskipTests=true -P dev" to create the documentation under the "docs" folder
+<li>"mvn test -P dev" will run all tests in the features folder and create an HTML report under the "reports" folder
<h3>How to develop tests</h3>
You can open the project in IntelliJ and Webstorm to run and develop scenarios.<br>
<li><b>You will need to install the Cucumber.Js plugin</b> In order to install, go to "Settings/Plugins". If cucumber.js in not on the list, go to "Browse repositories.." and install .
diff --git a/cucumber-js-test-apis-ci/plugins/jsdoc_config.json b/cucumber-js-test-apis-ci/cucumber-common/plugins/jsdoc_config.json
index a5a608e805..2757000472 100644
--- a/cucumber-js-test-apis-ci/plugins/jsdoc_config.json
+++ b/cucumber-js-test-apis-ci/cucumber-common/plugins/jsdoc_config.json
@@ -7,7 +7,8 @@
"outputSourceFiles": false
}
},
- "plugins": ["plugins/steps"],
+
+ "plugins": ["./steps"],
"opts": {
"template": "node_modules/jsdoc-one-page",
"destination": "docs/"
diff --git a/cucumber-js-test-apis-ci/plugins/reporter.js b/cucumber-js-test-apis-ci/cucumber-common/plugins/reporter.js
index 8913789c95..8913789c95 100644
--- a/cucumber-js-test-apis-ci/plugins/reporter.js
+++ b/cucumber-js-test-apis-ci/cucumber-common/plugins/reporter.js
diff --git a/cucumber-js-test-apis-ci/plugins/steps.js b/cucumber-js-test-apis-ci/cucumber-common/plugins/steps.js
index 2faa7efbd8..2faa7efbd8 100644
--- a/cucumber-js-test-apis-ci/plugins/steps.js
+++ b/cucumber-js-test-apis-ci/cucumber-common/plugins/steps.js
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/world.js b/cucumber-js-test-apis-ci/cucumber-common/stepDefinitions/world.js
index eaf48aa31f..7811aba886 100644
--- a/cucumber-js-test-apis-ci/stepDefinitions/world.js
+++ b/cucumber-js-test-apis-ci/cucumber-common/stepDefinitions/world.js
@@ -15,14 +15,24 @@
*/
const { setWorldConstructor } = require('cucumber');
const _ = require('lodash');
+const findUp = require('find-up');
-let config = require('../config.json');
+
+
+let configPath = findUp.sync('config.json');
+configPath = configPath.replace(/\\/g, '/');
+
+let config = require(configPath);
let localConfig = {};
try {
- localConfig = require('../devConfig.json');
+ let devConfigPath = findUp.sync('devConfig.json');
+ devConfigPath = devConfigPath.replace(/\\/g, '/');
+ localConfig = require(devConfigPath);
} catch (e) {
try {
- localConfig = require('../environments/dockerConfig.json');
+ let envdir = findUp.sync('environments', {type: 'directory'});
+ envdir = envdir.replace(/\\/g, '/');
+ localConfig = require(envdir + '/dockerConfig.json');
} catch (e) {
console.error("no env configuration was found!");
}
@@ -35,11 +45,10 @@ 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>
+ * This class can be extended in order to add additional configurations.
*<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>
@@ -50,23 +59,32 @@ class CustomWorld {
this.context = {};
this.context.headers = {};
let typeName;
+
+ this.context.defaultServerType = 'main';
for (typeName in config) {
this.context.headers[typeName] = {};
if (config[typeName].user) {
this.context.headers[typeName]['USER_ID'] = config[typeName].user;
}
+ // adding additional headers
+ if (config[typeName].additionalHeaders) {
+ _.assign(this.context.headers[typeName] , config[typeName].additionalHeaders);
+ }
+ if (config[typeName].isDefault !== undefined && config[typeName].isDefault) {
+ this.context.defaultServerType = typeName;
+ }
}
-
- this.context.vlm = {id: null, versionId: null};
- this.context.vsp = {id: null, versionId: null};
this.context.item = {id: null, versionId: null, componentId: null};
+ // adding the default items that should also be initialized
+ if (config.initData) {
+ _.assign(this.context, config.initData);
+ }
this.context.shouldFail = false;
this.context.errorCode = null;
this.context.inputData = null;
this.context.responseData = null;
- this.context.defaultServerType = 'onboarding';
this.config = config;
@@ -76,17 +94,14 @@ class CustomWorld {
var _config = config;
return function(type) {
let typeData = _config[type];
- let _url = _config.protocol + '://' +
+ let _url = typeData.protocol + '://' +
typeData.server + ':' +
typeData.port + '/' +
typeData.prefix;
return _url;
}
})();
-
setDefaultTimeout(60 * 1000);
}
}
-
-
setWorldConstructor(CustomWorld);
diff --git a/cucumber-js-test-apis-ci/cucumber-common/utils/UpdateTestConfig.js b/cucumber-js-test-apis-ci/cucumber-common/utils/UpdateTestConfig.js
new file mode 100644
index 0000000000..a2c1dae2f7
--- /dev/null
+++ b/cucumber-js-test-apis-ci/cucumber-common/utils/UpdateTestConfig.js
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+'use strict'
+
+const fs = require('fs');
+
+var pathToRoot = process.env.TESTS_BASE;
+if (!pathToRoot.endsWith("/")) {
+ pathToRoot += "/";
+}
+var envConfig = require(pathToRoot + 'config.json');
+var protocol = (process.env.PROTOCOL !== undefined) ? process.env.PROTOCOL : 'https';
+
+try {
+ envConfig = require(pathToRoot + 'environments/dockerConfig.json');
+} catch (e) {
+}
+
+function run() {
+ var inputArgs = process.argv.slice(2);
+ let changeConfig = false;
+ if (process.env.K8S_CONF_PATH !== undefined) {
+ console.log('updating with kubernetes services');
+ let k8sConfig = require(pathToRoot + process.env.K8S_CONF_PATH);
+ mapK8sPod2Docker(k8sConfig, inputArgs[0], inputArgs[1]);
+ changeConfig = true;
+ } else {
+ console.log('not updating at all');
+ }
+ if (changeConfig) {
+ let data = JSON.stringify(envConfig, null, 2);
+ console.log('writing config file: ' + pathToRoot+'environments/dockerConfig.json');
+ console.log(data);
+ fs.writeFileSync(pathToRoot+'environments/dockerConfig.json', data);
+ }
+}
+
+function mapK8sPod2Docker(k8sConfig, id, k8sid) {
+ let item = k8sConfig.items.find(item => {
+ if (item.spec !== undefined && item.spec.ports !== undefined) {
+ let spec = item.spec.ports.find(port => {
+ if (port.name === k8sid) {
+ return true;
+ }
+ });
+ return (spec !== undefined);
+ } else {
+ return false;
+ }
+ });
+
+ item.spec.ports.forEach(port => {
+ if (port.name === k8sid) {
+ envConfig[id].port = port.nodePort;
+ let rancherData = JSON.parse(item.metadata.annotations["field.cattle.io/publicEndpoints"]);
+ let address = rancherData.find(address => {
+ return address.port === port.nodePort;
+ });
+ envConfig[id].port = address.port;
+ envConfig[id].server = address.addresses[0];
+ envConfig[id].protocol = protocol;
+ envConfig[id].user = process.env.SDC_USER_ID;
+ }
+ });
+
+}
+
+run();
diff --git a/cucumber-js-test-apis-ci/cucumber-common/utils/Utils.js b/cucumber-js-test-apis-ci/cucumber-common/utils/Utils.js
new file mode 100644
index 0000000000..22ee775080
--- /dev/null
+++ b/cucumber-js-test-apis-ci/cucumber-common/utils/Utils.js
@@ -0,0 +1,223 @@
+/*
+ * 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 needle = require('needle');
+const fs = require('fs');
+require('node-zip');
+var btoa = require('btoa');
+const md5 = require('md5');
+const _ = require('lodash');
+
+function getOptionsForRequest(context, method, path, type) {
+ if (type == undefined || type == null) {
+ type = context.defaultServerType
+ }
+ let server = context.getUrlForType(type);
+ let options = {
+ method: method,
+ url: server + path,
+ headers: _.clone(context.headers[type])
+ };
+// options.headers["Content-Type"] = "application/json";
+// options.headers["accept"] = "application/json";
+ return options;
+}
+
+function _requestBinaryFormData(context, method, path, fileName, formInputName, type) {
+ let options = getOptionsForRequest(context, method, path, type);
+ let formData = {};
+ if (method === 'POST' || method === 'PUT') {
+ //formData[formInputName] = fs.createReadStream(fileName);
+ //options.formData = formData;
+ let fileData = {
+ file: fileName
+ };
+ fileData['content_type'] = 'multipart/form-data';
+ options.formData = {};
+ options.formData[formInputName] = fileData;
+ }
+ return _request(context, method, path, options);
+}
+function _requestBinaryBody(context, method, path, fileName, type) {
+ let options = getOptionsForRequest(context, method, path, type);
+ if (method === 'POST' || method === 'PUT') {
+ options.body = fs.createReadStream(fileName);
+ options.headers['Content-Type'] = 'application/octet-stream';
+
+ }
+ return _request(context, method, path, options);
+}
+
+
+function _requestPayload(context, method, path, filePath, type) {
+ let options = getOptionsForRequest(context, method, path, type);
+ options.json = _createPayload(filePath);
+ options.headers['Content-MD5'] = addCheckSum(options.json);
+ return _request(context, method, path, options);
+}
+
+function _requestRest(context, method, path, data, type) {
+ let options = getOptionsForRequest(context, method, path, type);
+ if (method === 'POST' || method === 'PUT') {
+ options.json = data;
+ }
+ return _request(context, method, path, options);
+}
+
+function _request(context, method, path, options) {
+ console.log('--> Calling REST ' + options.method +' url: ' + options.url);
+ let inputData = options.json;
+ let needleOptions = {headers: options.headers, rejectUnauthorized: false};
+ if (inputData == undefined) {
+ if (options.formData != undefined) {
+ inputData = options.formData;
+ needleOptions.multipart = true;
+ }
+ if (inputData && inputData.body != undefined) {
+ inputData = options.body;
+ }
+ } else {
+ needleOptions.json = true;
+ }
+ return needle(method, options.url, inputData, needleOptions)
+ .then(function(result) {
+ context.inputData = null;
+ let isExpected = (context.shouldFail) ? (result.statusCode != 200 && result.statusCode != 201) : (result.statusCode == 200 || result.statusCode == 201);
+ data = result.body;
+ if (!isExpected) {
+ console.log('Did not get expected response code');
+ throw '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) {
+ throw '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) {
+ throw 'Error Message was ' + errorMessage + ' instead of ' + contextErrorMessage;
+ }
+ }
+ if (context.shouldFail) {
+ context.shouldFail = false;
+ return({statusCode: result.statusCode, data: {}});
+ }
+
+ if (typeof data === 'string' && data) {
+ if (data.startsWith('[') || data.startsWith('{')) {
+ data = JSON.parse(data);
+ }
+ }
+ context.responseData = data;
+ context.inputData = data;
+ return({statusCode: result.statusCode, data: data});
+
+ })
+ .catch(function(err) {
+ console.error('Request URL: ' + options.url);
+ console.error('Request Method: ' + options.method);
+ console.log(err);
+ throw err;
+ })
+}
+
+function download(context, path, filePath, type) {
+ if (type == undefined || type == null) {
+ type = context.defaultServerType
+ }
+ let server = context.getUrlForType(type);
+ let options = {
+ method: 'GET',
+ url: server + path,
+ headers: context.headers[type]
+ };
+
+ console.log('--> Calling REST download url: ' + options.url);
+ return needle('GET', options.url, {}, {
+ headers: options.headers,
+ rejectUnauthorized: false,
+ output: filePath
+ })
+ .then(function (result) {
+ 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);
+ }
+ return zip;
+ })
+ .catch(function (err) {
+ console.error('Request URL: ' + options.url);
+ console.error('Request Method: ' + options.method);
+ throw err;
+ })
+}
+
+function _random() {
+ let d = new Date();
+ return d.getTime().toString().split('').reverse().join('');
+}
+
+function _getJSONFromFile(file) {
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
+}
+
+function _createPayload(fileName) {
+ var body = fs.readFileSync(fileName);
+ let payload = {
+ payloadData: body.toString('base64'),
+ payloadName: fileName.substring(fileName.lastIndexOf("/") + 1 )
+ };
+ return payload;
+}
+
+function addCheckSum(payloadData) {
+ let _md5 = md5(JSON.stringify(payloadData));
+ return btoa(_md5.toLowerCase());
+}
+
+function _getFile(file, format) {
+ if(format === '' ){
+ return fs.readFileSync(file)
+ }
+ return fs.readFileSync(file, format);
+}
+
+
+module.exports = {
+ getFile: _getFile,
+ request: _requestRest,
+ requestPayload: _requestPayload,
+ requestBinaryFormData: _requestBinaryFormData,
+ requestBinaryBody: _requestBinaryBody,
+ random : _random,
+ getJSONFromFile: _getJSONFromFile,
+ download: download,
+ payload: _createPayload
+};
diff --git a/cucumber-js-test-apis-ci/cucumber.js b/cucumber-js-test-apis-ci/cucumber.js
index 0eb79d3ac5..0f3b6bc961 100644
--- a/cucumber-js-test-apis-ci/cucumber.js
+++ b/cucumber-js-test-apis-ci/cucumber.js
@@ -1,3 +1,3 @@
module.exports = {
- "default" : "--require stepDefinitions -f summary -r ./features -f summary:report/summary.txt -f json:report/report.json --format-options '{\"colorsEnabled\": false}'"
+ "default" : "--require stepDefinitions --require cucumber-common/stepDefinitions -f summary -r ./features -f summary:report/summary.txt -f json:report/report.json --format-options '{\"colorsEnabled\": false}'"
}; \ No newline at end of file
diff --git a/cucumber-js-test-apis-ci/dev_pom.xml b/cucumber-js-test-apis-ci/dev_pom.xml
deleted file mode 100644
index 7ad10f8d3f..0000000000
--- a/cucumber-js-test-apis-ci/dev_pom.xml
+++ /dev/null
@@ -1,138 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>onboarding-cucumber</artifactId>
- <name>cucumber-report</name>
-
- <parent>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>sdc-onboarding</artifactId>
- <version>1.3.1-SNAPSHOT</version>
- <relativePath>../onboarding/pom.xml</relativePath>
- </parent>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <version>2.6.1</version>
- <executions>
- <execution>
- <id>clean.dist.folder</id>
- <phase>clean</phase>
- <goals>
- <goal>clean</goal>
- </goals>
- <configuration>
- <filesets>
- <fileset>
- <directory>${basedir}/report</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileset>
- <fileset>
- <directory>${basedir}/resources/downloads</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileset>
- <fileset>
- <directory>${basedir}/docs</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileset>
- </filesets>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>create-reporting-folders</id>
- <phase>generate-sources</phase>
- <configuration>
- <tasks>
- <echo message="Generate reports and downloads folders"/>
- <mkdir dir="${basedir}/report"/>
- <mkdir dir="${basedir}/resources/downloads"/>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <!-- ============================================= -->
- <!-- Build the UI module node code -->
- <!-- ============================================= -->
- <plugin>
- <groupId>com.github.eirslett</groupId>
- <artifactId>frontend-maven-plugin</artifactId>
- <version>1.6</version>
-
- <configuration>
- <installDirectory>${project.parent.parent.basedir}</installDirectory>
- </configuration>
-
- <executions>
-
- <execution>
- <id>install node and yarn</id>
- <goals>
- <goal>install-node-and-yarn</goal>
- </goals>
- <configuration>
- <nodeVersion>v9.4.0</nodeVersion>
- <yarnVersion>v1.3.2</yarnVersion>
- </configuration>
- </execution>
-
- <execution>
- <id>yarn run install</id>
- <goals>
- <goal>yarn</goal>
- </goals>
- <configuration>
- <arguments>install</arguments>
- </configuration>
- </execution>
- <execution>
- <id>yarn run cucumber docs</id>
- <goals>
- <goal>yarn</goal>
- </goals>
- <configuration>
- <yarnInheritsProxyConfigFromMaven>false</yarnInheritsProxyConfigFromMaven>
- <arguments>run cucumber-docs</arguments>
- </configuration>
- </execution>
-
- <execution>
- <id>yarn run cucumber test</id>
- <goals>
- <goal>yarn</goal>
- </goals>
- <configuration>
- <yarnInheritsProxyConfigFromMaven>false</yarnInheritsProxyConfigFromMaven>
- <arguments>run test-and-report</arguments>
- </configuration>
- <phase>test</phase>
- </execution>
-
-
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/cucumber-js-test-apis-ci/docker/Dockerfile b/cucumber-js-test-apis-ci/docker/Dockerfile
index fb4409215f..eab4e89f30 100644
--- a/cucumber-js-test-apis-ci/docker/Dockerfile
+++ b/cucumber-js-test-apis-ci/docker/Dockerfile
@@ -1,11 +1,12 @@
FROM node:8.16.0
-
ENV TESTS_BASE /var/lib/tests
USER root
RUN mkdir $TESTS_BASE
-COPY cucumber $TESTS_BASE
-COPY startup.sh $TESTS_BASE
-RUN chmod 777 $TESTS_BASE/startup.sh
+RUN mkdir $TESTS_BASE/environments
+COPY cucumber $TESTS_BASE
+COPY startup.sh .
+RUN chmod 777 ./startup.sh
+RUN chmod -R 777 $TESTS_BASE/node_modules/
-ENTRYPOINT [ "/var/lib/tests/startup.sh" ]
+ENTRYPOINT [ "./startup.sh" ]
diff --git a/cucumber-js-test-apis-ci/docker/startup.sh b/cucumber-js-test-apis-ci/docker/startup.sh
index 3170411ae5..b3ad4f140a 100644
--- a/cucumber-js-test-apis-ci/docker/startup.sh
+++ b/cucumber-js-test-apis-ci/docker/startup.sh
@@ -1,6 +1,9 @@
#!/bin/bash
cd /var/lib/tests
+
+rm devConfig.json
+
mkdir resources/downloads
-yarn install
-yarn run test-and-report
+
+npm run test-and-report
diff --git a/cucumber-js-test-apis-ci/package.json b/cucumber-js-test-apis-ci/package.json
index 0aecbdc4fd..646b71fe30 100644
--- a/cucumber-js-test-apis-ci/package.json
+++ b/cucumber-js-test-apis-ci/package.json
@@ -9,19 +9,23 @@
"scripts": {
"test": "cucumber-js",
"test-and-report": "npm-run-all -c -s test cucumber-html-report",
- "cucumber-html-report": "node plugins/reporter.js",
- "cucumber-docs": "jsdoc ./stepDefinitions -c plugins/jsdoc_config.json --readme plugins/README.md"
+ "cucumber-html-report": "node cucumber-common/plugins/reporter.js",
+ "cucumber-docs": "jsdoc ./stepDefinitions -c cucumber-common/plugins/jsdoc_config.json --readme cucumber-common/plugins/README.md"
},
"author": "",
"license": "Apache-2.0",
"dependencies": {
"assert": "^1.4.1",
+ "btoa": "^1.2.1",
"cucumber": "^3.2.1",
"cucumber-html-reporter": "^3.0.4",
"docdash": "^0.4.0",
+ "find-up": "^4.1.0",
"jsdoc": "^3.5.5",
"jsdoc-one-page": "0.0.5",
"lodash": "^4.17.4",
+ "md5": "^2.2.1",
+ "needle": "^2.4.0",
"node-zip": "^1.1.1",
"normalize-newline": "^3.0.0",
"npm-run-all": "^4.1.2",
diff --git a/cucumber-js-test-apis-ci/pom.xml b/cucumber-js-test-apis-ci/pom.xml
index e24a7d2093..41c3352961 100644
--- a/cucumber-js-test-apis-ci/pom.xml
+++ b/cucumber-js-test-apis-ci/pom.xml
@@ -26,6 +26,12 @@
<configuration>
<filesets>
<fileset>
+ <directory>${basedir}/node_modules</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </fileset>
+ <fileset>
<directory>${basedir}/report</directory>
<includes>
<include>**/*</include>
@@ -60,6 +66,38 @@
<configuration>
</configuration>
</plugin>
+ <plugin>
+ <groupId>com.github.eirslett</groupId>
+ <artifactId>frontend-maven-plugin</artifactId>
+ <version>1.6</version>
+
+ <configuration>
+ <installDirectory>${project.parent.parent.basedir}</installDirectory>
+ </configuration>
+
+ <executions>
+ <execution>
+ <id>install node and npm</id>
+ <goals>
+ <goal>install-node-and-npm</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ <configuration>
+ <nodeVersion>v10.15.3</nodeVersion>
+ <npmVersion>6.4.1</npmVersion>
+ </configuration>
+ </execution>
+ <execution>
+ <id>npm run install</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <configuration>
+ <arguments>install</arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<resources>
<resource>
@@ -67,22 +105,84 @@
<targetPath>${project.build.directory}/docker_assembly</targetPath>
<filtering>false</filtering>
</resource>
- <resource>
- <directory>${basedir}</directory>
- <includes>
- <include>features/**/*</include>
- <include>stepDefinitions/**/*</include>
- <include>plugins/**/*</include>
- <include>resources/**/*</include>
- <include>*.js*</include>
- </includes>
- <targetPath>${project.build.directory}/docker_assembly/cucumber</targetPath>
- <filtering>false</filtering>
- </resource>
</resources>
</build>
<profiles>
<profile>
+ <id>dev</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-reporting-folders</id>
+ <phase>initialize</phase>
+ <configuration>
+ <tasks>
+ <echo message="Generate reports and downloads folders"/>
+ <mkdir dir="${basedir}/report"/>
+ <mkdir dir="${basedir}/resources/downloads"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.github.eirslett</groupId>
+ <artifactId>frontend-maven-plugin</artifactId>
+ <version>1.6</version>
+
+ <configuration>
+ <workingDirectory>${project.basedir}</workingDirectory>
+ <installDirectory>${project.parent.parent.basedir}</installDirectory>
+ </configuration>
+
+ <executions>
+
+ <execution>
+ <id>npm run install</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <configuration>
+ <arguments>install</arguments>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>npm run cucumber test</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <configuration>
+ <npmInheritsProxyConfigFromMaven>false</npmInheritsProxyConfigFromMaven>
+ <arguments>run test-and-report</arguments>
+ </configuration>
+ <phase>test</phase>
+ </execution>
+
+ <execution>
+ <id>npm run documentation</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <configuration>
+ <npmInheritsProxyConfigFromMaven>false</npmInheritsProxyConfigFromMaven>
+ <arguments>run cucumber-docs</arguments>
+ </configuration>
+ <phase>install</phase>
+ </execution>
+
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
<id>docker</id>
<activation>
<activeByDefault>false</activeByDefault>
@@ -90,6 +190,37 @@
<build>
<plugins>
<plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>3.0.2</version>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/docker_assembly/cucumber</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}</directory>
+ <includes>
+ <include>features/**/*</include>
+ <include>stepDefinitions/**/*</include>
+ <include>plugins/**/*</include>
+ <include>resources/**/*</include>
+ <include>node_modules/**/*</include>
+ <include>cucumber-common/**/*</include>
+ <include>*.js*</include>
+ </includes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
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);
});