|
| 1 | +# Copyright 2026 Telefonica Investigacion y Desarrollo, S.A.U |
| 2 | +# |
| 3 | +# This file is part of Orion Context Broker. |
| 4 | +# |
| 5 | +# Orion Context Broker is free software: you can redistribute it and/or |
| 6 | +# modify it under the terms of the GNU Affero General Public License as |
| 7 | +# published by the Free Software Foundation, either version 3 of the |
| 8 | +# License, or (at your option) any later version. |
| 9 | +# |
| 10 | +# Orion Context Broker is distributed in the hope that it will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero |
| 13 | +# General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU Affero General Public License |
| 16 | +# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. |
| 17 | +# |
| 18 | +# For those usages not covered by this license please contact with |
| 19 | +# iot_support at tid dot es |
| 20 | + |
| 21 | +# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh |
| 22 | + |
| 23 | +--NAME-- |
| 24 | +TextUnrestricted metadata CRUD transitions support |
| 25 | + |
| 26 | +--SHELL-INIT-- |
| 27 | +dbInit CB |
| 28 | +brokerStart CB |
| 29 | + |
| 30 | +--SHELL-- |
| 31 | + |
| 32 | +# |
| 33 | +# 01. Create entity E with a custom type attribute and no TextUnrestricted metadata |
| 34 | +# 02. Update attribute with forbidden chars and NO metadata, get error |
| 35 | +# 03. Update attribute with forbidden chars and TextUnrestricted metadata as true |
| 36 | +# 04. Update attribute with forbidden chars and TextUnrestricted metadata as false, get error |
| 37 | +# 05. Update attribute with forbidden chars and empty metadata to remove it, get error |
| 38 | +# |
| 39 | + |
| 40 | +echo '01. Create entity E with a custom type attribute and no TextUnrestricted metadata' |
| 41 | +echo '=================================================================================' |
| 42 | +payload='{ |
| 43 | + "id": "E", |
| 44 | + "type": "T", |
| 45 | + "A": { |
| 46 | + "type": "FunnyType", |
| 47 | + "value": "initial value" |
| 48 | + } |
| 49 | +}' |
| 50 | +orionCurl --url /v2/entities --payload "$payload" |
| 51 | +echo |
| 52 | +echo |
| 53 | + |
| 54 | + |
| 55 | +echo '02. Update attribute with forbidden chars and NO metadata, get error' |
| 56 | +echo '====================================================================' |
| 57 | +payload='{ |
| 58 | + "value": "Value with <forbidden> characters (like = or ;)" |
| 59 | +}' |
| 60 | +orionCurl --url /v2/entities/E/attrs/A --payload "$payload" -X PUT |
| 61 | +echo |
| 62 | +echo |
| 63 | + |
| 64 | + |
| 65 | +echo '03. Update attribute with forbidden chars and TextUnrestricted metadata as true' |
| 66 | +echo '===============================================================================' |
| 67 | +payload='{ |
| 68 | + "value": "Value with <forbidden> characters (like = or ;)", |
| 69 | + "metadata": { |
| 70 | + "TextUnrestricted": { |
| 71 | + "value": true, |
| 72 | + "type": "Boolean" |
| 73 | + } |
| 74 | + } |
| 75 | +}' |
| 76 | +orionCurl --url /v2/entities/E/attrs/A --payload "$payload" -X PUT |
| 77 | +echo |
| 78 | +echo |
| 79 | + |
| 80 | + |
| 81 | +echo '04. Update attribute with forbidden chars and TextUnrestricted metadata as false, get error' |
| 82 | +echo '===========================================================================================' |
| 83 | +payload='{ |
| 84 | + "value": "Value with <forbidden> characters (like = or ;)", |
| 85 | + "metadata": { |
| 86 | + "TextUnrestricted": { |
| 87 | + "value": false, |
| 88 | + "type": "Boolean" |
| 89 | + } |
| 90 | + } |
| 91 | +}' |
| 92 | +orionCurl --url /v2/entities/E/attrs/A --payload "$payload" -X PUT |
| 93 | +echo |
| 94 | +echo |
| 95 | + |
| 96 | + |
| 97 | +echo '05. Update attribute with forbidden chars and empty metadata to remove it, get error' |
| 98 | +echo '====================================================================================' |
| 99 | +payload='{ |
| 100 | + "value": "Value with <forbidden> characters (like = or ;)", |
| 101 | + "metadata": {} |
| 102 | +}' |
| 103 | +orionCurl --url /v2/entities/E/attrs/A --payload "$payload" -X PUT |
| 104 | +echo |
| 105 | +echo |
| 106 | + |
| 107 | + |
| 108 | +--REGEXPECT-- |
| 109 | +01. Create entity E with a custom type attribute and no TextUnrestricted metadata |
| 110 | +================================================================================= |
| 111 | +HTTP/1.1 201 Created |
| 112 | +Date: REGEX(.*) |
| 113 | +Fiware-Correlator: REGEX([0-9a-f\-]{36}) |
| 114 | +Location: /v2/entities/E?type=T |
| 115 | +Content-Length: 0 |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | +02. Update attribute with forbidden chars and NO metadata, get error |
| 120 | +==================================================================== |
| 121 | +HTTP/1.1 400 Bad Request |
| 122 | +Date: REGEX(.*) |
| 123 | +Fiware-Correlator: REGEX([0-9a-f\-]{36}) |
| 124 | +Content-Type: application/json |
| 125 | +Content-Length: 76 |
| 126 | + |
| 127 | +{ |
| 128 | + "description": "Invalid characters in attribute value", |
| 129 | + "error": "BadRequest" |
| 130 | +} |
| 131 | + |
| 132 | + |
| 133 | +03. Update attribute with forbidden chars and TextUnrestricted metadata as true |
| 134 | +=============================================================================== |
| 135 | +HTTP/1.1 204 No Content |
| 136 | +Date: REGEX(.*) |
| 137 | +Fiware-Correlator: REGEX([0-9a-f\-]{36}) |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | +04. Update attribute with forbidden chars and TextUnrestricted metadata as false, get error |
| 142 | +=========================================================================================== |
| 143 | +HTTP/1.1 400 Bad Request |
| 144 | +Date: REGEX(.*) |
| 145 | +Fiware-Correlator: REGEX([0-9a-f\-]{36}) |
| 146 | +Content-Type: application/json |
| 147 | +Content-Length: 76 |
| 148 | + |
| 149 | +{ |
| 150 | + "description": "Invalid characters in attribute value", |
| 151 | + "error": "BadRequest" |
| 152 | +} |
| 153 | + |
| 154 | + |
| 155 | +05. Update attribute with forbidden chars and empty metadata to remove it, get error |
| 156 | +==================================================================================== |
| 157 | +HTTP/1.1 400 Bad Request |
| 158 | +Date: REGEX(.*) |
| 159 | +Fiware-Correlator: REGEX([0-9a-f\-]{36}) |
| 160 | +Content-Type: application/json |
| 161 | +Content-Length: 76 |
| 162 | + |
| 163 | +{ |
| 164 | + "description": "Invalid characters in attribute value", |
| 165 | + "error": "BadRequest" |
| 166 | +} |
| 167 | + |
| 168 | + |
| 169 | +--TEARDOWN-- |
| 170 | +brokerStop CB |
| 171 | +dbDrop CB |
0 commit comments