Support <scheme>://<netloc>/<prefix> endpoints
Currently openstack.session.parse_url[1] doesn't handle correctly endpoint with a non-empty relative path not containing the version. Typically it transforms the neutron endpoint: http://example.com/network into: http://example.com/v2.0 when it should transform it into: http://example.com/network/v2.0 This change corrects parse_url in order to support such case. [1] openstack.session Closes-Bug: #1569578 Change-Id: Id5d80552e8f0c972288af984944fe5fe2ae951bf
This commit is contained in:
@@ -35,7 +35,8 @@ def parse_url(filt, url):
|
||||
path = result.path
|
||||
vstr = VERSION_PATTERN.search(path)
|
||||
if not vstr:
|
||||
return result.scheme + "://" + result.netloc + "/" + filt.get_path()
|
||||
return (result.scheme + "://" + result.netloc + path.rstrip('/') +
|
||||
'/' + filt.get_path())
|
||||
start, end = vstr.span()
|
||||
prefix = path[:start]
|
||||
version = '/' + filt.get_path(path[start + 1:end])
|
||||
|
||||
@@ -27,6 +27,9 @@ class TestSession(testtools.TestCase):
|
||||
self.assertEqual(
|
||||
"http://127.0.0.1:9292/v1",
|
||||
session.parse_url(filt, "http://127.0.0.1:9292"))
|
||||
self.assertEqual(
|
||||
"http://127.0.0.1:9292/foo/v1",
|
||||
session.parse_url(filt, "http://127.0.0.1:9292/foo"))
|
||||
self.assertEqual(
|
||||
"http://127.0.0.1:9292/v2",
|
||||
session.parse_url(filt, "http://127.0.0.1:9292/v2.0"))
|
||||
|
||||
Reference in New Issue
Block a user