Merge "Use urlunparse to reconstruct base_url"
diff --git a/tempest/lib/auth.py b/tempest/lib/auth.py
index e269fd1..2d20a0b 100644
--- a/tempest/lib/auth.py
+++ b/tempest/lib/auth.py
@@ -325,13 +325,24 @@
parts = urlparse.urlparse(_base_url)
if filters.get('api_version', None) is not None:
+ version_path = '/%s' % filters['api_version']
path = re.sub(r'(^|/)+v\d+(?:\.\d+)?',
- '/' + filters['api_version'],
+ version_path,
parts.path,
count=1)
- _base_url = _base_url.replace(parts.path, path)
+ _base_url = urlparse.urlunparse((parts.scheme,
+ parts.netloc,
+ path or version_path,
+ parts.params,
+ parts.query,
+ parts.fragment))
if filters.get('skip_path', None) is not None and parts.path != '':
- _base_url = _base_url.replace(parts.path, "/")
+ _base_url = urlparse.urlunparse((parts.scheme,
+ parts.netloc,
+ '/',
+ parts.params,
+ parts.query,
+ parts.fragment))
return _base_url
@@ -447,13 +458,24 @@
parts = urlparse.urlparse(_base_url)
if filters.get('api_version', None) is not None:
+ version_path = '/%s' % filters['api_version']
path = re.sub(r'(^|/)+v\d+(?:\.\d+)?',
- '/' + filters['api_version'],
+ version_path,
parts.path,
count=1)
- _base_url = _base_url.replace(parts.path, path)
+ _base_url = urlparse.urlunparse((parts.scheme,
+ parts.netloc,
+ path or version_path,
+ parts.params,
+ parts.query,
+ parts.fragment))
if filters.get('skip_path', None) is not None:
- _base_url = _base_url.replace(parts.path, "/")
+ _base_url = urlparse.urlunparse((parts.scheme,
+ parts.netloc,
+ '/',
+ parts.params,
+ parts.query,
+ parts.fragment))
return _base_url