From 93fabeb929bb1b422d7473e23935f47fead4f4d8 Mon Sep 17 00:00:00 2001 From: NikhilMohan Date: Wed, 26 Aug 2020 20:30:48 +0530 Subject: Implementation for TMF 633 API - POST /serviceSpecification Issue-ID: EXTAPI-488 Signed-off-by: nikhil mohan Change-Id: I382e3b2bfbde656508bcfb0c86e748f21a7790d2 --- .../karatetest/data/serviceSpecification.json | 195 +++++++++++++++++++++ .../karatetest/features/00--ServiceCatalog.feature | 73 +++++++- src/test/resources/mappings/sdc/sdc_post_spec.json | 106 +++++++++++ 3 files changed, 373 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/karatetest/data/serviceSpecification.json create mode 100644 src/test/resources/mappings/sdc/sdc_post_spec.json (limited to 'src/test/resources') diff --git a/src/test/resources/karatetest/data/serviceSpecification.json b/src/test/resources/karatetest/data/serviceSpecification.json new file mode 100644 index 0000000..858aa11 --- /dev/null +++ b/src/test/resources/karatetest/data/serviceSpecification.json @@ -0,0 +1,195 @@ +[ + { + "name": "partner-service", + "description": "A test service through TMF API 633", + "@type": "ServiceSpecification", + "@schemaLocation": null, + "@baseType": "Service", + "toscaModelURL": "/", + "toscaResourceName": "", + "category": "Partner Domain Service", + "subcategory": "subservice", + "version": "1.0", + "lifecycleStatus": "NOT_CERTIFIED_CHECKOUT", + "DistributionStatus": "DISTRIBUTION_NOT_APPROVED", + "targetServiceSchema": { + "@type": "string", + "@schemaLocation": "/" + }, + "attachment": [{ + "id" : "1eadef", + "name" : "info-artifact", + "description" : "informational", + "artifactLabel" : "notes", + "artifactGroupType" : "info", + "artifactTimeout" : "500", + "artifactChecksum" : "adef23", + "artifactVersion" : "1.0", + "generatedFromUUID" : "a12e", + "url" : "/artifact/info/1eadef", + "mimeType" : "text", + "@type" : "ONAPartifact" + } + + ], + "relatedParty": [ + { + "id": "cs0008", + "role": "designer", + "name": "Carlos Santana" + } + ], + "resourceSpecification": [ + { + "id" : "281abc4d", + "version" : "1.0", + "name" : "vfirewall", + "resourceInstanceName" : "vfirewallinst", + "modelCustomizationName" : "vfirewallinst", + "resourceInvariantUUID" : "123ebdf", + "resourceType" : "VNF", + "@type" : "ONAPresource" + } + ], + "serviceSpecCharacteristic": [ + { + "name": "firewall", + "description": "Firewall characteristic", + "valueType": "string", + "@type": "string", + "@schemaLocation": "string", + "required": true, + "serviceSpecCharacteristicValue": [ + { + "valueType": "string", + "isDefault": true, + "value": "NA" + } + ] + }, + { + "name": "isBundled", + "description": "is bundled or not", + "valueType": "boolean", + "@type": "string", + "@schemaLocation": "string", + "required": true, + "serviceSpecCharacteristicValue": [ + { + "valueType": "boolean", + "isDefault": true, + "value": true + } + ] + }, + { + "name": "NumberofPort", + "description": "NumberofPorts", + "valueType": "integer", + "@type": "string", + "@schemaLocation": "string", + "required": true, + "serviceSpecCharacteristicValue": [ + { + "valueType": "string", + "isDefault": false, + "value": "10" + } + ] + }, + { + "name": "ipaddress", + "description": "ipaddress", + "valueType": "float", + "@type": "string", + "@schemaLocation": "string", + "required": true, + "serviceSpecCharacteristicValue": [ + { + "valueType": "string", + "isDefault": false, + "value": "15.123.9.101" + } + ] + } + ] + }, + { + "@type": "ServiceSpecification", + "@schemaLocation": null, + "@baseType": "Service", + "toscaModelURL": "/", + "toscaResourceName": "", + "subcategory": "subservice", + "version": "1.0", + "lifecycleStatus": "NOT_CERTIFIED_CHECKOUT", + "targetServiceSchema": { + "@type": "string", + "@schemaLocation": "/" + }, + "attachment": [], + "resourceSpecification": [], + "serviceSpecCharacteristic": [ + { + "name": "firewall", + "description": "Firewall characteristic", + "valueType": "string", + "@type": "string", + "@schemaLocation": "string", + "required": true, + "serviceSpecCharacteristicValue": [ + { + "valueType": "string", + "isDefault": true, + "value": "NA" + } + ] + }, + { + "name": "isBundled", + "description": "is bundled or not", + "valueType": "boolean", + "@type": "string", + "@schemaLocation": "string", + "required": true, + "serviceSpecCharacteristicValue": [ + { + "valueType": "boolean", + "isDefault": true, + "value": true + } + ] + }, + { + "name": "NumberofPorts", + "description": "Number of Ports", + "valueType": "integer", + "@type": "string", + "@schemaLocation": "string", + "required": true, + "serviceSpecCharacteristicValue": [ + { + "valueType": "string", + "isDefault": false, + "value": "10" + } + ] + }, + { + "name": "ipaddress", + "description": "ipaddress", + "valueType": "string", + "@type": "string", + "@schemaLocation": "string", + "required": true, + "serviceSpecCharacteristicValue": [ + { + "valueType": "string", + "isDefault": true, + "value": "10.244.34.1" + } + ] + } + ] + } +] \ No newline at end of file diff --git a/src/test/resources/karatetest/features/00--ServiceCatalog.feature b/src/test/resources/karatetest/features/00--ServiceCatalog.feature index 2a4a5c0..1887498 100644 --- a/src/test/resources/karatetest/features/00--ServiceCatalog.feature +++ b/src/test/resources/karatetest/features/00--ServiceCatalog.feature @@ -20,9 +20,10 @@ Feature: Service Catalog Background: * url nbiBaseUrl * def Context = Java.type('org.onap.nbi.test.Context'); +* def data = read('../data/serviceSpecification.json') * configure readTimeout = 30000 * call Context.startServers(); - + Scenario: testServiceCatalogGetResourceWithoutTosca Given path 'serviceSpecification','1e3feeb0-8e36-46c6-862c-236d9c626439_withoutTosca' When method get @@ -127,4 +128,74 @@ When method get Then status 500 * call Context.startServers(); +Scenario: testCreateServiceSpec +Given path 'serviceSpecification' +And header USER_ID = 'cs0008' +And request data[0] +When method post +Then status 201 +And match $.id contains '#notnull' +And match $.lifecycleStatus == 'NOT_CERTIFIED_CHECKOUT' +And match $.serviceSpecCharacteristic == +""" +[ { + "name" : "isBundle", + "description" : "is bundled or not", + "valueType" : "boolean", + "required" : true, + "serviceSpecCharacteristicValue" : [ { + "value" : "true", + "isDefault" : true + } ] + }, { + "name" : "ipaddress", + "description" : "ipaddress", + "valueType" : "string", + "required" : true, + "serviceSpecCharacteristicValue" : [ { + "value" : "10.244.34.1", + "isDefault" : true + } ] + }, { + "name" : "firewall", + "description" : "Firewall characteristic", + "valueType" : "string", + "required" : true, + "serviceSpecCharacteristicValue" : [ { + "value" : "NA", + "isDefault" : true + } ] + }, { + "name" : "NumberofPorts", + "description" : "Number of Ports", + "valueType" : "integer", + "required" : true, + "serviceSpecCharacteristicValue" : [ { + "value" : "10", + "isDefault" : true + } ] + } ] +""" + +Scenario: testCreateServiceSpecWithoutUser +Given path 'serviceSpecification' +And request data[0] +When method post +Then status 400 +And match $.message contains "Missing request header 'USER_ID'" + +Scenario: testCreateServiceSpecWithoutPayload +Given path 'serviceSpecification' +And header USER_ID = 'cs0008' +And request {} +When method post +Then status 400 + +Scenario: testCreateServiceSpecWithoutMandatoryDetails +Given path 'serviceSpecification' +And header USER_ID = 'cs0008' +And request data[1] +When method post +Then status 400 +And match $.message contains 'Bad Request' diff --git a/src/test/resources/mappings/sdc/sdc_post_spec.json b/src/test/resources/mappings/sdc/sdc_post_spec.json new file mode 100644 index 0000000..41e724f --- /dev/null +++ b/src/test/resources/mappings/sdc/sdc_post_spec.json @@ -0,0 +1,106 @@ +{ + "request": { + "method": "POST", + "url": "/sdc/v1/catalog/services", + "headers": { + "USER_ID": { + "contains": "cs0008" + } + }, + "bodyPatterns": [ + { + "contains": "\"name\":\"partner-service\"" + } + ] + }, + "response": { + "status": 201, + "jsonBody": { + "uuid": "1e3feeb0-8e36-46c6-862c-236d9c626439", + "href": "/serviceSpecification/1e3feeb0-8e36-46c6-862c-236d9c626439", + "name": "partner-service", + "description": "service", + "@type": "ServiceSpecification", + "@schemaLocation": null, + "@baseType": "Service", + "toscaModelURL": "/", + "toscaResourceName": "string", + "category": "Partner Domain Service", + "subcategory": "string", + "version": "1.0", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "targetServiceSchema": { + "@type": "string", + "@schemaLocation": "/" + }, + "artifacts": [ + { + "artifactUUID": "1eadef", + "artifactName": "info-artifact", + "artifactDescription": "informational", + "artifactLabel": "notes", + "artifactGroupType": "info", + "artifactTimeout": "500", + "artifactChecksum": "adef23", + "artifactVersion": "1.0", + "generatedFromUUID": "a12e", + "artifactURL": "/artifact/info/1eadef", + "artifactType": "text" + } + ], + "lastUpdaterUserId": "cs0008", + "lastUpdaterFullName": "Carlos Santana", + "resources": [ + { + "resourceUUID": "281abc4d", + "resourceVersion": "1.0", + "resourceName": "vfirewall", + "resourceInstanceName": "vfirewallinst", + "resourceInvariantUUID": "123ebdf", + "resoucreType": "VNF" + } + ], + "properties": [ + { + "type": "boolean", + "required": true, + "definition": false, + "description": "is bundled or not", + "name": "isBundle", + "value": "true", + "defaultValue": true + }, + { + "type": "string", + "required": true, + "definition": false, + "description": "ipaddress", + "name": "ipaddress", + "value": "10.244.34.1", + "defaultValue": true + }, + { + "type": "string", + "required": true, + "definition": false, + "description": "Firewall characteristic", + "name": "firewall", + "value": "NA", + "defaultValue": true + }, + { + "type": "integer", + "required": true, + "definition": false, + "description": "Number of Ports", + "name": "NumberofPorts", + "value": "10", + "defaultValue": true + } + ] + }, + "headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file -- cgit 1.2.3-korg