Merge "Don't truncate osapi_volume_link prefixes"

This commit is contained in:
Jenkins 2015-04-25 05:18:03 +00:00 committed by Gerrit Code Review
commit 5eb9d1140c
2 changed files with 21 additions and 1 deletions

View File

@ -353,7 +353,9 @@ class ViewBuilder(object):
url_parts = list(urlparse.urlsplit(orig_url)) url_parts = list(urlparse.urlsplit(orig_url))
prefix_parts = list(urlparse.urlsplit(prefix)) prefix_parts = list(urlparse.urlsplit(prefix))
url_parts[0:2] = prefix_parts[0:2] url_parts[0:2] = prefix_parts[0:2]
return urlparse.urlunsplit(url_parts) url_parts[2] = prefix_parts[2] + url_parts[2]
return urlparse.urlunsplit(url_parts).rstrip('/')
class MetadataDeserializer(wsgi.MetadataXMLDeserializer): class MetadataDeserializer(wsgi.MetadataXMLDeserializer):

View File

@ -547,3 +547,21 @@ class TestCollectionLinks(test.TestCase):
self._validate_next_link(href_link_mock, item_count, self._validate_next_link(href_link_mock, item_count,
osapi_max_limit, osapi_max_limit,
limit, should_link_exist) limit, should_link_exist)
class LinkPrefixTest(test.TestCase):
def test_update_link_prefix(self):
vb = common.ViewBuilder()
result = vb._update_link_prefix("http://192.168.0.243:24/",
"http://127.0.0.1/volume")
self.assertEqual("http://127.0.0.1/volume", result)
result = vb._update_link_prefix("http://foo.x.com/v1",
"http://new.prefix.com")
self.assertEqual("http://new.prefix.com/v1", result)
result = vb._update_link_prefix(
"http://foo.x.com/v1",
"http://new.prefix.com:20455/new_extra_prefix")
self.assertEqual("http://new.prefix.com:20455/new_extra_prefix/v1",
result)