Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in POST v2/op/update (batch op) ID validations fail for attr_name #2673

Closed
iariasleon opened this issue Nov 15, 2016 · 2 comments
Closed

in POST v2/op/update (batch op) ID validations fail for attr_name #2673

iariasleon opened this issue Nov 15, 2016 · 2 comments

Comments

@iariasleon
Copy link
Contributor

iariasleon commented Nov 15, 2016

Case 1 - not plain ascii chars are allowed in attribute name

in POST v2/op/update (batch op) not plain ascii chars are allowed in attribute name. See similar issues: #2658, #2664.

Dataset used

      | entities_id |
      |-------------|
      | habitación  |
      | españa      |
      | barça       |

update batch operation request

url: POST http://localhost:1026/v2/op/update
headers:
    Content-Type: application/json
    Fiware-Service: test_op_update_entitiies_type_error
    Fiware-ServicePath: /test
payload:  {"entities": [{"barça": {"value": "34", "metadata": {"warning": {"type": "alarm", "value": "hot"}}}, "type": "house", "id": "room1"}], "actionType": "APPEND"}

Response

http code: 204 - No Content
headers:
   Connection: Keep-Alive
   Content-Length: 0
   Fiware-Correlator: a4910862-ab21-11e6-a0c8-005056a20feb
   Date: Tue, 15 Nov 2016 10:52:46 GMT
payload:

Expected response

http code: 400 - Bad Request
{"error":"BadRequest","description":"Invalid characters in attribute name"}

doc in mongo

{ "_id" : { "id" : "room1", "type" : "house", "servicePath" : "/test" }, "attrNames" : [ "habitación", "españa", "barça" ], "attrs" : { "habitación" : { "type" : "Text", "creDate" : 1479207166, "modDate" : 1479207166, "value" : "34", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ] }, "españa" : { "value" : "34", "type" : "Text", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ], "creDate" : 1479207166, "modDate" : 1479207166 }, "barça" : { "value" : "34", "type" : "Text", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ], "creDate" : 1479207166, "modDate" : 1479207166 } }, "creDate" : 1479207166, "modDate" : 1479207166 }

Case 2 - length longer than 256 chars in attribute name

in POST v2/op/update (batch op) length longer than 256 chars in attribute name. See similar issues: #2658, #2664.

update batch operation request

url: POST http://localhost:1026/v2/op/update
headers:
    Content-Type: application/json
    Fiware-Service: test_op_update_entitiies_type_error
    Fiware-ServicePath: /test
payload:   {"entities": [{"type": "house", "rtYuafW55ZGKjrcdpn9UyldQU7tdJOQqXIK1NFh0zRytRLgICL4NTsVkDBLWOyyd4NrxbCqNaUrfdoyrBU8hPwYtp9CnCNy5kSJaqp3YRz8rO7vC7hywQlQGes8Ojpyrsl6CuolBcdyNlgqsZHzVyoH366K7JxrmYTcu7fEkTaDNTaocZioQLIlbYvhlDyxeqj0QOAbgpwJyrrh1RXWbZiu38nZbp4SHbp5HXCc74wQNltMEHqAKw7nknLO1MP777": {"value": "34", "metadata": {"warning": {"type": "alarm", "value": "hot"}}}, "id": "room1"}], "actionType": "APPEND"}

Response

http code: 204 - No Content
headers:
headers:
   Connection: Keep-Alive
   Content-Length: 0
   Fiware-Correlator: aaf5ada6-ab40-11e6-8433-005056a20feb
   Date: Tue, 15 Nov 2016 14:34:51 GMT
payload:

Expected response

http code: 400 - Bad Request
{"error":"BadRequest","description":"attribute name length: 257, max length supported: 256"}

doc in mongo

