From f755865c4bfa526d43fb21914be0e6fa844ec327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 5 Jun 2024 12:17:54 +0200 Subject: [PATCH] FIX issue raised in code review --- .../ngsi10.test.DISABLED | 365 ------------------ .../ngsi9.test.DISABLED | 335 ---------------- .../0968_invalid_regex_subs.test} | 54 +-- 3 files changed, 16 insertions(+), 738 deletions(-) delete mode 100644 test/functionalTest/cases/0585_empty_type_in_response/ngsi10.test.DISABLED delete mode 100644 test/functionalTest/cases/0585_empty_type_in_response/ngsi9.test.DISABLED rename test/functionalTest/cases/{0968_ngsi10_asterisk_subs/0968_ngsi10_asterisk_subs.test.DISABLED => 0968_invalid_regex_subs/0968_invalid_regex_subs.test} (62%) diff --git a/test/functionalTest/cases/0585_empty_type_in_response/ngsi10.test.DISABLED b/test/functionalTest/cases/0585_empty_type_in_response/ngsi10.test.DISABLED deleted file mode 100644 index cd04a058c6..0000000000 --- a/test/functionalTest/cases/0585_empty_type_in_response/ngsi10.test.DISABLED +++ /dev/null @@ -1,365 +0,0 @@ -# Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -NGSI10 Empty Entity Type Check - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- - -# -# 01. Update/APPEND an entity with type Room and id Room, Attribute temperature -# 02. Query with convop GET /v1/contextEntities/Room -# 03. Query with convop GET /v1/contextEntities/Room/attributes/temperature -# 04. Query with convop GET /v1/contextEntities/type/Room/id/Room -# 05. Query with convop GET /v1/contextEntities/type/Room/id/Room/attributes/temperature -# 06. Query with convop GET /v1/contextEntityTypes/Room -# 07. Query with convop GET /v1/contextEntityTypes/Room/attributes/temperature -# - -echo "01. Update/APPEND an entity with type Room and id Room, Attribute temperature" -echo "=============================================================================" -payload='{ - "contextElements": [ - { - "type": "Room", - "isPattern": "false", - "id": "Room", - "attributes": [ - { - "name": "temperature", - "type": "degree", - "value": "20", - "metadatas": [ - { - "name": "ID", - "type": "string", - "value": "backup" - } - ] - } - ] - } - ], - "updateAction": "APPEND" -}' -orionCurl --url /v1/updateContext --payload "$payload" -echo -echo - - -echo "02. Query with convop GET /v1/contextEntities/Room" -echo "==================================================" -orionCurl --url /v1/contextEntities/Room -echo -echo - - -echo "03. Query with convop GET /v1/contextEntities/Room/attributes/temperature" -echo "=========================================================================" -orionCurl --url /v1/contextEntities/Room/attributes/temperature -echo -echo - - -echo "04. Query with convop GET /v1/contextEntities/type/Room/id/Room" -echo "===============================================================" -orionCurl --url /v1/contextEntities/type/Room/id/Room -echo -echo - - -echo "05. Query with convop GET /v1/contextEntities/type/Room/id/Room/attributes/temperature" -echo "======================================================================================" -orionCurl --url /v1/contextEntities/type/Room/id/Room/attributes/temperature -echo -echo - - -echo "06. Query with convop GET /v1/contextEntityTypes/Room" -echo "=====================================================" -orionCurl --url /v1/contextEntityTypes/Room -echo -echo - - -echo "07. Query with convop GET /v1/contextEntityTypes/Room/attributes/temperature" -echo "============================================================================" -orionCurl --url /v1/contextEntityTypes/Room/attributes/temperature -echo -echo - - ---REGEXPECT-- -01. Update/APPEND an entity with type Room and id Room, Attribute temperature -============================================================================= -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 263 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "ID", - "type": "string", - "value": "backup" - } - ], - "name": "temperature", - "type": "degree", - "value": "" - } - ], - "id": "Room", - "isPattern": "false", - "type": "Room" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - -02. Query with convop GET /v1/contextEntities/Room -================================================== -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 242 - -{ - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "ID", - "type": "string", - "value": "backup" - } - ], - "name": "temperature", - "type": "degree", - "value": "20" - } - ], - "id": "Room", - "isPattern": "false", - "type": "Room" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } -} - - -03. Query with convop GET /v1/contextEntities/Room/attributes/temperature -========================================================================= -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 177 - -{ - "attributes": [ - { - "metadatas": [ - { - "name": "ID", - "type": "string", - "value": "backup" - } - ], - "name": "temperature", - "type": "degree", - "value": "20" - } - ], - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } -} - - -04. Query with convop GET /v1/contextEntities/type/Room/id/Room -=============================================================== -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 242 - -{ - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "ID", - "type": "string", - "value": "backup" - } - ], - "name": "temperature", - "type": "degree", - "value": "20" - } - ], - "id": "Room", - "isPattern": "false", - "type": "Room" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } -} - - -05. Query with convop GET /v1/contextEntities/type/Room/id/Room/attributes/temperature -====================================================================================== -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 177 - -{ - "attributes": [ - { - "metadatas": [ - { - "name": "ID", - "type": "string", - "value": "backup" - } - ], - "name": "temperature", - "type": "degree", - "value": "20" - } - ], - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } -} - - -06. Query with convop GET /v1/contextEntityTypes/Room -===================================================== -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 265 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "ID", - "type": "string", - "value": "backup" - } - ], - "name": "temperature", - "type": "degree", - "value": "20" - } - ], - "id": "Room", - "isPattern": "false", - "type": "Room" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - -07. Query with convop GET /v1/contextEntityTypes/Room/attributes/temperature -============================================================================ -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 265 - -{ - "contextResponses": [ - { - "contextElement": { - "attributes": [ - { - "metadatas": [ - { - "name": "ID", - "type": "string", - "value": "backup" - } - ], - "name": "temperature", - "type": "degree", - "value": "20" - } - ], - "id": "Room", - "isPattern": "false", - "type": "Room" - }, - "statusCode": { - "code": "200", - "reasonPhrase": "OK" - } - } - ] -} - - ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/0585_empty_type_in_response/ngsi9.test.DISABLED b/test/functionalTest/cases/0585_empty_type_in_response/ngsi9.test.DISABLED deleted file mode 100644 index 5136e99181..0000000000 --- a/test/functionalTest/cases/0585_empty_type_in_response/ngsi9.test.DISABLED +++ /dev/null @@ -1,335 +0,0 @@ -# Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U -# -# This file is part of Orion Context Broker. -# -# Orion Context Broker is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# Orion Context Broker is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -# General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -# -# For those usages not covered by this license please contact with -# iot_support at tid dot es - -# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh - ---NAME-- -NGSI9 Empty Entity Type Check - ---SHELL-INIT-- -dbInit CB -brokerStart CB - ---SHELL-- - -# -# 01. Register an entity with type Room and id Room -# 02. Discover with convop GET /v1/registry/contextEntities/Room -# 03. Discover with convop GET /v1/registry/contextEntities/Room/attributes/temperature -# 04. Discover with convop GET /v1/registry/contextEntityTypes/Room -# 05. Discover with convop GET /v1/registry/contextEntityTypes/Room/attributes/temperature -# 06. Discover with convop GET /v1/registry/contextEntities/type/Room/id/Room -# 07. Discover with convop GET /v1/registry/contextEntities/type/Room/id/Room/attributes/temperature -# - -echo "01. Register an entity with type Room and id Room" -echo "=================================================" -payload='{ - "contextRegistrations": [ - { - "entities": [ - { - "type": "Room", - "isPattern": "false", - "id": "Room" - }, - { - "type": "Room", - "isPattern": "false", - "id": "OfficeRoom" - } - ], - "attributes": [ - { - "name": "temperature", - "type": "degree" - } - ], - "providingApplication": "http://localhost:1028/application" - } - ], - "duration": "PT1H" -}' -orionCurl --url /v1/registry/registerContext --payload "$payload" -echo -echo - - -echo "02. Discover with convop GET /v1/registry/contextEntities/Room" -echo "==============================================================" -orionCurl --url /v1/registry/contextEntities/Room -echo -echo - - -echo "03. Discover with convop GET /v1/registry/contextEntities/Room/attributes/temperature" -echo "=====================================================================================" -orionCurl --url /v1/registry/contextEntities/Room/attributes/temperature -echo -echo - - -echo "04. Discover with convop GET /v1/registry/contextEntityTypes/Room" -echo "=================================================================" -orionCurl --url /v1/registry/contextEntityTypes/Room -echo -echo - - -echo "05. Discover with convop GET /v1/registry/contextEntityTypes/Room/attributes/temperature" -echo "========================================================================================" -orionCurl --url /v1/registry/contextEntityTypes/Room/attributes/temperature -echo -echo - -echo "06. Discover with convop GET /v1/registry/contextEntities/type/Room/id/Room" -echo "===========================================================================" -orionCurl --url /v1/registry/contextEntities/type/Room/id/Room -echo -echo - - -echo "07. Discover with convop GET /v1/registry/contextEntities/type/Room/id/Room/attributes/temperature" -echo "==================================================================================================" -orionCurl --url /v1/registry/contextEntities/type/Room/id/Room/attributes/temperature -echo -echo - - ---REGEXPECT-- -01. Register an entity with type Room and id Room -================================================= -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 63 - -{ - "duration": "PT1H", - "registrationId": "REGEX([0-9a-f]{24})" -} - - -02. Discover with convop GET /v1/registry/contextEntities/Room -============================================================== -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 234 - -{ - "contextRegistrationResponses": [ - { - "contextRegistration": { - "attributes": [ - { - "name": "temperature", - "type": "degree" - } - ], - "entities": [ - { - "id": "Room", - "isPattern": "false", - "type": "Room" - } - ], - "providingApplication": "http://localhost:1028/application" - } - } - ] -} - - -03. Discover with convop GET /v1/registry/contextEntities/Room/attributes/temperature -===================================================================================== -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 234 - -{ - "contextRegistrationResponses": [ - { - "contextRegistration": { - "attributes": [ - { - "name": "temperature", - "type": "degree" - } - ], - "entities": [ - { - "id": "Room", - "isPattern": "false", - "type": "Room" - } - ], - "providingApplication": "http://localhost:1028/application" - } - } - ] -} - - -04. Discover with convop GET /v1/registry/contextEntityTypes/Room -================================================================= -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 288 - -{ - "contextRegistrationResponses": [ - { - "contextRegistration": { - "attributes": [ - { - "name": "temperature", - "type": "degree" - } - ], - "entities": [ - { - "id": "Room", - "isPattern": "false", - "type": "Room" - }, - { - "id": "OfficeRoom", - "isPattern": "false", - "type": "Room" - } - ], - "providingApplication": "http://localhost:1028/application" - } - } - ] -} - - -05. Discover with convop GET /v1/registry/contextEntityTypes/Room/attributes/temperature -======================================================================================== -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 288 - -{ - "contextRegistrationResponses": [ - { - "contextRegistration": { - "attributes": [ - { - "name": "temperature", - "type": "degree" - } - ], - "entities": [ - { - "id": "Room", - "isPattern": "false", - "type": "Room" - }, - { - "id": "OfficeRoom", - "isPattern": "false", - "type": "Room" - } - ], - "providingApplication": "http://localhost:1028/application" - } - } - ] -} - - -06. Discover with convop GET /v1/registry/contextEntities/type/Room/id/Room -=========================================================================== -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 234 - -{ - "contextRegistrationResponses": [ - { - "contextRegistration": { - "attributes": [ - { - "name": "temperature", - "type": "degree" - } - ], - "entities": [ - { - "id": "Room", - "isPattern": "false", - "type": "Room" - } - ], - "providingApplication": "http://localhost:1028/application" - } - } - ] -} - - -07. Discover with convop GET /v1/registry/contextEntities/type/Room/id/Room/attributes/temperature -================================================================================================== -HTTP/1.1 200 OK -Date: REGEX(.*) -Fiware-Correlator: REGEX([0-9a-f\-]{36}) -Content-Type: application/json -Content-Length: 234 - -{ - "contextRegistrationResponses": [ - { - "contextRegistration": { - "attributes": [ - { - "name": "temperature", - "type": "degree" - } - ], - "entities": [ - { - "id": "Room", - "isPattern": "false", - "type": "Room" - } - ], - "providingApplication": "http://localhost:1028/application" - } - } - ] -} - - ---TEARDOWN-- -brokerStop CB -dbDrop CB diff --git a/test/functionalTest/cases/0968_ngsi10_asterisk_subs/0968_ngsi10_asterisk_subs.test.DISABLED b/test/functionalTest/cases/0968_invalid_regex_subs/0968_invalid_regex_subs.test similarity index 62% rename from test/functionalTest/cases/0968_ngsi10_asterisk_subs/0968_ngsi10_asterisk_subs.test.DISABLED rename to test/functionalTest/cases/0968_invalid_regex_subs/0968_invalid_regex_subs.test index 51d1ed2ff5..88b6207876 100644 --- a/test/functionalTest/cases/0968_ngsi10_asterisk_subs/0968_ngsi10_asterisk_subs.test.DISABLED +++ b/test/functionalTest/cases/0968_invalid_regex_subs/0968_invalid_regex_subs.test @@ -21,7 +21,7 @@ # VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh --NAME-- -NGSI10 subscription with invalid regex "*" +Subscription with invalid regex "*" --SHELL-INIT-- dbInit CB @@ -37,38 +37,21 @@ echo "01. Create subscription with invalid regex" echo "==========================================" payload=' { + "subject": { "entities": [ { "type": "Patient", - "isPattern": "true", - "id": "*" + "idPattern": "*" } - ], - "attributes": [ - "Blood glucose", - "Body temperature", - "Systolic blood pressure", - "Diastolic blood pressure", - "Respiration rate", - "Heart rate", - "Blood oxygen", - "timestamp" - ], - "reference": "http://A.B.C.D:5999/orion2mysql", - "duration": "P1Y", - "notifyConditions": [ - { - "type": "ONCHANGE", - "condValues": [ - "timestamp" - ] - } - ], - "throttling": "PT1S" -} -' - -orionCurl --url /v1/subscribeContext --payload "$payload" + ] + }, + "notification": { + "http": { + "url": "http://A.B.C.D:5999/orion2mysql" + } + } +}' +orionCurl --url /v2/subscriptions --payload "$payload" echo echo @@ -76,20 +59,15 @@ echo --REGEXPECT-- 01. Create subscription with invalid regex ========================================== -HTTP/1.1 200 OK +HTTP/1.1 400 Bad Request Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 141 +Content-Length: 73 { - "subscribeError": { - "errorCode": { - "code": "400", - "details": "invalid payload: invalid regex for entity id pattern", - "reasonPhrase": "Bad Request" - } - } + "description": "Invalid regex for entity idPattern", + "error": "BadRequest" }