aboutsummaryrefslogtreecommitdiffstats
path: root/cucumber-js-test-apis-ci/stepDefinitions
diff options
context:
space:
mode:
authorilanap <ilanap@amdocs.com>2019-01-01 17:22:07 +0200
committerOren Kleks <orenkle@amdocs.com>2019-01-02 12:37:08 +0000
commit866418030975f2ee09a27d144de4e880218e84e8 (patch)
tree70a329025f0c382b658c667813dd4f9183e6e98e /cucumber-js-test-apis-ci/stepDefinitions
parent9da0b14bb0a0321f08458ba7b9148336e00d77d3 (diff)
docker for cucumber BDD
Issue-ID: SDC-2028 Change-Id: I7c1376c449ba7650c3bbc1838726cfd178d2ca40 Signed-off-by: ilanap <ilanap@amdocs.com>
Diffstat (limited to 'cucumber-js-test-apis-ci/stepDefinitions')
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/ActivitySpec_steps.js47
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/Collaboration_Steps.js113
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/General_Steps.js304
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/GlobalTypes.js24
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/InputData_steps.js94
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/InterfaceOperationSteps.js156
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/Item_steps.js91
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/NetworkPackage_steps.js54
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/Questionnaire_steps.js129
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/REST_Steps.js80
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/Toggle_Steps.js48
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/Utils.js148
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/VF_steps.js43
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/VLM_steps.js79
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/VSP_steps.js185
-rw-r--r--cucumber-js-test-apis-ci/stepDefinitions/world.js92
16 files changed, 1687 insertions, 0 deletions
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/ActivitySpec_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/ActivitySpec_steps.js
new file mode 100644
index 0000000000..7fe8ddf201
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/ActivitySpec_steps.js
@@ -0,0 +1,47 @@
+/*
+ * Copyright © 2016-2018 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 {Then, When} = require('cucumber');
+const assert = require('assert');
+const util = require('./Utils.js');
+const _ = require('lodash');
+
+When('I want to create an ActivitySpec', function () {
+ let path = '/activity-spec';
+ return util.request(this.context, 'POST', path, this.context.inputData, false, 'activity_spec').then((result)=> {
+ this.context.item = {id : result.data.id, versionId: result.data.versionId};
+ this.context.activityspec = {id : result.data.id, versionId: result.data.versionId};
+ });
+});
+
+When('I want to list ActivitySpecs with status {string}', function (string) {
+ let path = '/activity-spec?status='+string;
+ return util.request(this.context, 'GET', path, null, false, 'activity_spec').then((result)=> {
+ this.context.listCount = result.data.listCount;
+ });
+});
+
+When('I want to get the ActivitySpec for the current item', function () {
+ let path = '/activity-spec/'+ this.context.item.id+'/versions/'+this.context.item.versionId ;
+ return util.request(this.context, 'GET', path, null, false, 'activity_spec').then((result)=> {
+ });
+});
+
+Then('I want to call action {string} on this ActivitySpec item', function(string) {
+ let path = '/activity-spec/'+ this.context.item.id+'/versions/'+this.context.item.versionId+'/actions' ;
+ let inputData = JSON.parse('{"action" : "' +string+ '"}');
+ return util.request(this.context, 'PUT', path, inputData, false, 'activity_spec')
+}); \ No newline at end of file
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/Collaboration_Steps.js b/cucumber-js-test-apis-ci/stepDefinitions/Collaboration_Steps.js
new file mode 100644
index 0000000000..c4de758300
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/Collaboration_Steps.js
@@ -0,0 +1,113 @@
+/*
+ * 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 {Then, When, Given} = require('cucumber');
+const assert = require('assert');
+const util = require('./Utils.js');
+
+/**
+ * @module Collaboration
+ * @description Adds the user with the given user ID as a contributor on the item
+ * @exampleFile Example_Collaboration.feature
+ * @step I want to add user {string} as a contributor to this Item
+ **/
+When('I want to add user {string} as a contributor to this Item', function(string) {
+ let path = '/items/' + this.context.item.id + '/permissions/Contributor';
+ let inputData = {removedUsersIds:[],addedUsersIds:[string]};
+ return util.request(this.context, 'PUT', path, inputData);
+});
+
+/**
+ * @module Collaboration
+ * @description Adds the user with the given user ID as a contributor on the item
+ * @exampleFile Example_Collaboration.feature
+ * @step I want to remove user {string} as a contributor to this Item
+ **/
+When('I want to remove user {string} as a contributor to this Item', function(string) {
+ let path = '/items/' + this.context.item.id + '/permissions/Contributor';
+ let inputData = {removedUsersIds:[string],addedUsersIds:[]};
+ return util.request(this.context, 'PUT', path, inputData);
+});
+
+/**
+ * @module Collaboration
+ * @description Changes the owner to the given User ID
+ * @exampleFile Example_Collaboration.feature
+ * @step I want to change the owner to user {string} on this Item
+ **/
+When('I want to change the owner to user {string} on this Item', function(string) {
+ let path = '/items/' + this.context.item.id + '/permissions/Owner';
+ let inputData = {removedUsersIds:[],addedUsersIds:[string]};
+ return util.request(this.context, 'PUT', path, inputData);
+});
+
+
+/**
+ * @module Collaboration
+ * @description Checks the role for a user on the item by User id and Role can be either: Contributor/Owner
+ * @exampleFile Example_Collaboration.feature
+ * @step I want check user {string} has role {string} on this Item
+ **/
+When('I want to check user {string} has role {string} on this Item', function(string, string2) {
+ let path = '/items/' + this.context.item.id + '/permissions';
+ return util.request(this.context, 'GET', path).then(results => {
+ for (i in results.data.results) {
+ if (results.data.results[i].userId === string) {
+ assert.equal(string2.toLowerCase(), results.data.results[i].permission.toLowerCase());
+ return;
+ }
+ }
+ assert.fail('User not found');
+ });
+});
+
+/**
+ * @module Collaboration
+ * @description Checks the user wth this Id has no permissions on this item
+ * @exampleFile Example_Collaboration.feature
+ * @step I want check user {string} has rno permissions on this Item
+ **/
+When('I want to check user {string} has no permissions on this Item', function(string) {
+ let path = '/items/' + this.context.item.id + '/permissions';
+ return util.request(this.context, 'GET', path).then(results => {
+ for (i in results.data.results) {
+ if (results.data.results[i].userId === string) {
+ assert.fail('Found', null, 'User should not have permissions');
+ return;
+ }
+ }
+ });
+});
+
+/**
+ * @module Collaboration
+ * @description Gets the permissions for the Item
+ * @exampleFile Example_Collaboration.feature
+ * @step I want to get the permissions for this Item
+ **/
+When('I want to get the permissions for this Item', function() {
+ let path = '/items/' + this.context.item.id + '/permissions';
+ return util.request(this.context, 'GET', path);
+});
+
+/**
+ * @module Collaboration
+ * @description Changes the user for the Rest calls
+ * @exampleFile Example_Collaboration.feature
+ * @step I want to set the user to {string}
+ **/
+When('I want to set the user to {string}', function(string) {
+ this.context.headers['onboarding'].USER_ID = string;
+});
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/General_Steps.js b/cucumber-js-test-apis-ci/stepDefinitions/General_Steps.js
new file mode 100644
index 0000000000..2076366595
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/General_Steps.js
@@ -0,0 +1,304 @@
+/*
+ * 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 {Then, When, Given} = require('cucumber');
+const assert = require('assert');
+const _ = require('lodash');
+const normalizeNewline = require('normalize-newline');
+require('node-zip');
+YAML = require('yamljs');
+const fs = require('fs');
+const util = require('./Utils.js');
+
+function getPath(path, context) {
+ let compiled = _.template(path);
+ return compiled(context);
+}
+
+/**
+ * @module ContextData
+ * @description Use with "Given". Use ONLY for local testing when you know the value of the Item you want to use
+ * instead of creating a new one.
+ * @step Item {string} and version Id {string}
+ **/
+Given('Item {string} and version Id {string}', function (string, string2) {
+ this.context.item.id = string;
+ this.context.item.versionId = string2;
+});
+/**
+ * @module ContextData
+ * @exampleFile Example_ResponseData_CheckAndManipulation.feature
+ * @description Response Data::<br>
+ * """<br>
+ * {jsonObject}<br>
+ * """<br>
+ * @step Use with "Given". Use ONLY for local testing, creates a response data object
+ **/
+Given('Response Data:', function (docString) {
+ this.context.responseData = JSON.parse(docString);
+});
+
+/**
+ * @module ContextData
+ * @description Copy a property from the response data to context Item/VLM/VSP data, example: vsp.componentId
+ * @step I want to save on the context for {string} property {string} with value {string}
+ **/
+Then('I want to save on the context for {string} property {string} with value {string}', function(string, string1, string2) {
+ assert.equal(_.includes(['VLM', 'VSP', 'Item'], string), true);
+ let val = _.get(this.context.responseData, string2);
+ _.set(this.context, string1, val);
+});
+/**
+ * @module ContextData
+ * @description Copy a property from the response data to saved data on the context. Example: save newly generated IDs. Response data value can be from a path, xample: results[0].id
+ * @exampleFile Example_Rest_Calls.feature
+ * @step I want to save to property {string} from response data path {string}
+ **/
+Then('I want to copy to property {string} from response data path {string}', function(string, string2) {
+ let val = _.get(this.context.responseData, string2);
+ _.set(this.context, string, val);
+});
+/**
+ * @module ContextData
+ * @description This will set the value of a saved property on the context
+ * @exampleFile Example_Rest_Calls.feature
+ * @step I want to set property {string} to value {string}
+ **/
+Then('I want to set property {string} to value {string}', function(string, string2) {
+ _.set(this.context, string, string2);
+});
+
+/**
+ * @module ResponseData
+ * @description Will check the output data for a property and a value. property can be a path (example: results[0].id)
+ * @exampleFile Example_ResponseData_CheckAndManipulation.feature
+ * @step I want to check property {string} for value {string}
+ **/
+Then('I want to check property {string} for value {string}', function(string, string2) {
+ assert.equal(_.get(this.context.responseData, string), string2);
+});
+/**
+ * @module ResponseData
+ * @description Will check the output data for a property and a value. property can be a path
+ * (example: results[0].id). Supports comparison to a long String by allowing a line break
+ * @exampleFile VirtualMachineInterfaceValidationHeatResourceMissingProperties.feature
+ * @step I want to check property {string} for value {string}
+ **/
+
+Then('I want to check property {string} for value:', function(string, docString) {
+ assert.equal(_.get(this.context.responseData, string), docString.trim());
+});
+/**
+ * @module ResponseData
+ * @description Will check the output data for a property and a integer. property can be a path (example: results[0].id)
+ * @exampleFile Example_ResponseData_CheckAndManipulation.feature
+ * @step I want to check property {string} for value {int}
+ **/
+Then('I want to check property {string} for value {int}', function(string, int) {
+ assert.equal(_.get(this.context.responseData, string), int);
+});
+/**
+ * @module ResponseData
+ * @description Will check the output data for a property and a boolean. property can be a path (example: results[0].id)
+ * @exampleFile Example_ResponseData_CheckAndManipulation.feature
+ * @step I want to check property {string} to be "True/False"
+ **/
+Then('I want to check property {string} to be {word}', function(string, string2) {
+ assert.equal(_.get(this.context.responseData, string), string2.toLowerCase() == "true");
+});
+/**
+ * @module ResponseData
+ * @description Will check the output data for a property and a boolean. property can be a path (example: results[0].id)
+ * @exampleFile Example_ResponseData_CheckAndManipulation.feature
+ * @step I want to check property {string} to have length {int}
+ **/
+Then('I want to check property {string} to have length {int}', function(string, intLength) {
+ let arrayProp = _.get(this.context.responseData, string);
+ assert.equal(arrayProp.length, intLength);
+});
+/**
+ * @module ResponseData
+ * @description Will check the output data for a property and make sure it exists
+ * @exampleFile Example_ResponseData_CheckAndManipulation.feature
+ * @step I want to check property {string} exists
+ **/
+Then('I want to check property {string} exists', function(string) {
+ assert.equal(_.has(this.context.responseData, string), true);
+});
+/**
+ * @module ResponseData
+ * @description Will check the output data for a property and make sure it does not exist
+ * @exampleFile Example_ResponseData_CheckAndManipulation.feature
+ * @step I want to check property {string} does not exist
+ **/
+Then('I want to check property {string} does not exist', function(string) {
+ assert.equal(_.has(this.context.responseData, string), false);
+});
+
+/**
+* @module ContextData
+* @description Use during development to see what is on the context
+ * @exampleFile Example_ResponseData_CheckAndManipulation.feature
+* @step I want to print context data
+**/
+Then('I want to print the context data', function() {
+ console.log('------------ context ---------------');
+ console.log(JSON.stringify(this.context, null, 2));
+ console.log('--------------------------------------');
+});
+/**
+ * @module ContextData
+ * @description Set this in order to check that the following Rest call will not have response code 200
+ * @exampleFile Example_Rest_Calls.feature
+ * @step I want the following to fail
+ **/
+Then('I want the following to fail', function() {
+ this.context.shouldFail = true;
+});
+
+/**
+ * @module ContextData
+ * @description Set this in order to check that the following Rest call will have the error code on the return data
+ * @exampleFile Example_VSP.feature
+ * @step I want the following to fail with error code {string}
+ **/
+Then('I want the following to fail with error code {string}', function(string) {
+ this.context.shouldFail = true;
+ this.context.errorCode = string;
+});
+
+
+/**
+ * @module ContextData
+ * @description Set this in order to check that the following Rest call will have the error message on the return data
+ * @exampleFile DeleteVLMCertified.feature
+ * @step I want the following to fail with error message {string}
+ **/
+Then('I want the following to fail with error message {string}', function(string) {
+ this.context.shouldFail = true;
+ let errorMessage = getPath(string, this.context);
+ this.context.errorMessage = errorMessage;
+});
+
+/**
+ * @module ZipData
+ * @description Use this in order to extract a file from a zip file and to compare it to a local file (string comparison).
+ * @exampleFile Example_VSP.feature
+ * @step I want to compare the content of the entry {string} in the zip {string} with file {string}
+ **/
+Then ('I want to compare the content of the entry {string} in the zip {string} with file {string}', function (string, string2, string3) {
+ let zipFile = fs.readFileSync(string2, 'binary');
+ let zip = new JSZip(zipFile, {base64: false, checkCRC32: true});
+ let fileData = zip.files[string]._data;
+ let compareFileData = fs.readFileSync(string3, {encoding: 'ascii'});
+ assert.equal(normalizeNewline(compareFileData), normalizeNewline(fileData));
+});
+
+/**
+ * @module ZipData
+ * @description Loads the yaml from zip file onto the context responseData as JSON for running checks on the output
+ * @exampleFile Example_VSP.feature
+ * @step I want to load the yaml content of the entry {string} in the zip {string} to context
+ **/
+Then ('I want to load the yaml content of the entry {string} in the zip {string} to context', function (string, string2, callback) {
+ let zipFile = fs.readFileSync(string2, 'binary');
+ let zip = new JSZip(zipFile, {base64: false, checkCRC32: true});
+ let fileData = zip.files[string]._data;
+ let nativeObject = YAML.parse(fileData);
+ this.context.responseData = nativeObject;
+ callback();
+});
+
+
+/**
+ * @module ZipData
+ * @description Loads the json from zip file onto the context responseData for running check son the output
+ * @exampleFile Example_VSP.feature
+ * @step I want to load the json content of the entry {string} in the zip {string} to context
+ **/
+When('I want to load the json content of the entry {string} in the zip {string} to context', function (string, string2, callback) {
+ let zipFile = fs.readFileSync(string2, 'binary');
+ let zip = new JSZip(zipFile, {base64: false, checkCRC32: true});
+ let str = zip.files[string]._data;
+ this.context.responseData = JSON.parse(str);
+ callback();
+});
+
+/**
+ * @module ResponseData
+ * @description Check that the result list doesn't contain an element with property x which has value
+ * equals to saved property y
+ * @exampleFile ListItemsFilters.feature
+ * @step I want to check that element in the response list with {string} equals to value of saved property {string} does not exist
+ **/
+Then('I want to check that element in the response list with {string} equals to value of saved property {string} does not exist', function (propertyPath, valueProperty) {
+ const results = this.context.responseData.results;
+ assert.equal(results.find(result => this.context[valueProperty] === _.get(result, propertyPath)), undefined);
+});
+
+/**
+ * @module ResponseData
+ * @description Check that the result list contains an element with property x which has value
+ * equals to saved property y
+ * @exampleFile ListItemsFilters.feature
+ * @step I want to check that element in the response list with {string} equals to value of saved property {string} exists
+ **/
+Then('I want to check that element in the response list with {string} equals to value of saved property {string} exists', function(propertyPath, valueProperty) {
+ const results = this.context.responseData.results;
+ assert.notEqual(results.find(result => this.context[valueProperty] === _.get(result, propertyPath)), undefined);
+});
+
+/**
+ * @module ResponseData
+ * @description Check that the itemId from context exits in result of responseData
+ * exampleFile ArchiveItem.feature
+ * step I want to check that item exits in response
+ **/
+Then('I want to check that item exits in response', function() {
+
+ const id = this.context.item.id;
+ const results = this.context.responseData.results;
+ var testResult = false;
+
+ for(var i=0; i< results.length; i++){
+ if ( id == results[i].id){
+ testResult = true;
+ }
+ }
+
+ assert.equal(testResult,true);
+});
+
+
+/**
+ * @module ResponseData
+ * @description Check that the itemId from context does NOT exits in result of responseData
+ * exampleFile ArchiveItem.feature
+ * step I want to check that item does not exits in response
+ **/
+Then('I want to check that item does not exits in response', function() {
+
+ const id = this.context.item.id;
+ const results = this.context.responseData.results;
+ var testResult = false;
+
+ for(var i=0; i< results.length; i++){
+ if ( id == results[i].id){
+ testResult = true;
+ }
+ }
+
+ assert.equal(testResult,false);
+}); \ No newline at end of file
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/GlobalTypes.js b/cucumber-js-test-apis-ci/stepDefinitions/GlobalTypes.js
new file mode 100644
index 0000000000..461fee74a7
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/GlobalTypes.js
@@ -0,0 +1,24 @@
+/*
+ * Copyright © 2016-2018 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 {Then, When} = require('cucumber');
+const assert = require('assert');
+const util = require('./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');
+}); \ 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
new file mode 100644
index 0000000000..57a374b9bb
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/InputData_steps.js
@@ -0,0 +1,94 @@
+/*
+ * 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 {Then, When, Given} = require('cucumber');
+const assert = require('assert');
+const _ = require('lodash');
+const fs = require('fs');
+const util = require('./Utils.js');
+
+/**
+ * @module InputData
+ * @description creates an ampty input data object
+ * @exampleFile Example_Rest_Calls.feature, Example_VLM.feature
+ * @step I want to create input data
+ **/
+When('I want to create input data', function () {
+ this.context.inputData = {};
+});
+
+/**
+ * @module InputData
+ * @exampleFile Example_Heat.feature
+ * @description I want to set the input data to:<br>
+ * """<br>
+ * {jsonObject}<br>
+ * """<br>
+ * @step creates an input data element with the given json object
+ **/
+When('I want to set the input data to:', function (docString) {
+ this.context.inputData = JSON.parse(docString);
+});
+
+/**
+ * @module InputData
+ * @description creates an input data object from the json in the given file
+ * @exampleFile Example_Rest_Calls.feature
+ * @step I want to set the input data to file {string}
+ **/
+When('I want to set the input data to file {string}', function (string) {
+ this.context.inputData = util.getJSONFromFile(string);
+});
+
+/**
+ * @module InputData
+ * @description sets the property on the input data to the given value
+ * @exampleFile Example_Rest_Calls.feature, Example_VLM.feature
+ * @step I want to update the input property {string} with value {string}
+ **/
+Then('I want to update the input property {string} with value {string}', function(string, string2) {
+ _.set(this.context.inputData, string, string2);
+});
+
+/**
+ * @module InputData
+ * @description sets the input property on the input data to the value from property
+ * @exampleFile TestMD5.feature
+ * @step I want to update the input property {string} from property {string}
+ **/
+Then('I want to update the input property {string} from property {string}', function(string, string2) {
+ let val = _.get(this.context, string2);
+ _.set(this.context.inputData, string, val);
+});
+
+/**
+ * @module InputData
+ * @description removes a property from the input data object
+ * @exampleFile Example_Rest_Calls.feature
+ * @step I want to remove {string} from the input data
+ **/
+Then('I want to remove {string} from the input data', function(string) {
+ delete this.context.inputData[string];
+});
+
+/**
+ * @module InputData
+ * @description sets the input data property to a random value
+ * @exampleFile Example_Rest_Calls.feature
+ * @step I want to update the input property {string} with a random value
+ **/
+Then('I want to update the input property {string} with a random value', function(string) {
+ _.set(this.context.inputData, string, util.random());
+});
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/InterfaceOperationSteps.js b/cucumber-js-test-apis-ci/stepDefinitions/InterfaceOperationSteps.js
new file mode 100644
index 0000000000..408db9e9f8
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/InterfaceOperationSteps.js
@@ -0,0 +1,156 @@
+/*
+ * 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 {Then, When} = require('cucumber');
+const assert = require('assert');
+const util = require('./Utils.js');
+
+
+When('I want to create a VF', function() {
+ let inputData = util.getJSONFromFile('resources/json/operation/createVF.json');
+
+ inputData.name = util.random();
+ inputData.tags[0] = util.random();
+
+ var type = "resources";
+ let path = '/catalog/' + type;
+ return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
+ this.context.component = {uniqueId : result.data.uniqueId, type : type, id : result.data.inputs[0].uniqueId};
+});
+});
+
+When('I want to create a Service', function() {
+ let inputData = util.getJSONFromFile('resources/json/operation/createService.json');
+
+ inputData.name = util.random();
+ inputData.tags[0] = util.random();
+
+ var type = "services";
+ let path = '/catalog/' + type;
+ return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
+ this.context.component = {uniqueId : result.data.uniqueId, type : type, id : result.data.inputs[0].uniqueId};
+});
+});
+
+function makeType() {
+ var text = "";
+ var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+ for (var i = 0; i < 5; i++)
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
+
+ return text;
+}
+
+When('I want to create an Operation with input output', function() {
+ let path = '/catalog/' + this.context.component.type + '/' + this.context.component.uniqueId + '/interfaceOperations';
+ let inputData = util.getJSONFromFile('resources/json/operation/createOperationWithInputOutput.json');
+
+ inputData.interfaceOperations.operation.inputParams.listToscaDataDefinition[0].name = util.random();
+ inputData.interfaceOperations.operation.inputParams.listToscaDataDefinition[0].property = this.context.component.id;
+ inputData.interfaceOperations.operation.outputParams.listToscaDataDefinition[0].name = util.random();
+ inputData.interfaceOperations.operation.operationType = makeType();
+ inputData.interfaceOperations.operation.description = makeType();
+
+ return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
+ this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
+});
+});
+
+When('I want to create an Operation', function() {
+ let path = '/catalog/' + this.context.component.type + '/' + this.context.component.uniqueId + '/interfaceOperations';
+ let inputData = util.getJSONFromFile('resources/json/operation/createOperation.json');
+ inputData.interfaceOperations.operation.operationType = makeType();
+ inputData.interfaceOperations.operation.description = makeType();
+
+ return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
+ this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
+});
+});
+
+When('I want to create an Operation with workflow', function() {
+ let path = '/catalog/' + this.context.component.type + '/' + this.context.component.uniqueId + '/interfaceOperations';
+ let inputData = util.getJSONFromFile('resources/json/operation/createOperation-with-workflow.json');
+
+ inputData.interfaceOperations.operation.inputParams.listToscaDataDefinition[0].name = util.random();
+ inputData.interfaceOperations.operation.inputParams.listToscaDataDefinition[0].property = this.context.component.id;
+ inputData.interfaceOperations.operation.outputParams.listToscaDataDefinition[0].name = util.random();
+ inputData.interfaceOperations.operation.operationType = makeType();
+ inputData.interfaceOperations.operation.description = makeType();
+ inputData.interfaceOperations.operation.workflowId = makeType();
+ inputData.interfaceOperations.operation.workflowVersionId = makeType();
+
+ return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
+ this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
+});
+});
+
+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)=> {
+ });
+});
+
+When('I want to get an Operation by Id', function () {
+ let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/interfaceOperations/' + this.context.operation.uniqueId;
+ return util.request(this.context, 'GET', path, null, false, 'catalog').then((result)=> {
+ this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
+});
+});
+
+When('I want to update an Operation', function () {
+ let inputData = util.getJSONFromFile('resources/json/operation/updateOperation.json');
+ let path = '/catalog/'+ this.context.component.type + '/'+ this.context.component.uniqueId +'/interfaceOperations';
+ inputData.interfaceOperations.operation.uniqueId = this.context.operation.uniqueId;
+ inputData.interfaceOperations.operation.operationType = this.context.operation.operationType;
+ inputData.interfaceOperations.operation.inputParams.listToscaDataDefinition[0].name = util.random();
+ inputData.interfaceOperations.operation.inputParams.listToscaDataDefinition[0].property = this.context.component.id;
+ inputData.interfaceOperations.operation.outputParams.listToscaDataDefinition[0].name = util.random();
+ return util.request(this.context, 'PUT', path, inputData, false, 'catalog').then((result)=> {
+ this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
+});
+});
+
+
+When('I want to delete an Operation', function() {
+ let path = '/catalog/'+ this.context.component.type + '/'+ this.context.component.uniqueId +'/interfaceOperations/' + this.context.operation.uniqueId;
+ return util.request(this.context, 'DELETE', path, null, false, '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)=> {
+ this.context.component = {uniqueId : result.data.uniqueId, type : this.context.component.type};
+});
+});
+
+
+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)=> {
+ this.context.component = {uniqueId : result.data.uniqueId};
+});
+});
+
+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)=> {
+ 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
new file mode 100644
index 0000000000..3ff7f20f73
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/Item_steps.js
@@ -0,0 +1,91 @@
+/*
+ * 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 {Then, When} = require('cucumber');
+const assert = require('assert');
+const util = require('./Utils.js');
+/**
+ * @module Item
+ * @description uses item id and version id from context
+ * @exampleFile Example_VSP.feature, Example_VLM.feature
+ * @step I want to make sure this Item has status {string}
+ **/
+Then('I want to make sure this Item has status {string}', function (string) {
+ let path = '/items/' + this.context.item.id + '/versions';
+ return util.request(this.context, 'GET', path).then(result => {
+ assert.equal(result.data.results[0].id, this.context.item.versionId);
+ assert.equal(result.data.results[0].status, string);
+ });
+});
+/**
+ * @module Item
+ * @description uses item id and version id from context
+ * @exampleFile Example_VSP.feature, Example_VLM.feature
+ * @step I want to commit this Item
+ **/
+Then('I want to commit this Item', function () {
+ let path = '/items/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/actions';
+ let inputData = {action: 'Commit', commitRequest: {message: '00Behave'}};
+ return util.request(this.context, 'PUT', path, inputData);
+});
+/**
+ * @module Item
+ * @description creates a new major version. item id and version id from context
+ * @exampleFile Example_VLM.feature
+ * @step I want to create a new version for this Item
+ **/
+Then('I want to create a new version for this Item', function () {
+ let path = '/items/' + this.context.item.id + '/versions/' + this.context.item.versionId;
+ let inputData = {description: 'Behave Version', creationMethod: 'major'};
+ return util.request(this.context, 'POST', path, inputData).then(result => {
+ assert.equal(result.data.status, 'Draft');
+ });
+});
+/**
+ * @module Item
+ * @description reverts to a revision with a given saved property. Should be set from the revision list first
+ * @exampleFile Example_VLM.feature
+ * @step I want to commit this Item
+ **/
+Then('I want to revert this Item to the revision with the value from saved property {string}', function (string) {
+ let path = '/items/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/actions';
+ let inputData = {action: 'Revert', revisionRequest: {revisionId: this.context[string]}};
+ return util.request(this.context, 'PUT', path, inputData);
+});
+
+
+/**
+ * @module Item
+ * @exampleFile ArchiveItem.feature
+ * @step I want to archive this item
+ **/
+Then('I want to archive this item', function() {
+ let path = '/items/' + this.context.item.id + '/actions'
+ let inputData = {action: 'ARCHIVE'};
+ return util.request(this.context, 'PUT', path, inputData);
+});
+
+
+/**
+ * @module Item
+ * @exampleFile ArchiveItem.feature
+ * @step I want to restore this item
+ **/
+Then('I want to restore this item', function() {
+ let path = '/items/' + this.context.item.id + '/actions'
+ let inputData = {action: 'RESTORE'};
+ return util.request(this.context, 'PUT', path, inputData);
+});
+
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/NetworkPackage_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/NetworkPackage_steps.js
new file mode 100644
index 0000000000..731d5b8470
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/NetworkPackage_steps.js
@@ -0,0 +1,54 @@
+/*
+ * 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 {Then, When} = require('cucumber');
+const assert = require('assert');
+const util = require('./Utils.js');
+const _ = require('lodash');
+const fs = require('fs');
+require('node-zip');
+
+/**
+ * @module NetworkPackage
+ * @description Uploads the NetworkPackage file to the VSP on the context
+ * @exampleFile Example_HEAT.feature
+ * @step I want to upload a NetworkPackage for this VSP from path {string}
+ **/
+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);
+});
+
+/**
+ * @module NetworkPackage
+ * @description Downloads the network package to disk
+ * @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) {
+ 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)];
+});
+
+/**
+ * @module NetworkPackage
+ * @description Processes the NetworkPackage file on the server
+ * @exampleFile Example_HEAT.feature
+ * @step I want to process the NetworkPackage file for this VSP
+ **/
+Then('I want to process the NetworkPackage file for this VSP', function () {
+ let path = '/vendor-software-products/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/orchestration-template-candidate/process';
+ return util.request(this.context, 'PUT', path, this.context.inputData);
+});
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/Questionnaire_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/Questionnaire_steps.js
new file mode 100644
index 0000000000..2e169fadc8
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/Questionnaire_steps.js
@@ -0,0 +1,129 @@
+/*
+ * 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 {Then, When} = require('cucumber');
+const assert = require('assert');
+const util = require('./Utils.js');
+const _ = require('lodash');
+
+function getPath(path, context) {
+ let compiled = _.template(path);
+ return compiled(context);
+}
+
+/**
+ * @module Questionnaire
+ * @description Gets the questionnaire for the current item and saves it on the context
+ * @exampleFile Example_VSP.feature
+ * @step I want to get the questionnaire for this item
+ **/
+Then('I want to get the questionnaire for this item', function () {
+ let path = "/vendor-software-products/" + this.context.item.id + "/versions/" + this.context.item.versionId + "/questionnaire";
+ return util.request(this.context, 'GET', path).then(result => {
+ this.context.qdata = JSON.parse(result.data.data);
+ this.context.qschema = result.data.schema;
+ this.context.qurl = path;
+ });
+});
+
+/**
+ * @module Questionnaire
+ * @description Gets the questionnaire for the current item and component and saves it on the context
+ * @exampleFile Example_VSP.feature
+ * @step I want to get the questionnaire for this component
+ **/
+Then('I want to get the questionnaire for this component', function () {
+ let path = "/vendor-software-products/" + this.context.item.id + "/versions/" + this.context.item.versionId + "/components/" + this.context.componentId + "/questionnaire";
+ return util.request(this.context, 'GET', path).then(result => {
+ this.context.qdata = JSON.parse(result.data.data);
+ this.context.qschema = result.data.schema;
+ this.context.qurl = path;
+ });
+});
+
+/**
+ * @module Questionnaire
+ * @description Gets the questionnaire from path and saves it on the context
+ * @exampleFile TestMD5.feature
+ * @step I want to get the questionnaire for this path {string}
+ **/
+Then('I want to get the questionnaire for this path {string}', function (string) {
+ let path = getPath(string, this.context);
+ return util.request(this.context, 'GET', path).then(result => {
+ this.context.qdata = JSON.parse(result.data.data);
+ this.context.qschema = result.data.schema;
+ this.context.qurl = path;
+ });
+});
+
+/**
+ * @module Questionnaire
+ * @description Updates the property for the saved questionnaire
+ * @exampleFile Example_VSP.feature
+ * @step I want to update this questionnaire with value {string} for path {string}
+ **/
+Then('I want to update this questionnaire with value {string} for property {string}', function (string, string2) {
+ _.set(this.context.qdata, string, string2);
+});
+
+/**
+ * @module Questionnaire
+ * @description Checks the questionnaire data on the context for the given value and property
+ * @exampleFile Example_VSP.feature
+ * @step I want to check this questionnaire has value {string} for property {string}
+ **/
+Then('I want to check this questionnaire has value {string} for property {string}', function (string, string2) {
+ assert.equal(_.get(this.context.qdata, string), string2);
+});
+
+/**
+ * @module Questionnaire
+ * @description Updates the the questionnaire data from the context to the same url that loaded it
+ * @exampleFile Example_VSP.feature
+ * @step I want to update this questionnaire
+ **/
+Then('I want to update this questionnaire', function () {
+ return util.request(this.context, 'PUT', this.context.qurl, this.context.qdata);
+});
+
+/**
+ * @module Questionnaire
+ * @description Checks if the value of given property name in questionnaire data on the context is same as provided value
+ * @exampleFile ComponentData.feature
+ * @step I want to check value of {string} in the questionnaire data with value of property {string}
+ */
+Then('I want to check value of {string} in the questionnaire data with value of property {string}', function (string,
+ propertyName) {
+ expectedValue = _.get(this.context, propertyName)
+ data1 = this.context.qdata;
+ assert.equal(_.get(data1, string), expectedValue);
+});
+
+/**
+ * @module Questionnaire - Defined in Questionnaire module since this is used to fetch componentId for which questionnaire is to be fetched
+ * @description Finds and set componentId in context from list of components in responseData for component name in given property
+ * @exampleFile ComponentData.feature
+ * @step I want to set componentId for component name in property {string}
+ */
+Then('I want to set componentId for component name in property {string}', function (string) {
+ displayName = _.get(this.context, string);
+ results = this.context.responseData.results;
+ for (i=0; i<results.length; i++) {
+ if (results[i].displayName == displayName ){
+ this.context.componentId = results[i].id;
+ return;
+ }
+ }
+}); \ No newline at end of file
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/REST_Steps.js b/cucumber-js-test-apis-ci/stepDefinitions/REST_Steps.js
new file mode 100644
index 0000000000..c3844124d7
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/REST_Steps.js
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2016-2018 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 {When} = require('cucumber');
+const _ = require('lodash');
+const util = require('./Utils.js');
+_.templateSettings.interpolate = /{([\s\S]+?)}/g;
+
+function getPath(path, context) {
+ let compiled = _.template(path);
+ return compiled(context);
+}
+/**
+ * @module Rest_Calls
+ * @description makes a GET request to the given path (path is appended after the "onboarding-api/v1.0" prefix)<br>
+ * @exampleFile Example_Rest_Calls.feature
+ * @step I want to get path {string}
+ **/
+When('I want to get path {string}', function(string) {
+ let path = getPath(string, this.context);
+ return util.request(this.context, 'GET', path);
+});
+
+/**
+ * @module Rest_Calls
+ * @description makes a DELETE request to the given path and appends the saved property (path is appended after the "onboarding-api/v1.0" prefix)<br>
+ * @exampleFile Example_Rest_Calls.feature
+ * @step I want to delete for path {string} with the value from saved property {string}
+ **/
+When('I want to delete for path {string} with the value from saved property {string}', function(string, string2) {
+ let path = getPath(string, this.context);
+ path += '/' + this.context[string2];
+ return util.request(this.context, 'DELETE', path);
+});
+
+/**
+ * @module Rest_Calls
+ * @description makes a DELETE request to the given path and appends the saved property (path is appended after the "onboarding-api/v1.0" prefix)<br>
+ * @exampleFile Example_Rest_Calls.feature
+ * @step I want to delete for path {string} with the value from saved property {string}
+ **/
+When('I want to delete for path {string}', function (string) {
+ let path = getPath(string, this.context);
+ //path += '/' + this.context[string2];
+ return util.request(this.context, 'DELETE', path);
+});
+
+/**
+ * @module Rest_Calls
+ * @description makes a PUT request to the given path and sends the input data from the context (path is appended after the "onboarding-api/v1.0" prefix)<br>
+ * @exampleFile Example_Rest_Calls.feature
+ * @step I want to update for path {string} with the input data from the context
+ **/
+When('I want to update for path {string} with the input data from the context', function(string) {
+ let path = getPath(string, this.context);
+ return util.request(this.context, 'PUT', path, this.context.inputData);
+});
+
+/**
+ * @module Rest_Calls
+ * @description makes a POST request to the given path and sends the input data from the context (path is appended after the "onboarding-api/v1.0" prefix)<br>
+ * @exampleFile Example_Rest_Calls.feature
+ * @step I want to create for path {string} with the input data from the context
+ **/
+When('I want to create for path {string} with the input data from the context', function(string) {
+ let path = getPath(string, this.context);
+ return util.request(this.context, 'POST', path, this.context.inputData);
+});
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/Toggle_Steps.js b/cucumber-js-test-apis-ci/stepDefinitions/Toggle_Steps.js
new file mode 100644
index 0000000000..16bcc2afb9
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/Toggle_Steps.js
@@ -0,0 +1,48 @@
+/*
+* Copyright © 2016-2018 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 {Then, When, Given} = require('cucumber');
+const assert = require('assert');
+const util = require('./Utils.js');
+
+
+/**
+ * @module Toggle
+ * @description this step will retrun and print to console the list of toggled features with their status
+ * @exampleFile Example_Toggle.feature
+ * @step I want to list Togglz
+ **/
+
+Then('I want to list Togglz', function() {
+ let path = '/togglz' ;
+ return util.request(this.context, 'GET', path).then(result => {
+ const featureList = result.data.features;
+ console.log(featureList);
+ });
+
+});
+
+/**
+ * @module Toggle
+ * @description this step will set the status for all toggled features
+ * @exampleFile Example_Toggle.feature
+ * @step I want to set all Togglz to be "true/false"
+ **/
+
+Then('I want to set all Togglz to be {string}', function(string) {
+ let path = '/togglz/state/' + string ;
+ return util.request(this.context, 'PUT', path);
+}); \ No newline at end of file
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/Utils.js b/cucumber-js-test-apis-ci/stepDefinitions/Utils.js
new file mode 100644
index 0000000000..66e959f6e5
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/Utils.js
@@ -0,0 +1,148 @@
+/*
+ * 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
new file mode 100644
index 0000000000..3411a25fcb
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/VF_steps.js
@@ -0,0 +1,43 @@
+/*
+ * 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 {Then, When} = require('cucumber');
+const assert = require('assert');
+const util = require('./Utils.js');
+
+
+/**
+ * @module VF
+ * @description Creates a VF for this Item (does NOT work on localhost). will get the data for the item and then update the input
+ * data for the VF call.
+ * @exampleFile Example_VSP.feature
+ * @step I want to create a VF for this Item
+ **/
+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['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;
+ this.context.inputData.name = result.data.name;
+ 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, 'vf');
+ });
+});
+
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/VLM_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/VLM_steps.js
new file mode 100644
index 0000000000..35e78b2d97
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/VLM_steps.js
@@ -0,0 +1,79 @@
+/*
+ * 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 {Then, When, Given} = require('cucumber');
+const assert = require('assert');
+const util = require('./Utils.js');
+
+/**
+ * @module VLM
+ * @description Creates a new VLM with a random name and saves the id and versionId on the context item object and the context vlm object<br>
+ * Input data will be taken from the 'resources/json/createVLM.json' file.
+ *@exampleFile Example_VLM.feature
+ * @step I want to create a VLM
+ **/
+When('I want to create a VLM', function() {
+ let inputData = util.getJSONFromFile('resources/json/createVLM.json');
+ inputData.vendorName = util.random();
+ let path = '/vendor-license-models';
+ return util.request(this.context, 'POST', path, inputData).then(result => {
+ this.context.item ={id : result.data.itemId, versionId: result.data.version.id};
+ this.context.vlm = {id : result.data.itemId, name : inputData.vendorName};
+ });
+});
+
+/**
+ * @module VLM
+ * @exampleFile Example_VLM.feature
+ * @step I want to submit this VLM
+ **/
+Then('I want to submit this VLM', function() {
+ let inputData = {action: 'Submit'};
+ let path = '/vendor-license-models/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/actions';
+ return util.request(this.context, 'PUT', path, inputData);
+});
+
+/**
+ * @module VLM
+ * @exampleFile DeleteVLMDraft.feature
+ * @step I want to delete this VLM
+ **/
+Then('I want to delete this VLM', function() {
+ let path = '/vendor-license-models/' + this.context.item.id ;
+ return util.request(this.context, 'DELETE', path);
+});
+
+
+/**
+ * @module VLM
+ * @exampleFile ArchiveItem.feature
+ * @step I want to list Archived VLMs
+ **/
+Then('I want to list Archived VLMs', function() {
+ let path = '/vendor-license-models/?Status=ARCHIVED';
+ return util.request(this.context, 'GET', path);
+});
+
+/**
+ * @module VLM
+ * @exampleFile ArchiveItem.feature
+ * @step I want to list Active VLMs
+ **/
+Then('I want to list Active VLMs', function() {
+ let path = '/vendor-license-models';
+ return util.request(this.context, 'GET', path);
+});
+
+
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/VSP_steps.js b/cucumber-js-test-apis-ci/stepDefinitions/VSP_steps.js
new file mode 100644
index 0000000000..b9b928a7f6
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/VSP_steps.js
@@ -0,0 +1,185 @@
+/*
+ * 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 {Then, When} = require('cucumber');
+const assert = require('assert');
+const util = require('./Utils.js');
+const _ = require('lodash');
+
+
+/**
+ * @module VSP
+ * @description Creates a new VSP with a random name and saves the id and versionId on the context item object and the context vsp object<br>
+ * Input data will be taken from the 'resources/json/createVSP.json' file.
+ * Vendor id and name are taken from the vlm on the context (requires a VLM to be created first).
+ * @exampleFile Example_VSP.feature
+ * @step I want to create a VSP with onboarding type {string}
+ **/
+When('I want to create a VSP with onboarding type {string}', function(string) {
+ let inputData = util.getJSONFromFile('resources/json/createVSP.json');
+ inputData.onboardingMethod = string;
+ inputData.vendorName = this.context.vlm.name;
+ inputData.vendorId = this.context.vlm.id;
+ inputData.name = util.random();
+ let path = '/vendor-software-products';
+ return util.request(this.context, 'POST', path, inputData).then(result => {
+ this.context.item = {id : result.data.itemId, versionId: result.data.version.id};
+ this.context.vsp = {id : result.data.itemId, versionId: result.data.version.id};
+ });
+});
+
+/**
+ * @module VSP
+ * @description Creates a new VSP with the 'NetowrkPackage' onboarding type and with a random name and saves the id and versionId on the context item object and the context vsp object<br>
+ * Input data will be taken from the 'resources/json/createVSP.json' file.
+ * Vendor id and name are taken from the vlm on the context (requires a VLM to be created first).
+ * @exampleFile Example_VSP.feature
+ * @step I want to create a VSP with onboarding type {string}
+ **/
+When('I want to create a VSP with onboarding type Manual', function() {
+ let inputData = util.getJSONFromFile('resources/json/createManualVSP.json');
+ inputData.vendorName = this.context.vlm.name;
+ inputData.vendorId = this.context.vlm.id;
+ inputData.name = util.random();
+ inputData.licensingVersion = this.context.licensingVersion;
+ inputData.licensingData.licenseAgreement = this.context.licenseAgreement;
+ inputData.licensingData.featureGroups[0] = this.context.featureGroupId;
+ let path = '/vendor-software-products';
+ return util.request(this.context, 'POST', path, inputData).then(result => {
+ this.context.item = {id : result.data.itemId, versionId: result.data.version.id};
+ this.context.vsp = {id : result.data.itemId, versionId: result.data.version.id};
+ });
+});
+
+
+/**
+ * @module VSP
+ * @exampleFile Example_VSP.feature
+ * @step I want to submit this VSP
+ **/
+Then('I want to submit this VSP', function () {
+ let path = '/vendor-software-products/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/actions';
+ let inputData = {action: 'Submit'};
+ return util.request(this.context, 'PUT', path, inputData);
+});
+
+/**
+ * @module VSP
+ * @exampleFile Example_VSP.feature
+ * @step I want to package this VSP
+ **/
+Then('I want to package this VSP', function () {
+ let path = '/vendor-software-products/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/actions';
+ let inputData = {action: 'Create_Package'};
+ return util.request(this.context, 'PUT', path, inputData);
+});
+
+/**
+ * @module VSP
+ * @description Adds a component to the current item
+ * @exampleFile Example_VSP.feature
+ * @step I want to add a component
+ **/
+Then('I want to add a component', function () {
+ let path = '/vendor-software-products/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/components';
+ let inputData = {name: 'Cucumber Name', displayName: 'Cucumber', description: 'Cucumber Description'};
+ return util.request(this.context, 'POST', path, inputData).then(result => {
+ this.context.componentId = result.data.vfcId;
+ });
+});
+
+
+/**
+ * @module VSP
+ * @description Downloads the packaged file for this component to the given path
+ * @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) {
+ let path = '/vendor-software-products/packages/' + this.context.item.id;
+ return [util.download(this.context, path, string, callback)];
+});
+
+
+/**
+ * @module VSP
+ * @exampleFile DeleteVSPDraft.feature
+ * @step I want to delete this VSP
+ **/
+Then('I want to delete this VSP', function() {
+ let path = '/vendor-software-products/' + this.context.item.id ;
+ return util.request(this.context, 'DELETE', path);
+});
+
+/**
+ * @module VSP
+ * @exampleFile ArchiveItem.feature
+ * @step I want to list Archived VSPs
+ **/
+Then('I want to list Archived VSPs', function() {
+ let path = '/vendor-software-products/?Status=ARCHIVED';
+ return util.request(this.context, 'GET', path);
+});
+
+/**
+ * @module VSP
+ * @exampleFile ArchiveItem.feature
+ * @step I want to list Active VSPs
+ **/
+Then('I want to list Active VSPs', function() {
+ let path = '/vendor-software-products';
+ return util.request(this.context, 'GET', path);
+});
+
+
+/**
+ * @module VSP
+ * @exampleFile FilterArchivedVSPpackage.feature
+ * @step I want to list Archived VSPs packages
+ **/
+Then('I want to list Archived VSPs packages', function() {
+ let path = '/vendor-software-products/packages?Status=ARCHIVED';
+ return util.request(this.context, 'GET', path);
+});
+
+/**
+ * @module VSP
+ * @exampleFile FilterArchivedVSPpackage.feature
+ * @step I want to list Active VSPs packages
+ **/
+Then('I want to list Active VSPs packages', function() {
+ let path = '/vendor-software-products/packages';
+ return util.request(this.context, 'GET', path);
+
+});
+
+/**
+ * @module VSP
+ * @exampleFile FilterArchivedVSPpackage.feature
+ * @step I want to check that VSP package exits in response
+ **/
+Then('I want to check that VSP package exits in response', function() {
+
+ const packages = this.context.responseData.results;
+ const id = this.context.item.id;
+ var testResult = false;
+
+ for(var i=0; i< packages.length; i++){
+ if (id == packages[i].packageId){
+ testResult = true;
+ }
+ }
+ assert.equal(testResult,true);
+}); \ No newline at end of file
diff --git a/cucumber-js-test-apis-ci/stepDefinitions/world.js b/cucumber-js-test-apis-ci/stepDefinitions/world.js
new file mode 100644
index 0000000000..eaf48aa31f
--- /dev/null
+++ b/cucumber-js-test-apis-ci/stepDefinitions/world.js
@@ -0,0 +1,92 @@
+/*
+ * 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);