Commit aa090b76 authored by Boxiang Sun's avatar Boxiang Sun Committed by Vincent Pelletier

caucase.test: CAUCASE_NETLOC should not contain literal IP addresses

parent 4e2c2fe9
......@@ -388,6 +388,14 @@ class CaucaseTest(TestCase):
)
self._caucase_url = 'http://' + netloc
parsed_url = urllib_parse.urlparse(self._caucase_url)
try:
ipaddress.ip_address(parsed_url.hostname)
except ValueError:
pass # parsed_url.hostname is a hostname as expected
else: # pragma: no cover
raise AssertionError('CAUCASE_NETLOC should not contains literal IP')
self.assertFalse(
canConnect((parsed_url.hostname, parsed_url.port)),
'Something else is already listening on %r, define CAUCASE_NETLOC '
......@@ -3795,10 +3803,21 @@ class CaucaseShellTest(TestCase):
"""
Run caucase.sh's embedded testsuite.
"""
self._run('--test', os.getenv(
netloc = os.getenv(
'CAUCASE_NETLOC',
'localhost:8000',
))
)
caucase_url = 'http://' + netloc
parsed_url = urllib_parse.urlparse(caucase_url)
try:
ipaddress.ip_address(parsed_url.hostname)
except ValueError:
pass # parsed_url.hostname is a hostname as expected
else: # pragma: no cover
raise AssertionError('CAUCASE_NETLOC should not contains literal IP')
self._run('--test',netloc)
if __name__ == '__main__': # pragma: no cover
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment