Version response compatible with Folsom
This change adds <link> elements to the <version id="v2.0"> element in the version response to be compatible with the response given by the Keystone server in the Folsom release. Fixes bug 1187101 Change-Id: Ida71e2dbe3cf432d429fb739e68a83d7e009ca40
This commit is contained in:
parent
dc7fdb031a
commit
b0d766343b
@ -300,6 +300,18 @@ class XmlSerializer(object):
|
||||
self._populate_sequence(element, value)
|
||||
elif isinstance(value, dict):
|
||||
self._populate_tree(element, value)
|
||||
|
||||
# NOTE(blk-u): For compatibility with Folsom, when serializing the
|
||||
# v2.0 version element also add the links to the base element.
|
||||
if (value.get('id') == 'v2.0' and
|
||||
value.get('status') == 'stable' and
|
||||
value.get('updated') == '2013-03-06T00:00:00Z'):
|
||||
|
||||
for item in value['links']:
|
||||
child = etree.Element('link')
|
||||
self.populate_element(child, item)
|
||||
element.append(child)
|
||||
|
||||
elif isinstance(value, basestring):
|
||||
element.text = unicode(value)
|
||||
|
||||
|
@ -250,3 +250,48 @@ class XmlSerializerTestCase(test.TestCase):
|
||||
</object>
|
||||
"""
|
||||
self.assertSerializeDeserialize(d, xml)
|
||||
|
||||
def test_v2_links_special_case(self):
|
||||
# There's special-case code (for backward compatibility) where if the
|
||||
# data is the v2 version data, the link elements are also added to the
|
||||
# main element.
|
||||
|
||||
d = {
|
||||
"object": {
|
||||
"id": "v2.0",
|
||||
"status": "stable",
|
||||
"updated": "2013-03-06T00:00:00Z",
|
||||
"links": [{"href": "http://localhost:5000/v2.0/",
|
||||
"rel": "self"},
|
||||
{"href": "http://docs.openstack.org/api/openstack-"
|
||||
"identity-service/2.0/content/",
|
||||
"type": "text/html", "rel": "describedby"},
|
||||
{"href": "http://docs.openstack.org/api/openstack-"
|
||||
"identity-service/2.0/"
|
||||
"identity-dev-guide-2.0.pdf",
|
||||
"type": "application/pdf", "rel": "describedby"}]
|
||||
}}
|
||||
|
||||
xml = """
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<object xmlns="http://docs.openstack.org/identity/api/v2.0"
|
||||
id="v2.0" status="stable" updated="2013-03-06T00:00:00Z">
|
||||
<links>
|
||||
<link rel="self" href="http://localhost:5000/v2.0/"/>
|
||||
<link rel="describedby"
|
||||
href="http://docs.openstack.org/api/openstack-\
|
||||
identity-service/2.0/content/" type="text/html"/>
|
||||
<link rel="describedby"
|
||||
href="http://docs.openstack.org/api/openstack-\
|
||||
identity-service/2.0/identity-dev-guide-2.0.pdf" type="application/pdf"/>
|
||||
</links>
|
||||
<link rel="self" href="http://localhost:5000/v2.0/"/>
|
||||
<link rel="describedby"
|
||||
href="http://docs.openstack.org/api/openstack-\
|
||||
identity-service/2.0/content/" type="text/html"/>
|
||||
<link rel="describedby"
|
||||
href="http://docs.openstack.org/api/openstack-\
|
||||
identity-service/2.0/identity-dev-guide-2.0.pdf" type="application/pdf"/>
|
||||
</object>
|
||||
"""
|
||||
self.assertEqualXML(serializer.to_xml(d), xml)
|
||||
|
@ -281,6 +281,11 @@ vnd.openstack.identity-v2.0+xml"/>
|
||||
<link href="http://docs.openstack.org/api/openstack-identity-service/\
|
||||
2.0/identity-dev-guide-2.0.pdf" type="application/pdf" rel="describedby"/>
|
||||
</links>
|
||||
<link href="http://localhost:%%(port)s/v2.0/" rel="self"/>
|
||||
<link href="http://docs.openstack.org/api/openstack-identity-service/\
|
||||
2.0/content/" type="text/html" rel="describedby"/>
|
||||
<link href="http://docs.openstack.org/api/openstack-identity-service/\
|
||||
2.0/identity-dev-guide-2.0.pdf" type="application/pdf" rel="describedby"/>
|
||||
</version>
|
||||
"""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user