Fix Masakari API to properly return error codes

Change-Id: I538b9b143c868d9419709356daf0ffc48e2f0df9
Closes-Bug: #1932194
This commit is contained in:
Mitya_Eremeev 2021-07-09 11:37:37 +03:00 committed by Radosław Piliszek
parent 4e84d3a9c9
commit 5c6fd44504
3 changed files with 10 additions and 3 deletions

View File

@ -44,7 +44,7 @@ CONF = masakari.conf.CONF
class ConvertedException(webob.exc.WSGIHTTPException):
def __init__(self, code, title="", explanation=""):
self.code = code
self.code = int(code)
# There is a strict rule about constructing status line for HTTP:
# '...Status-Line, consisting of the protocol version followed by a
# numeric status code and its associated textual phrase, with each

View File

@ -253,8 +253,9 @@ class ResourceTest(MicroversionedTest):
@extensions.expected_errors(HTTPStatus.BAD_REQUEST)
def create(self, req, body):
if expected_body != body:
msg = "The request body invalid"
raise webob.exc.HTTPBadRequest(explanation=msg)
raise exception.ConvertedException(
code=HTTPStatus.BAD_REQUEST,
explanation="The request body invalid")
return "success"
# verify the method: POST
app = fakes.TestRouter(Controller())

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes Masakari API to properly return error codes for invalid requests
to the user instead of 500.
`LP#1932194 <https://launchpad.net/bugs/1932194>`__