Health Monitor url_path requires leading slash

Change-Id: I9b5b0eb6560cf08420b37ae0eacb5e1f86f75f54
Story: 2001891
Task: 14375
This commit is contained in:
Adam Harwell 2018-04-20 16:53:25 -07:00
parent 555c057e88
commit 791f52309c
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"}