From b968389c706a57896e38f870c26b3446f00a2409 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Wed, 9 Sep 2020 16:56:08 +0200 Subject: [PATCH 01/24] feat: bootstrap some samples of NGSI-LD entities --- samples/building-location-attribute.jsonld | 23 ++++++++++++++ samples/building-minimal.jsonld | 8 +++++ .../building-relationship-of-property.jsonld | 30 +++++++++++++++++++ samples/building-relationship.jsonld | 12 ++++++++ samples/building-simple-attributes.jsonld | 26 ++++++++++++++++ 5 files changed, 99 insertions(+) create mode 100644 samples/building-location-attribute.jsonld create mode 100644 samples/building-minimal.jsonld create mode 100644 samples/building-relationship-of-property.jsonld create mode 100644 samples/building-relationship.jsonld create mode 100644 samples/building-simple-attributes.jsonld diff --git a/samples/building-location-attribute.jsonld b/samples/building-location-attribute.jsonld new file mode 100644 index 00000000..864d122e --- /dev/null +++ b/samples/building-location-attribute.jsonld @@ -0,0 +1,23 @@ +{ + "id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", + "type": "Building", + "name": { + "type": "Property", + "value": "Eiffel Tower" + }, + "subCategory": { + "type": "Property", + "value": ["tourism"] + }, + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + } + }, + "@context": [ + "https://fiware.github.io/data-models/context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/samples/building-minimal.jsonld b/samples/building-minimal.jsonld new file mode 100644 index 00000000..23fadf8a --- /dev/null +++ b/samples/building-minimal.jsonld @@ -0,0 +1,8 @@ +{ + "id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", + "type": "Building", + "@context": [ + "https://fiware.github.io/data-models/context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/samples/building-relationship-of-property.jsonld b/samples/building-relationship-of-property.jsonld new file mode 100644 index 00000000..6483778e --- /dev/null +++ b/samples/building-relationship-of-property.jsonld @@ -0,0 +1,30 @@ +{ + "id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", + "type": "Building", + "name": { + "type": "Property", + "value": "Eiffel Tower" + }, + "subCategory": { + "type": "Property", + "value": ["tourism"] + }, + "airQualityLevel": { + "type": "Property", + "value": 4, + "unitCode": "C62", + "observedAt": "2020-09-09T16:40:00.000Z", + "hasWeatherObserved": { + "type": "Relationship", + "object": "urn:ngsi-ld:Sensor:43a1af27-4aa7-44fe-bee9-fe76d56978a4" + } + }, + "almostFull": { + "type": "Property", + "value": false + }, + "@context": [ + "https://fiware.github.io/data-models/context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/samples/building-relationship.jsonld b/samples/building-relationship.jsonld new file mode 100644 index 00000000..ec4bb68b --- /dev/null +++ b/samples/building-relationship.jsonld @@ -0,0 +1,12 @@ +{ + "id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", + "type": "Building", + "locatedAt": { + "type": "Relationship", + "object": "urn:ngsi-ld:City:Paris" + }, + "@context": [ + "https://fiware.github.io/data-models/context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/samples/building-simple-attributes.jsonld b/samples/building-simple-attributes.jsonld new file mode 100644 index 00000000..bc3dd795 --- /dev/null +++ b/samples/building-simple-attributes.jsonld @@ -0,0 +1,26 @@ +{ + "id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", + "type": "Building", + "name": { + "type": "Property", + "value": "Eiffel Tower" + }, + "subCategory": { + "type": "Property", + "value": ["tourism"] + }, + "airQualityLevel": { + "type": "Property", + "value": 4, + "unitCode": "C62", + "observedAt": "2020-09-09T16:40:00.000Z" + }, + "almostFull": { + "type": "Property", + "value": false + }, + "@context": [ + "https://fiware.github.io/data-models/context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file -- GitLab From 7f51dcc04dbf398efd1d822ed94a0006c178d82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patr=C3=ADcia=20Oliveira?= Date: Sat, 12 Sep 2020 01:08:08 +0100 Subject: [PATCH 02/24] First demo draft with structure and run instructions --- README.md | 0 .../Provision/Entities/CreateEntity_200.robot | 44 + .../Entities/CreateEntity_200_DD.robot | 6 + .../data}/building-location-attribute.jsonld | 0 .../Entities/data}/building-minimal.jsonld | 0 .../building-relationship-of-property.jsonld | 0 .../data}/building-relationship.jsonld | 0 .../data}/building-simple-attributes.jsonld | 0 .../Provision/Entities/schemas/response.json | 73 + requirements.txt | 5 + resources/ApiUtils.resource | 62 + .../__pycache__/variables.cpython-37.pyc | Bin 0 -> 1757 bytes resources/variables.py | 6 + results/log.html | 2137 +++++++++++++++ results/output.xml | 183 ++ results/report.html | 2434 +++++++++++++++++ scripts/run_tests.sh | 24 + 17 files changed, 4974 insertions(+) create mode 100644 README.md create mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200.robot create mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200_DD.robot rename {samples => TP/NGSI-LD/ContextInformation/Provision/Entities/data}/building-location-attribute.jsonld (100%) rename {samples => TP/NGSI-LD/ContextInformation/Provision/Entities/data}/building-minimal.jsonld (100%) rename {samples => TP/NGSI-LD/ContextInformation/Provision/Entities/data}/building-relationship-of-property.jsonld (100%) rename {samples => TP/NGSI-LD/ContextInformation/Provision/Entities/data}/building-relationship.jsonld (100%) rename {samples => TP/NGSI-LD/ContextInformation/Provision/Entities/data}/building-simple-attributes.jsonld (100%) create mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/schemas/response.json create mode 100644 requirements.txt create mode 100644 resources/ApiUtils.resource create mode 100644 resources/__pycache__/variables.cpython-37.pyc create mode 100644 resources/variables.py create mode 100644 results/log.html create mode 100644 results/output.xml create mode 100644 results/report.html create mode 100755 scripts/run_tests.sh diff --git a/README.md b/README.md new file mode 100644 index 00000000..e69de29b diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200.robot new file mode 100644 index 00000000..68247a18 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200.robot @@ -0,0 +1,44 @@ +*** Settings *** +Documentation TP description. +Variables ../../../../../resources/variables.py +Library REST ${url} +Library JSONSchemaLibrary .schemas/ +Library OperatingSystem + +#Suite Setup +#Suite Teardown + +*** Variable *** +${endpoint}= entities + + +*** Test Case *** +CreateEntity_200_MINIMAL + [Documentation] TP Variation description. + [Tags] critical + Log To Console "Will start Test Case CreateEntity_200_MINIMAL ..." + #TO DO: read body from files + Create Entity {"id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", "type": "Building"} + Check HTTP Status Code Is 201 + Check HTTP Response Body Json Schema Is response.json + +*** Keywords *** +Create Entity + [Arguments] ${body} + ${response} POST ${endpoint} body=${body} + Output request + Output response + Set Test Variable ${response} + +Check HTTP Status Code Is + [Arguments] ${status} + Log To Console ${response} + Should Be Equal ${response['status']} ${status} + +Check HTTP Response Body Json Schema Is + [Arguments] ${input} + Should Contain ${response['headers']['Content-Type']} application/json + ${schema} = Catenate SEPARATOR= ${input} .schema.json + Validate Json ${schema} ${response['body']} + Log Json Schema Validation OK + diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200_DD.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200_DD.robot new file mode 100644 index 00000000..53c2e08d --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200_DD.robot @@ -0,0 +1,6 @@ +#TODO: Data Driven example + + +*** Test Case *** +CreateEntity_200_DD + Log To Console "Will start Test Case CreateEntity_200_DD..." \ No newline at end of file diff --git a/samples/building-location-attribute.jsonld b/TP/NGSI-LD/ContextInformation/Provision/Entities/data/building-location-attribute.jsonld similarity index 100% rename from samples/building-location-attribute.jsonld rename to TP/NGSI-LD/ContextInformation/Provision/Entities/data/building-location-attribute.jsonld diff --git a/samples/building-minimal.jsonld b/TP/NGSI-LD/ContextInformation/Provision/Entities/data/building-minimal.jsonld similarity index 100% rename from samples/building-minimal.jsonld rename to TP/NGSI-LD/ContextInformation/Provision/Entities/data/building-minimal.jsonld diff --git a/samples/building-relationship-of-property.jsonld b/TP/NGSI-LD/ContextInformation/Provision/Entities/data/building-relationship-of-property.jsonld similarity index 100% rename from samples/building-relationship-of-property.jsonld rename to TP/NGSI-LD/ContextInformation/Provision/Entities/data/building-relationship-of-property.jsonld diff --git a/samples/building-relationship.jsonld b/TP/NGSI-LD/ContextInformation/Provision/Entities/data/building-relationship.jsonld similarity index 100% rename from samples/building-relationship.jsonld rename to TP/NGSI-LD/ContextInformation/Provision/Entities/data/building-relationship.jsonld diff --git a/samples/building-simple-attributes.jsonld b/TP/NGSI-LD/ContextInformation/Provision/Entities/data/building-simple-attributes.jsonld similarity index 100% rename from samples/building-simple-attributes.jsonld rename to TP/NGSI-LD/ContextInformation/Provision/Entities/data/building-simple-attributes.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/schemas/response.json b/TP/NGSI-LD/ContextInformation/Provision/Entities/schemas/response.json new file mode 100644 index 00000000..f566f086 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/schemas/response.json @@ -0,0 +1,73 @@ +{ + "required": [ + "timestamp", + "path", + "status", + "error", + "message", + "requestId" + ], + "properties": { + "timestamp": { + "$id": "#/properties/timestamp", + "type": "integer", + "title": "The timestamp schema", + "description": "An explanation about the purpose of this instance.", + "default": 0, + "examples": [ + 1599842686277 + ] + }, + "path": { + "$id": "#/properties/path", + "type": "string", + "title": "The path schema", + "description": "An explanation about the purpose of this instance.", + "default": "", + "examples": [ + "/ngsi-ld/v1/entities" + ] + }, + "status": { + "$id": "#/properties/status", + "type": "integer", + "title": "The status schema", + "description": "An explanation about the purpose of this instance.", + "default": 0, + "examples": [ + 415 + ] + }, + "error": { + "$id": "#/properties/error", + "type": "string", + "title": "The error schema", + "description": "An explanation about the purpose of this instance.", + "default": "", + "examples": [ + "Unsupported Media Type" + ] + }, + "message": { + "$id": "#/properties/message", + "type": "string", + "title": "The message schema", + "description": "An explanation about the purpose of this instance.", + "default": "", + "examples": [ + "Content type '' not supported" + ] + }, + "requestId": { + "$id": "#/properties/requestId", + "type": "string", + "title": "The requestId schema", + "description": "An explanation about the purpose of this instance.", + "default": "", + "examples": [ + "9a15420d-86" + ] + } + }, + "additionalProperties": true +} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..abbafcd8 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +robotframework==3.2.1 +RESTinstance==1.0.2 +robotframework-jsonschemalibrary==1.0 +robotframework-pabot==1.8.0 + diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource new file mode 100644 index 00000000..5610f609 --- /dev/null +++ b/resources/ApiUtils.resource @@ -0,0 +1,62 @@ +*** Settings *** +Variables ./variables.py + +Library REST ${url} + +*** Variables *** +${response} + +*** Keywords *** +Api POST request + [Arguments] ${api path} ${header} ${body} + ${response} POST ${api path}/ headers=${header} body=${body} + Output request + Output response + Output Schema + Set Test Variable ${response} + +Api GET request + [Arguments] ${api path} ${header} + ${response} GET ${api path} headers=${header} + Output request + Output response + Output Schema + Set Test Variable ${response} + +Api DEL request + [Arguments] ${header} ${api path} + ${response} DEL ${api path} headers=${header} + Output request + Output response + Output Schema + Set Test Variable ${response} + +Assert response status code + [Arguments] ${code} + Should Be Equal ${response}[status] ${code} + +Check HTTP Response Status Code Is + [Arguments] ${expected_status} + ${status}= Convert To Integer ${expected_status} + Console + Should Be Equal ${response['status']} ${status} + Log Status code validated + +Check HTTP Response Body Json Schema Is + [Arguments] ${input} + Should Contain ${response['headers']['Content-Type']} application/json + ${schema} = Catenate SEPARATOR= ${input} .schema.json + Validate Json ${schema} ${response['body']} + Log Json Schema Validation OK + +Should Be Present In Json List + [Arguments] ${expr} ${json_field} ${json_value} + Log Check if ${json_field} is present in ${expr} with the value ${jsonvalue} + :FOR ${item} IN @{expr} + \ Exit For Loop If "${item['${json_field}']}" == "${json_value}" + Log Item found ${item} + [return] ${item} + +Check Result Contains + [Arguments] ${source} ${parameter} ${value} + Should Be Present In Json List ${source} ${parameter} ${value} \ No newline at end of file diff --git a/resources/__pycache__/variables.cpython-37.pyc b/resources/__pycache__/variables.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..854d46792f09a3a79cf67b4333dbb2690cbdd767 GIT binary patch literal 1757 zcmaJ?OOvZa6i#NmdbR5MCtTgdOn?ljiDg;l1!;!IO?Y%@7gIo!(9jJTAS9u5r9Z=^ z8~>1t+4>XQxw6Tv`zS5#sso4SJihat13i89>WdyddVh2e@76U}zT;AT z$uIaC_wm)webmD}yZ8DNGwSo*Ze4NdOlMr)nsP&Y{ma#l{U7=l({_;5^}hOgFsSO7 zQc~RDxVepYvSDBEk`r3 zv&e+l6uW>NNg&Y-kjV(lG++y-Cdw&@=H|#-Qp*<>wF&*>N*oh!CMF@1DV{63?IwyN zxT2SvqM5EskPEjwAB~q2Vxpe&d zV$4nEJCmW`X0@5R0x)P1n6)yEa^L*jf?yztS@KkRkCG{n*jm}`idvy+_ z6YX?()>^E3RjATN=Y9w(LO28+o(3_*d6MZzzC4~+``$Rgn{^QmwSCMKp~DQQIOaZQ zUPFU7T8g-hFPStN8pO&gf|qN?<>tNX0_!eR(IBo!y?1z&24GRNF-d2knDGjG`Af<^O=}+s> z)sNuI1^#|2Us z4v}@Y(r2T25iN|zH<^S>bA`06I3X*Rdx>@mWqCSX#n!ae=UTziMwyVTJr;LEZAW!M zOzvjIEIR4AD}iQ6$ddx9g{eIzH^7^ZJp(*F6X2?)md3 zC`k~~xGK9p|K;-6H-n^L@nBz2(!`_;20Ky@NVU6(2)n8GnDW0qD+Xm;6^Am4tHJvq zxBK(+t6f|_zTfH2mWrQ8{B*hMzq~3xWV_fIap FzX4nIH%9;f literal 0 HcmV?d00001 diff --git a/resources/variables.py b/resources/variables.py new file mode 100644 index 00000000..7be45ca3 --- /dev/null +++ b/resources/variables.py @@ -0,0 +1,6 @@ +def get_variables(arg=None): + variables = { + 'url': 'https://stellio-dev.eglobalmark.com/ngsi-ld/v1/', + 'token': 'eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJIS0xvcnlIcDN6VHlOY0EtNWYwQ19iVC1hbm5ldDFLSUhFT0U1VnN1NjRrIn0.eyJleHAiOjE2MDA3MDI2MjUsImlhdCI6MTU5OTgzODYyNSwianRpIjoiMDNmYTA3YzktNjU0ZS00NDVjLWIwNjQtM2U4YzBkOTVjNzFjIiwiaXNzIjoiaHR0cHM6Ly9zc28uZWdsb2JhbG1hcmsuY29tL2F1dGgvcmVhbG1zL3N0ZWxsaW8tZGV2IiwiYXVkIjoiYWNjb3VudCIsInN1YiI6ImYzZmVlOWFkLWI3NzItNDFmMy05ZmVmLTNhODIxODI3OTUwMyIsInR5cCI6IkJlYXJlciIsImF6cCI6InR0Zi1jaW0tdWJpd2hlcmUiLCJzZXNzaW9uX3N0YXRlIjoiNzFiMGQ4N2QtZTZiOS00YTk0LTlkMDItOGQ2OTljMjQ1MzU0IiwiYWNyIjoiMSIsInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJzdGVsbGlvLWNyZWF0b3IiLCJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsidHRmLWNpbS11Yml3aGVyZSI6eyJyb2xlcyI6WyJ1bWFfcHJvdGVjdGlvbiJdfSwiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiJwcm9maWxlIGVtYWlsIiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJjbGllbnRJZCI6InR0Zi1jaW0tdWJpd2hlcmUiLCJjbGllbnRIb3N0IjoiMTAuNS4xLjEiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJzZXJ2aWNlLWFjY291bnQtdHRmLWNpbS11Yml3aGVyZSIsImNsaWVudEFkZHJlc3MiOiIxMC41LjEuMSJ9.WdTawXIl2SKrlYvmba25fsE-2jbB5a2jhLcLqRbULwbEWyLBZMuRAnq3ArMRB9IxawlSn1fsMfaFvcsGbdBGjVUeC1XiVezHRYlTiwEZGETi5LUsLC6DocEM_Pk2drNQZJf1AiQmnVhJxb55BBQeOBtLDJomjvFAikzwo43JglL01h4CoCcxLnU2Iv3iiqFIsENJ_h-IVD9VMZdcTkvTS3hiD52nJ2XozR5UG8gqYf55Og5NBrKBtPo5pLZ6fuKwiHYdIsQlYV_EGuWrGwkmmCiNt_ZDO9szqPIKlz8zeASuuZgCigQcL6B59_kbv1-lbMGip5UQH9TJkdKU121lLA' + } + return variables diff --git a/results/log.html b/results/log.html new file mode 100644 index 00000000..cf5c76c6 --- /dev/null +++ b/results/log.html @@ -0,0 +1,2137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Opening Robot Framework log failed

+
    +
  • Verify that you have JavaScript enabled in your browser.
  • +
  • Make sure you are using a modern enough browser. If using Internet Explorer, version 8 or newer is required.
  • +
  • Check are there messages in your browser's JavaScript error log. Please report the problem if you suspect you have encountered a bug.
  • +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/results/output.xml b/results/output.xml new file mode 100644 index 00000000..887aafca --- /dev/null +++ b/results/output.xml @@ -0,0 +1,183 @@ + + + + + + + + + + + +Logs the given message to the console. + +"Will start Test Case CreateEntity_200_MINIMAL ..." + + + + + +{"id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", "type": "Building"} + + + +http + +*Sends a POST request to the endpoint.* + +${endpoint} +body=${body} + + +${response} + +${response} = {'seconds': 0.5796079999999999, 'status': 401, 'body': '', 'headers': {'Server': 'nginx/1.14.2', 'Date': 'Sat, 12 Sep 2020 00:05:56 GMT', 'Content-Length': '0', 'Connection': 'keep-alive', 'WWW-Authen... + + + + +I/O + +*Outputs JSON to terminal or a file.* + +request + + +{ + "method": "POST", + "url": "https://stellio-dev.eglobalmark.com/ngsi-ld/v1/entities", + "scheme": "https", + "netloc": "stellio-dev.eglobalmark.com", + "path": "/ngsi-ld/v1/entities", + "query": {}, + "body": { + "id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", + "type": "Building" + }, + "headers": { + "Accept": "application/json, */*", + "Content-Type": "application/json", + "User-Agent": "RESTinstance/1.0.2" + }, + "proxies": {}, + "timeout": [ + null, + null + ], + "cert": null, + "sslVerify": true, + "allowRedirects": true, + "timestamp": { + "utc": "2020-09-12T00:05:57.090645+00:00", + "local": "2020-09-12T01:05:57.090645+01:00" + } +} + + + + +I/O + +*Outputs JSON to terminal or a file.* + +response + + +{ + "seconds": 0.5796079999999999, + "status": 401, + "body": "", + "headers": { + "Server": "nginx/1.14.2", + "Date": "Sat, 12 Sep 2020 00:05:56 GMT", + "Content-Length": "0", + "Connection": "keep-alive", + "WWW-Authenticate": "Bearer", + "Cache-Control": "no-cache, no-store, max-age=0, must-revalidate", + "Pragma": "no-cache", + "Expires": "0", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "DENY", + "X-XSS-Protection": "1 ; mode=block", + "Referrer-Policy": "no-referrer" + } +} + + + +Makes a variable available everywhere within the scope of the current test. + +${response} + +${response} = {'seconds': 0.5796079999999999, 'status': 401, 'body': '', 'headers': {'Server': 'nginx/1.14.2', 'Date': 'Sat, 12 Sep 2020 00:05:56 GMT', 'Content-Length': '0', 'Connection': 'keep-alive', 'WWW-Authen... + + + + + + +201 + + +Logs the given message to the console. + +${response} + + + + +Fails if the given objects are unequal. + +${response['status']} +${status} + +Argument types are: +<class 'int'> +<type 'unicode'> +401 != 201 + + + + +TP Variation description. + +critical + +401 != 201 + +TP description. + + + + + + + + + + + + + + + + +Critical Tests +All Tests + + +critical + + +Isg-Cim-Tpdl-Demo +Isg-Cim-Tpdl-Demo.TP +Isg-Cim-Tpdl-Demo.TP.NGSI-LD +Isg-Cim-Tpdl-Demo.TP.NGSI-LD.ContextInformation +Isg-Cim-Tpdl-Demo.TP.NGSI-LD.ContextInformation.Provision +Isg-Cim-Tpdl-Demo.TP.NGSI-LD.ContextInformation.Provision.Entities +Isg-Cim-Tpdl-Demo.TP.NGSI-LD.ContextInformation.Provision.Entities.CreateEntity 200 + + + + + diff --git a/results/report.html b/results/report.html new file mode 100644 index 00000000..ebef607e --- /dev/null +++ b/results/report.html @@ -0,0 +1,2434 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Opening Robot Framework report failed

+
    +
  • Verify that you have JavaScript enabled in your browser.
  • +
  • Make sure you are using a modern enough browser. If using Internet Explorer, version 8 or newer is required.
  • +
  • Check are there messages in your browser's JavaScript error log. Please report the problem if you suspect you have encountered a bug.
  • +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh new file mode 100755 index 00000000..37d96e63 --- /dev/null +++ b/scripts/run_tests.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +#run all tests +robot --outputdir ./results . + +#run all tests with base url overriden +robot --variable url:"URL_HERE" --outputdir ./results . + +#specify which tests are critical +robot --critical critical --outputdir ./results . + +#run by specific tag(s) +robot --include critical --outputdir ./results . +robot --include critical --include negative --outputdir ./results . + +#run specific test suite +robot --outputdir ./results ./TP/NGSI-LD/ContextInformation +robot --outputdir ./results ./TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200.robot + +#run specific test case +robot --outputdir ./results -t "CreateEntity_200_MINIMAL" ./TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200.robot + +#rerun failed tests +robot --rerunfailedsuites ./results/output.xml --outputdir ./results . -- GitLab From e2b97d8e5de3803d5456da019a57e1d14415eb65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patr=C3=ADcia=20Oliveira?= Date: Mon, 14 Sep 2020 17:50:13 +0100 Subject: [PATCH 03/24] Fix test CreateEntity_200_Minimal. Add test CreateEntity_409_AlreadyExists --- .../Provision/Entities/CreateEntity.robot | 53 +++ .../Provision/Entities/CreateEntity_200.robot | 44 -- ...D.robot => CreateEntity_data-driven.robot} | 0 .../schemas/error_response.schema.json | 7 + .../Provision/Entities/schemas/response.json | 73 --- results/log.html | 10 +- results/output.xml | 423 +++++++++++++++--- results/report.html | 10 +- 8 files changed, 421 insertions(+), 199 deletions(-) create mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity.robot delete mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200.robot rename TP/NGSI-LD/ContextInformation/Provision/Entities/{CreateEntity_200_DD.robot => CreateEntity_data-driven.robot} (100%) create mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/schemas/error_response.schema.json delete mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/schemas/response.json diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity.robot new file mode 100644 index 00000000..1faf731c --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity.robot @@ -0,0 +1,53 @@ +*** Settings *** +Documentation TP description. +Variables ../../../../../resources/variables.py +Library REST ${url} +Library JSONSchemaLibrary ${CURDIR}/schemas +Library OperatingSystem +Library String + +#Suite Setup +Suite Teardown Delete Entity by Id urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9 + +*** Variable *** +${endpoint}= entities + +*** Test Case *** +CreateEntity_200_Minimal + [Documentation] TP Variation description. + [Tags] critical + Create Entity building-minimal.jsonld + Check HTTP Status Code Is 201 + +CreateEntity_409_AlreadyExists + Create Entity building-minimal.jsonld + Check HTTP Status Code Is 409 + Check HTTP Response Body Json Schema Is error_response + +*** Keywords *** +Create Entity + [Arguments] ${filename} + &{headers}= Create Dictionary Content-Type=application/ld+json authorization=Bearer ${token} + ${response}= POST ${endpoint} body=${CURDIR}/data/${filename} headers=${headers} + Output request + Output response + Set Test Variable ${response} + +Check HTTP Status Code Is + [Arguments] ${status} + ${response_status}= convert to string ${response['status']} + Should Be Equal ${response_status} ${status} + +Check HTTP Response Body Json Schema Is + [Arguments] ${input} + Should Contain ${response['headers']['Content-Type']} application/json + ${schema}= Catenate SEPARATOR= ${input} .schema.json + Validate Json ${schema} ${response['body']} + Log Json Schema Validation OK + +Delete Entity by Id + [Arguments] ${id} + &{headers}= Create Dictionary authorization=Bearer ${token} + ${response}= DELETE ${endpoint}/${id} headers=${headers} + Output request + Output response \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200.robot deleted file mode 100644 index 68247a18..00000000 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200.robot +++ /dev/null @@ -1,44 +0,0 @@ -*** Settings *** -Documentation TP description. -Variables ../../../../../resources/variables.py -Library REST ${url} -Library JSONSchemaLibrary .schemas/ -Library OperatingSystem - -#Suite Setup -#Suite Teardown - -*** Variable *** -${endpoint}= entities - - -*** Test Case *** -CreateEntity_200_MINIMAL - [Documentation] TP Variation description. - [Tags] critical - Log To Console "Will start Test Case CreateEntity_200_MINIMAL ..." - #TO DO: read body from files - Create Entity {"id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", "type": "Building"} - Check HTTP Status Code Is 201 - Check HTTP Response Body Json Schema Is response.json - -*** Keywords *** -Create Entity - [Arguments] ${body} - ${response} POST ${endpoint} body=${body} - Output request - Output response - Set Test Variable ${response} - -Check HTTP Status Code Is - [Arguments] ${status} - Log To Console ${response} - Should Be Equal ${response['status']} ${status} - -Check HTTP Response Body Json Schema Is - [Arguments] ${input} - Should Contain ${response['headers']['Content-Type']} application/json - ${schema} = Catenate SEPARATOR= ${input} .schema.json - Validate Json ${schema} ${response['body']} - Log Json Schema Validation OK - diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200_DD.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_data-driven.robot similarity index 100% rename from TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_200_DD.robot rename to TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity_data-driven.robot diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/schemas/error_response.schema.json b/TP/NGSI-LD/ContextInformation/Provision/Entities/schemas/error_response.schema.json new file mode 100644 index 00000000..11507449 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/schemas/error_response.schema.json @@ -0,0 +1,7 @@ +{ + "required": [ + "detail", + "type", + "title" + ] +} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/schemas/response.json b/TP/NGSI-LD/ContextInformation/Provision/Entities/schemas/response.json deleted file mode 100644 index f566f086..00000000 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/schemas/response.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "required": [ - "timestamp", - "path", - "status", - "error", - "message", - "requestId" - ], - "properties": { - "timestamp": { - "$id": "#/properties/timestamp", - "type": "integer", - "title": "The timestamp schema", - "description": "An explanation about the purpose of this instance.", - "default": 0, - "examples": [ - 1599842686277 - ] - }, - "path": { - "$id": "#/properties/path", - "type": "string", - "title": "The path schema", - "description": "An explanation about the purpose of this instance.", - "default": "", - "examples": [ - "/ngsi-ld/v1/entities" - ] - }, - "status": { - "$id": "#/properties/status", - "type": "integer", - "title": "The status schema", - "description": "An explanation about the purpose of this instance.", - "default": 0, - "examples": [ - 415 - ] - }, - "error": { - "$id": "#/properties/error", - "type": "string", - "title": "The error schema", - "description": "An explanation about the purpose of this instance.", - "default": "", - "examples": [ - "Unsupported Media Type" - ] - }, - "message": { - "$id": "#/properties/message", - "type": "string", - "title": "The message schema", - "description": "An explanation about the purpose of this instance.", - "default": "", - "examples": [ - "Content type '' not supported" - ] - }, - "requestId": { - "$id": "#/properties/requestId", - "type": "string", - "title": "The requestId schema", - "description": "An explanation about the purpose of this instance.", - "default": "", - "examples": [ - "9a15420d-86" - ] - } - }, - "additionalProperties": true -} \ No newline at end of file diff --git a/results/log.html b/results/log.html index cf5c76c6..3ad41627 100644 --- a/results/log.html +++ b/results/log.html @@ -1743,25 +1743,25 @@ function stopPropagation(event) { window.output = {};