{ "_id" : { "id" : "room1", "type" : "house", "servicePath" : "/test" }, "attrNames" : [ "<attributes_name>", "rtYuafW55ZGKjrcdpn9UyldQU7tdJOQqXIK1NFh0zRytRLgICL4NTsVkDBLWOyyd4NrxbCqNaUrfdoyrBU8hPwYtp9CnCNy5kSJaqp3YRz8rO7vC7hywQlQGes8Ojpyrsl6CuolBcdyNlgqsZHzVyoH366K7JxrmYTcu7fEkTaDNTaocZioQLIlbYvhlDyxeqj0QOAbgpwJyrrh1RXWbZiu38nZbp4SHbp5HXCc74wQNltMEHqAKw7nknLO1MP777" ], "attrs" : { "<attributes_name>" : { "type" : "Text", "creDate" : 1479220336, "modDate" : 1479220336, "value" : "34", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ] }, "rtYuafW55ZGKjrcdpn9UyldQU7tdJOQqXIK1NFh0zRytRLgICL4NTsVkDBLWOyyd4NrxbCqNaUrfdoyrBU8hPwYtp9CnCNy5kSJaqp3YRz8rO7vC7hywQlQGes8Ojpyrsl6CuolBcdyNlgqsZHzVyoH366K7JxrmYTcu7fEkTaDNTaocZioQLIlbYvhlDyxeqj0QOAbgpwJyrrh1RXWbZiu38nZbp4SHbp5HXCc74wQNltMEHqAKw7nknLO1MP777" : { "value" : "34", "type" : "Text", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ], "creDate" : 1479220491, "modDate" : 1479220491 } }, "creDate" : 1479220336, "modDate" : 1479220491 }

Case 3 - forbidden chars in attribute name

in POST v2/op/update (batch op) forbidden chars in attribute name. See similar issues: #2658, #2664.

datased used

      | attributes_name |
      |---------------------|
      | house<flat>     |
      | house=flat      |
      | house"flat"     |
      | house'flat'     |
      | house;flat      |
      | house(flat)     |
      | house_?         |
      | house_&         |
      | house_/         |
      | house_#         |

update batch operation request

url: POST http://localhost:1026/v2/op/update
headers:
    Content-Type: application/json
    Fiware-Service: test_op_update_entitiies_type_error
    Fiware-ServicePath: /test
payload:    {"entities": [{"type": "house", "house_#": {"value": "34", "metadata": {"warning": {"type": "alarm", "value": "hot"}}}, "id": "room1"}], "actionType": "APPEND"}

Response

http code: 204 - No Content
headers:
headers:
   Connection: Keep-Alive
   Content-Length: 0
   Fiware-Correlator: 3fdb33ae-ab42-11e6-8e40-005056a20feb
   Date: Tue, 15 Nov 2016 14:46:10 GMT
payload:

Expected response

http code: 400 - Bad Request
{"error":"BadRequest","description":"Invalid characters in attribute name"}

doc in mongo

{ "_id" : { "id" : "room1", "type" : "house", "servicePath" : "/test" }, "attrNames" : [ "house<flat>", "house=flat", "house\"flat\"", "house'flat'", "house;flat", "house(flat)", "house_?", "house_&", "house_/", "house_#" ], "attrs" : { "house<flat>" : { "type" : "Text", "creDate" : 1479221431, "modDate" : 1479221431, "value" : "34", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ] }, "house=flat" : { "value" : "34", "type" : "Text", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ], "creDate" : 1479221431, "modDate" : 1479221431 }, "house"flat"" : { "value" : "34", "type" : "Text", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ], "creDate" : 1479221431, "modDate" : 1479221431 }, "house'flat'" : { "value" : "34", "type" : "Text", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ], "creDate" : 1479221431, "modDate" : 1479221431 }, "house;flat" : { "value" : "34", "type" : "Text", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ], "creDate" : 1479221431, "modDate" : 1479221431 }, "house(flat)" : { "value" : "34", "type" : "Text", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ], "creDate" : 1479221431, "modDate" : 1479221431 }, "house_?" : { "value" : "34", "type" : "Text", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ], "creDate" : 1479221432, "modDate" : 1479221432 }, "house_&" : { "value" : "34", "type" : "Text", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ], "creDate" : 1479221432, "modDate" : 1479221432 }, "house_/" : { "value" : "34", "type" : "Text", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ], "creDate" : 1479221432, "modDate" : 1479221432 }, "house_#" : { "value" : "34", "type" : "Text", "md" : { "warning" : { "type" : "alarm", "value" : "hot" } }, "mdNames" : [ "warning" ], "creDate" : 1479221432, "modDate" : 1479221432 } }, "creDate" : 1479221431, "modDate" : 1479221432 }
@iariasleon iariasleon changed the title in POST v2/op/update (batch op) not plain ascii chars are allowed in the attribute name in POST v2/op/update (batch op) ID validations fail for attr_name Nov 15, 2016
@fgalan
Copy link
Member

fgalan commented Nov 15, 2016

Fixed by PR #2679.

@iariasleon
Copy link
Contributor Author

LGTM

@iariasleon iariasleon added this to the 1.6.0 milestone Nov 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants