Merge "[placement] Fix an error message in API validation"
This commit is contained in:
commit
892d5d06c0
nova
@ -99,9 +99,9 @@ def put_trait(req):
|
|||||||
jsonschema.validate(name, CUSTOM_TRAIT)
|
jsonschema.validate(name, CUSTOM_TRAIT)
|
||||||
except jsonschema.ValidationError:
|
except jsonschema.ValidationError:
|
||||||
raise webob.exc.HTTPBadRequest(
|
raise webob.exc.HTTPBadRequest(
|
||||||
_('The trait is invalid. A valid trait must include prefix '
|
_('The trait is invalid. A valid trait must be no longer than '
|
||||||
'"CUSTOM_" and use following characters: "A"-"Z", "0"-"9" and '
|
'255 characters, start with the prefix "CUSTOM_" and use '
|
||||||
'"_"'))
|
'following characters: "A"-"Z", "0"-"9" and "_"'))
|
||||||
|
|
||||||
trait = rp_obj.Trait(context)
|
trait = rp_obj.Trait(context)
|
||||||
trait.name = name
|
trait.name = name
|
||||||
|
@ -13,13 +13,19 @@ tests:
|
|||||||
PUT: /traits/TRAIT_X
|
PUT: /traits/TRAIT_X
|
||||||
status: 400
|
status: 400
|
||||||
response_strings:
|
response_strings:
|
||||||
- 'The trait is invalid. A valid trait must include prefix \"CUSTOM_\" and use following characters: \"A\"-\"Z\", \"0\"-\"9\" and \"_\"'
|
- 'The trait is invalid. A valid trait must be no longer than 255 characters, start with the prefix \"CUSTOM_\" and use following characters: \"A\"-\"Z\", \"0\"-\"9\" and \"_\"'
|
||||||
|
|
||||||
- name: create a trait with invalid characters
|
- name: create a trait with invalid characters
|
||||||
PUT: /traits/CUSTOM_ABC:1
|
PUT: /traits/CUSTOM_ABC:1
|
||||||
status: 400
|
status: 400
|
||||||
response_strings:
|
response_strings:
|
||||||
- 'The trait is invalid. A valid trait must include prefix \"CUSTOM_\" and use following characters: \"A\"-\"Z\", \"0\"-\"9\" and \"_\"'
|
- 'The trait is invalid. A valid trait must be no longer than 255 characters, start with the prefix \"CUSTOM_\" and use following characters: \"A\"-\"Z\", \"0\"-\"9\" and \"_\"'
|
||||||
|
|
||||||
|
- name: create a trait with name exceed max characters
|
||||||
|
PUT: /traits/CUSTOM_ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNO
|
||||||
|
status: 400
|
||||||
|
response_strings:
|
||||||
|
- 'The trait is invalid. A valid trait must be no longer than 255 characters, start with the prefix \"CUSTOM_\" and use following characters: \"A\"-\"Z\", \"0\"-\"9\" and \"_\"'
|
||||||
|
|
||||||
- name: create a trait
|
- name: create a trait
|
||||||
PUT: /traits/CUSTOM_TRAIT_1
|
PUT: /traits/CUSTOM_TRAIT_1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user