]> xenbits.xensource.com Git - osstest/openstack-nova.git/commitdiff
Return 400 when name is more than 200 characters
authorbhagyashris <bhagyashri.shewale@nttdata.com>
Wed, 30 Nov 2016 15:11:48 +0000 (20:41 +0530)
committerbhagyashris <bhagyashri.shewale@nttdata.com>
Wed, 7 Dec 2016 06:59:10 +0000 (12:29 +0530)
APIs listed below are returning 500 error if you pass name more than
200 characters.
1. create resource_providers
2. update resource_providers

Added maxLength check in schema to ensure name should not be more than
200 characters.

Closes-Bug: #1642485
Change-Id: Ia22ae86702dabe18bc577b17164a81c363da6d41

nova/api/openstack/placement/handlers/resource_provider.py
nova/tests/functional/api/openstack/placement/gabbits/resource-provider.yaml

index 271c8f57a333e8088a5603ac5bb950fd1d66be20..d8a895e790ffa49438b10aa6e62579ebeafa05ec 100644 (file)
@@ -28,7 +28,8 @@ POST_RESOURCE_PROVIDER_SCHEMA = {
     "type": "object",
     "properties": {
         "name": {
-            "type": "string"
+            "type": "string",
+            "maxLength": 200
         },
         "uuid": {
             "type": "string",
index 50d9c40de516235e2be67c8a7446dde398d74732..d564a9905f820f021862b0f727d43e1bf73d00db 100644 (file)
@@ -254,3 +254,23 @@ tests:
   status: 400
   response_strings:
       - "Failed validating 'format'"
+
+- name: try to create resource provider with name exceed max characters
+  POST: /resource_providers
+  request_headers:
+      content-type: application/json
+  data:
+      name: &name_exceeds_max_length_check This is a long text of 201 charactersssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
+  status: 400
+  response_strings:
+      - "Failed validating 'maxLength'"
+
+- name: try to update resource provider with name exceed max characters
+  PUT: /resource_providers/$ENVIRON['RP_UUID']
+  request_headers:
+      content-type: application/json
+  data:
+      name: *name_exceeds_max_length_check
+  status: 400
+  response_strings:
+      - "Failed validating 'maxLength'"