blob: 3e2321963ce8c52a128c36d6a6feae9984a3ce0b [file] [log] [blame]
mojahidi65204c62018-04-25 18:39:53 +05301/*
2 * Copyright © 2016-2017 European Support Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16const {Then, When} = require('cucumber');
17const assert = require('assert');
18const util = require('./Utils.js');
19
20
21When('I want to create a VF', function() {
priyanshu5b9d9a12019-01-14 15:46:55 +053022 let inputData = util.getJSONFromFile('resources/json/createVFWithoutCSAR.json');
mojahidi65204c62018-04-25 18:39:53 +053023
priyanshu5b9d9a12019-01-14 15:46:55 +053024 var resourceName = util.random();
25 inputData.name = resourceName;
26 inputData.tags[0] = resourceName;
mojahidi65204c62018-04-25 18:39:53 +053027
mojahidi5082ac82018-09-07 11:07:49 +053028 var type = "resources";
29 let path = '/catalog/' + type;
siddharth0905b734ea22018-11-22 13:37:31 +053030 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
mojahidi5082ac82018-09-07 11:07:49 +053031 this.context.component = {uniqueId : result.data.uniqueId, type : type, id : result.data.inputs[0].uniqueId};
32});
33});
34
35When('I want to create a Service', function() {
priyanshu5b9d9a12019-01-14 15:46:55 +053036 let inputData = util.getJSONFromFile('resources/json/createService.json');
mojahidi5082ac82018-09-07 11:07:49 +053037
priyanshu5b9d9a12019-01-14 15:46:55 +053038 var serviceName = util.random();
39 inputData.name = serviceName;
40 inputData.tags[0] = serviceName;
mojahidi5082ac82018-09-07 11:07:49 +053041
42 var type = "services";
43 let path = '/catalog/' + type;
siddharth0905b734ea22018-11-22 13:37:31 +053044 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
mojahidi5082ac82018-09-07 11:07:49 +053045 this.context.component = {uniqueId : result.data.uniqueId, type : type, id : result.data.inputs[0].uniqueId};
mojahidi65204c62018-04-25 18:39:53 +053046});
47});
48
49function makeType() {
50 var text = "";
51 var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
52
53 for (var i = 0; i < 5; i++)
54 text += possible.charAt(Math.floor(Math.random() * possible.length));
55
56 return text;
57}
58
siddharth0905b734ea22018-11-22 13:37:31 +053059When('I want to create an Operation', function() {
60 let path = '/catalog/' + this.context.component.type + '/' + this.context.component.uniqueId + '/interfaceOperations';
ilanape5d23232019-01-30 12:50:04 +020061 let inputData = util.getJSONFromFile('resources/json/interfaceOperation/createInterfaceOperations.json');
priyanshu5b9d9a12019-01-14 15:46:55 +053062 var operationName = makeType();
63 var interfaceType = makeType();
64 inputData.interfaces.interface1.type = interfaceType;
65 inputData.interfaces.interface1.operations.delete.name = operationName;
66 inputData.interfaces.interface1.operations.delete.inputs.listToscaDataDefinition[0].name = util.random();
67 inputData.interfaces.interface1.operations.delete.inputs.listToscaDataDefinition[0].inputId = this.context.component.id;
68 inputData.interfaces.interface1.operations.delete.outputs.listToscaDataDefinition[0].name = util.random();
69 inputData.interfaces.interface1.operations.delete.description = operationName + " description";
siddharth0905b734ea22018-11-22 13:37:31 +053070
71 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
priyanshu5b9d9a12019-01-14 15:46:55 +053072 {intOperations = result.data.interfaces[0].operations};
73 this.context.interface = { interfaceUniqueId : result.data.interfaces[0].uniqueId,
74 interfaceType : result.data.interfaces[0].type,
75 operationUniqueId : Object.keys(intOperations)[0]
76 };
siddharth0905b734ea22018-11-22 13:37:31 +053077});
78});
79
priyanshu5b9d9a12019-01-14 15:46:55 +053080When('I want to update an Operation', function () {
ilanape5d23232019-01-30 12:50:04 +020081 let inputData = util.getJSONFromFile('resources/json/interfaceOperation/updateInterfaceOperation.json');
priyanshu5b9d9a12019-01-14 15:46:55 +053082 let path = '/catalog/'+ this.context.component.type + '/'+ this.context.component.uniqueId +'/interfaceOperations';
83 inputData.interfaces.interface1.operations.delete.uniqueId = this.context.interface.operationUniqueId;
84 inputData.interfaces.interface1.type=this.context.interface.interfaceType;
85 inputData.interfaces.interface1.operations.delete.inputs.listToscaDataDefinition[0].name = util.random();
86 inputData.interfaces.interface1.operations.delete.inputs.listToscaDataDefinition[0].inputId = this.context.component.id;
87 inputData.interfaces.interface1.operations.delete.outputs.listToscaDataDefinition[0].name = util.random();
siddharth0905b734ea22018-11-22 13:37:31 +053088
priyanshu5b9d9a12019-01-14 15:46:55 +053089 return util.request(this.context, 'PUT', path, inputData, false, 'catalog').then((result)=> {
90 {intOperations = result.data.interfaces[0].operations};
91 this.context.interface = { interfaceUniqueId : result.data.interfaces[0].uniqueId,
92 interfaceType : result.data.interfaces[0].type,
93 operationUniqueId : Object.keys(intOperations)[0]
94 };
siddharth0905b734ea22018-11-22 13:37:31 +053095});
96});
mojahidi65204c62018-04-25 18:39:53 +053097
priyanshu5b9d9a12019-01-14 15:46:55 +053098When('I want to get an Operation by Id', function () {
99 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/interfaces/' +
100 this.context.interface.interfaceUniqueId + '/operations/' +this.context.interface.operationUniqueId ;
101 return util.request(this.context, 'GET', path, null, false, 'catalog').then((result)=> {
102
103 {intOperations = result.data.interfaces[0].operations};
104 this.context.interface = { interfaceUniqueId : result.data.interfaces[0].uniqueId,
105 interfaceType : result.data.interfaces[0].type,
106 operationUniqueId : Object.keys(intOperations)[0]
107 };
108 });
109
110});
111
mojahidi5082ac82018-09-07 11:07:49 +0530112When('I want to list Operations', function () {
113 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/filteredDataByParams?include=interfaces';
siddharth0905b734ea22018-11-22 13:37:31 +0530114 return util.request(this.context, 'GET', path, null, false, 'catalog').then((result)=> {
mojahidi5082ac82018-09-07 11:07:49 +0530115 });
116});
117
mojahidi65204c62018-04-25 18:39:53 +0530118
119When('I want to delete an Operation', function() {
priyanshu5b9d9a12019-01-14 15:46:55 +0530120 let path = '/catalog/'+ this.context.component.type + '/'+ this.context.component.uniqueId +'/interfaces/' +
121 this.context.interface.interfaceUniqueId + '/operations/' +this.context.interface.operationUniqueId ;
siddharth0905b734ea22018-11-22 13:37:31 +0530122 return util.request(this.context, 'DELETE', path, null, false, 'catalog');
mojahidi65204c62018-04-25 18:39:53 +0530123});
124
125
mojahidi5082ac82018-09-07 11:07:49 +0530126When('I want to checkin this component', function () {
127 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/lifecycleState/CHECKIN' ;
mojahidi65204c62018-04-25 18:39:53 +0530128 let inputData = {userRemarks: 'checkin'};
siddharth0905b734ea22018-11-22 13:37:31 +0530129 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then((result)=> {
mojahidi5082ac82018-09-07 11:07:49 +0530130 this.context.component = {uniqueId : result.data.uniqueId, type : this.context.component.type};
mojahidi65204c62018-04-25 18:39:53 +0530131});
132});
133
134
mojahidi5082ac82018-09-07 11:07:49 +0530135Then('I want to submit this component', function () {
136 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/lifecycleState/certificationRequest' ;
mojahidi65204c62018-04-25 18:39:53 +0530137 let inputData = {userRemarks: 'submit'};
siddharth0905b734ea22018-11-22 13:37:31 +0530138 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then((result)=> {
139 this.context.component = {uniqueId : result.data.uniqueId};
mojahidi65204c62018-04-25 18:39:53 +0530140});
141});
142
mojahidi5082ac82018-09-07 11:07:49 +0530143Then('I want to certify this component', function () {
144 let path = '/catalog/'+ this.context.component.type +'/' + this.context.component.uniqueId + '/lifecycleState/certify' ;
145 let inputData = {userRemarks: 'certify'};
siddharth0905b734ea22018-11-22 13:37:31 +0530146 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then((result)=> {
mojahidi5082ac82018-09-07 11:07:49 +0530147 this.context.component = {uniqueId : result.data.uniqueId};
148});
149});