Return 400 when name is more than 255 characters

APIs listed below are returning 500 error if you pass name more than
255 characters.
1. create resource_classes
2. update resource_classes

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

Closes-Bug: #1648314
Change-Id: I4ae54f3061fe43d87a656088db1d2ae454eb8237
This commit is contained in:
bhagyashris 2016-12-07 18:28:48 +05:30
parent 1795699bc3
commit 874e666e7a
2 changed files with 21 additions and 0 deletions

View File

@ -29,6 +29,7 @@ POST_RC_SCHEMA_V1_2 = {
"name": {
"type": "string",
"pattern": "^CUSTOM\_[A-Z0-9_]+$",
"maxLength": 255,
},
},
"required": [

View File

@ -195,3 +195,23 @@ tests:
status: 400
response_strings:
- JSON does not validate
- name: try to create resource class with name exceed max characters
POST: /resource_classes
request_headers:
content-type: application/json
data:
name: &name_exceeds_max_length_check CUSTOM_THIS_IS_A_LONG_TEXT_OF_LENGTH_256_CHARACTERSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
status: 400
response_strings:
- "Failed validating 'maxLength'"
- name: try to update resource class with name exceed max characters
PUT: /resource_classes/$ENVIRON['CUSTOM_RES_CLASS']
request_headers:
content-type: application/json
data:
name: *name_exceeds_max_length_check
status: 400
response_strings:
- "Failed validating 'maxLength'"