config: default core.dcos_url scheme to https (#870)
This commit is contained in:
@@ -66,12 +66,15 @@ def test_get_missing_property(env):
|
||||
_get_missing_value('missing.property', env)
|
||||
|
||||
|
||||
def test_invalid_dcos_url(env):
|
||||
stderr = b'Please check url \'abc.com\'. Missing http(s)://\n'
|
||||
assert_command(['dcos', 'config', 'set', 'core.dcos_url', 'abc.com'],
|
||||
stderr=stderr,
|
||||
returncode=1,
|
||||
def test_dcos_url_without_scheme(env):
|
||||
old = b'http://dcos.snakeoil.mesosphere.com'
|
||||
new = b"abc.com"
|
||||
out = b"[core.dcos_url]: changed from '%s' to 'https://%s'\n" % (old, new)
|
||||
assert_command(['dcos', 'config', 'set', 'core.dcos_url', new],
|
||||
returncode=0,
|
||||
stderr=out,
|
||||
env=env)
|
||||
config_set('core.dcos_url', old, env)
|
||||
|
||||
|
||||
def test_get_top_property(env):
|
||||
|
||||
@@ -283,8 +283,8 @@ def _parse_url(value):
|
||||
if value_regex is None:
|
||||
scheme_match = re.match(scheme_pattern, value, re.IGNORECASE)
|
||||
if scheme_match is None:
|
||||
msg = 'Please check url {!r}. Missing http(s)://'.format(value)
|
||||
raise DCOSException(msg)
|
||||
logger.debug("Defaulting URL to https scheme")
|
||||
return "https://" + value
|
||||
else:
|
||||
raise DCOSException(
|
||||
'Unable to parse {!r} as a url'.format(value))
|
||||
|
||||
@@ -60,16 +60,6 @@ def bad_array(request):
|
||||
][request.param]
|
||||
|
||||
|
||||
@pytest.fixture(params=[
|
||||
'www.test.com',
|
||||
'http:/hi.com',
|
||||
'https//www.hi.com',
|
||||
'http://bad.port:here'
|
||||
])
|
||||
def bad_url(request):
|
||||
return request.param
|
||||
|
||||
|
||||
@pytest.fixture(params=[
|
||||
('string', 'this is a string', 'this is a string'),
|
||||
('string', 'null', None),
|
||||
@@ -214,11 +204,6 @@ def test_parse_url():
|
||||
assert jsonitem._parse_url('http://test.com:12') == 'http://test.com:12'
|
||||
|
||||
|
||||
def test_parse_invalid_url(bad_url):
|
||||
with pytest.raises(DCOSException):
|
||||
jsonitem._parse_url(bad_url)
|
||||
|
||||
|
||||
def test_find_parser(schema, jsonitem_tuple):
|
||||
key, string_value, value = jsonitem_tuple
|
||||
assert jsonitem.find_parser(key, schema)(string_value) == value
|
||||
|
||||
Reference in New Issue
Block a user