[placement] Require at least one resource class in allocation
If an allocation was made with an empty resources object, a 500 response code would result. This change adjusts the schema to use minProperties of 1 to say there must be at least one resource class and value pair in the allocation. If there is not a 400 response is returned. As this is fixing 500 response to a useful error, no microversion is required. A previous gabbi file which demonstrated the problem has been updated to demonstrate that the problem has been fixed. Change-Id: I7d9c64c77586564fb3bdbe92c693bd2a1bc06f24 Closes-Bug: #1714072
This commit is contained in:
parent
ad2d3fc0f8
commit
10f8a9aa12
@ -51,6 +51,7 @@ ALLOCATION_SCHEMA = {
|
|||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"minProperties": 1,
|
||||||
"patternProperties": {
|
"patternProperties": {
|
||||||
"^[0-9A-Z_]+$": {
|
"^[0-9A-Z_]+$": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Bug 1714072 describes a situation where a resource provider is present in the
|
# Bug 1714072 describes a situation where a resource provider is present in the
|
||||||
# body of an allocation, but the resources object is empty. There should be at
|
# body of an allocation, but the resources object is empty. There should be at
|
||||||
# least one resource class and value pair. If there is not a 400 response
|
# least one resource class and value pair. If there is not a 400 response
|
||||||
# should be returned. This gabbit file demonstrates the problem: a 500 on the final
|
# should be returned.
|
||||||
# test.
|
|
||||||
|
|
||||||
fixtures:
|
fixtures:
|
||||||
- APIFixture
|
- APIFixture
|
||||||
@ -59,5 +58,6 @@ tests:
|
|||||||
resources: {}
|
resources: {}
|
||||||
project_id: 42a32c07-3eeb-4401-9373-68a8cdca6784
|
project_id: 42a32c07-3eeb-4401-9373-68a8cdca6784
|
||||||
user_id: 66cb2f29-c86d-47c3-8af5-69ae7b778c70
|
user_id: 66cb2f29-c86d-47c3-8af5-69ae7b778c70
|
||||||
# This should be 400
|
status: 400
|
||||||
status: 500
|
response_strings:
|
||||||
|
- does not have enough properties
|
||||||
|
Loading…
Reference in New Issue
Block a user