Merge "V3 xml responses should use v3 namespace."
This commit is contained in:
commit
c1cf07c74c
@ -15,6 +15,12 @@ paste.filter_factory = keystone.middleware:AdminTokenAuthMiddleware.factory
|
|||||||
[filter:xml_body]
|
[filter:xml_body]
|
||||||
paste.filter_factory = keystone.middleware:XmlBodyMiddleware.factory
|
paste.filter_factory = keystone.middleware:XmlBodyMiddleware.factory
|
||||||
|
|
||||||
|
[filter:xml_body_v2]
|
||||||
|
paste.filter_factory = keystone.middleware:XmlBodyMiddlewareV2.factory
|
||||||
|
|
||||||
|
[filter:xml_body_v3]
|
||||||
|
paste.filter_factory = keystone.middleware:XmlBodyMiddlewareV3.factory
|
||||||
|
|
||||||
[filter:json_body]
|
[filter:json_body]
|
||||||
paste.filter_factory = keystone.middleware:JsonBodyMiddleware.factory
|
paste.filter_factory = keystone.middleware:JsonBodyMiddleware.factory
|
||||||
|
|
||||||
@ -73,13 +79,13 @@ paste.app_factory = keystone.service:v3_app_factory
|
|||||||
paste.app_factory = keystone.service:admin_app_factory
|
paste.app_factory = keystone.service:admin_app_factory
|
||||||
|
|
||||||
[pipeline:public_api]
|
[pipeline:public_api]
|
||||||
pipeline = sizelimit url_normalize build_auth_context token_auth admin_token_auth xml_body json_body ec2_extension user_crud_extension public_service
|
pipeline = sizelimit url_normalize build_auth_context token_auth admin_token_auth xml_body_v2 json_body ec2_extension user_crud_extension public_service
|
||||||
|
|
||||||
[pipeline:admin_api]
|
[pipeline:admin_api]
|
||||||
pipeline = sizelimit url_normalize build_auth_context token_auth admin_token_auth xml_body json_body ec2_extension s3_extension crud_extension admin_service
|
pipeline = sizelimit url_normalize build_auth_context token_auth admin_token_auth xml_body_v2 json_body ec2_extension s3_extension crud_extension admin_service
|
||||||
|
|
||||||
[pipeline:api_v3]
|
[pipeline:api_v3]
|
||||||
pipeline = sizelimit url_normalize build_auth_context token_auth admin_token_auth xml_body json_body ec2_extension_v3 s3_extension simple_cert_extension service_v3
|
pipeline = sizelimit url_normalize build_auth_context token_auth admin_token_auth xml_body_v3 json_body ec2_extension_v3 s3_extension simple_cert_extension service_v3
|
||||||
|
|
||||||
[app:public_version_service]
|
[app:public_version_service]
|
||||||
paste.app_factory = keystone.service:public_version_app_factory
|
paste.app_factory = keystone.service:public_version_app_factory
|
||||||
|
@ -151,6 +151,7 @@ class XmlBodyMiddleware(wsgi.Middleware):
|
|||||||
remove_in=+2)
|
remove_in=+2)
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(XmlBodyMiddleware, self).__init__(*args, **kwargs)
|
super(XmlBodyMiddleware, self).__init__(*args, **kwargs)
|
||||||
|
self.xmlns = None
|
||||||
|
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
"""Transform the request from XML to JSON."""
|
"""Transform the request from XML to JSON."""
|
||||||
@ -173,13 +174,29 @@ class XmlBodyMiddleware(wsgi.Middleware):
|
|||||||
response.content_type = 'application/xml'
|
response.content_type = 'application/xml'
|
||||||
try:
|
try:
|
||||||
body_obj = jsonutils.loads(response.body)
|
body_obj = jsonutils.loads(response.body)
|
||||||
response.body = serializer.to_xml(body_obj)
|
response.body = serializer.to_xml(body_obj, xmlns=self.xmlns)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('Serializer failed')
|
LOG.exception('Serializer failed')
|
||||||
raise exception.Error(message=response.body)
|
raise exception.Error(message=response.body)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
class XmlBodyMiddlewareV2(XmlBodyMiddleware):
|
||||||
|
"""De/serializes XML to/from JSON for v2.0 API."""
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(XmlBodyMiddlewareV2, self).__init__(*args, **kwargs)
|
||||||
|
self.xmlns = 'http://docs.openstack.org/identity/api/v2.0'
|
||||||
|
|
||||||
|
|
||||||
|
class XmlBodyMiddlewareV3(XmlBodyMiddleware):
|
||||||
|
"""De/serializes XML to/from JSON for v3 API."""
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(XmlBodyMiddlewareV3, self).__init__(*args, **kwargs)
|
||||||
|
self.xmlns = 'http://docs.openstack.org/identity/api/v3'
|
||||||
|
|
||||||
|
|
||||||
class NormalizingFilter(wsgi.Middleware):
|
class NormalizingFilter(wsgi.Middleware):
|
||||||
"""Middleware filter to handle URL normalization."""
|
"""Middleware filter to handle URL normalization."""
|
||||||
|
|
||||||
|
@ -268,6 +268,7 @@ class XmlVersionTestCase(tests.TestCase):
|
|||||||
|
|
||||||
DOC_INTRO = '<?xml version="1.0" encoding="UTF-8"?>'
|
DOC_INTRO = '<?xml version="1.0" encoding="UTF-8"?>'
|
||||||
XML_NAMESPACE_ATTR = 'xmlns="http://docs.openstack.org/identity/api/v2.0"'
|
XML_NAMESPACE_ATTR = 'xmlns="http://docs.openstack.org/identity/api/v2.0"'
|
||||||
|
XML_NAMESPACE_V3 = 'xmlns="http://docs.openstack.org/identity/api/v3"'
|
||||||
|
|
||||||
v2_VERSION_DATA = """
|
v2_VERSION_DATA = """
|
||||||
<version %(v2_namespace)s status="deprecated" updated="2014-04-17T00:00:00Z"
|
<version %(v2_namespace)s status="deprecated" updated="2014-04-17T00:00:00Z"
|
||||||
@ -312,7 +313,7 @@ vnd.openstack.identity-v3+xml"/>
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
v3_VERSION_RESPONSE = ((DOC_INTRO + v3_VERSION_DATA) %
|
v3_VERSION_RESPONSE = ((DOC_INTRO + v3_VERSION_DATA) %
|
||||||
dict(v3_namespace=XML_NAMESPACE_ATTR))
|
dict(v3_namespace=XML_NAMESPACE_V3))
|
||||||
|
|
||||||
VERSIONS_RESPONSE = ((DOC_INTRO + """
|
VERSIONS_RESPONSE = ((DOC_INTRO + """
|
||||||
<versions %(namespace)s>
|
<versions %(namespace)s>
|
||||||
|
Loading…
Reference in New Issue
Block a user