diff --git a/masakari/api/openstack/wsgi.py b/masakari/api/openstack/wsgi.py index fb4648b0..7a14eea2 100644 --- a/masakari/api/openstack/wsgi.py +++ b/masakari/api/openstack/wsgi.py @@ -183,7 +183,7 @@ class Request(wsgi.Request): def set_api_version_request(self): """Set API version request based on the request header information.""" hdr_string = microversion_parse.get_version( - self.headers, service_type='masakari') + self.headers, service_type='instance-ha') if hdr_string is None: self.api_version_request = api_version.APIVersionRequest( @@ -1059,7 +1059,7 @@ class Fault(webob.exc.HTTPException): if not req.api_version_request.is_null(): self.wrapped_exc.headers[API_VERSION_REQUEST_HEADER] = \ - 'masakari ' + req.api_version_request.get_string() + 'instance-ha ' + req.api_version_request.get_string() self.wrapped_exc.headers.add('Vary', API_VERSION_REQUEST_HEADER) self.wrapped_exc.content_type = 'application/json' diff --git a/masakari/tests/unit/api/openstack/test_wsgi.py b/masakari/tests/unit/api/openstack/test_wsgi.py index f91afd37..aa54eb76 100644 --- a/masakari/tests/unit/api/openstack/test_wsgi.py +++ b/masakari/tests/unit/api/openstack/test_wsgi.py @@ -37,7 +37,7 @@ class MicroversionedTest(testscenarios.WithScenarios, test.NoDBTestCase): header_name = 'OpenStack-API-Version' def _make_microversion_header(self, value): - return {self.header_name: value} + return {self.header_name: 'instance-ha %s' % value} class RequestTest(MicroversionedTest): @@ -138,6 +138,12 @@ class RequestTest(MicroversionedTest): self.assertEqual(api_version.APIVersionRequest("1.0"), request.api_version_request) + def test_api_version_request_header_invalid(self): + request = wsgi.Request.blank('/') + request.headers = self._make_microversion_header('1.1.1') + self.assertRaises(exception.InvalidAPIVersionString, + request.set_api_version_request) + class ActionDispatcherTest(test.NoDBTestCase): def test_dispatch(self):