Merge "Health Monitor url_path requires leading slash"

This commit is contained in:
Zuul
2018-04-26 04:49:37 +00:00
committed by Gerrit Code Review
2 changed files with 11 additions and 1 deletions

View File

@@ -55,7 +55,8 @@ def url_path(url_path):
if (
p_url.scheme or p_url.userinfo or p_url.host or
p_url.port or
p_url.path is None
p_url.path is None or
not p_url.path.startswith('/')
):
raise exceptions.InvalidURLPath(url_path=url_path)
except Exception:

View File

@@ -87,6 +87,15 @@ class TestHealthMonitor(object):
self.assertRaises(exc.InvalidInput, wsme_json.fromjson,
self._type, body)
def test_invalid_url_path_no_leading_slash(self):
body = {"delay": 1, "timeout": 1, "max_retries": 1,
"url_path": 'blah'}
if self._type is hm_type.HealthMonitorPOST:
body.update({"type": constants.PROTOCOL_HTTP,
"pool_id": uuidutils.generate_uuid()})
self.assertRaises(exc.InvalidInput, wsme_json.fromjson,
self._type, body)
def test_invalid_expected_codes(self):
body = {"delay": 1, "timeout": 1, "max_retries": 1,
"expected_codes": "lol"}