cook: raise an error if a port is provided in action urls (#38964)
gitea/hobo/pipeline/head This commit looks good
Details
gitea/hobo/pipeline/head This commit looks good
Details
This commit is contained in:
parent
592ee8a73c
commit
3ddb15758d
|
@ -7,6 +7,12 @@ from hobo.environment import models
|
|||
|
||||
|
||||
def validate_service_url(url):
|
||||
if urllib.parse.urlparse(url).port is not None:
|
||||
raise ValidationError(
|
||||
_('Error: providing port is not supported on service url %(url)s'),
|
||||
code='invalid-url',
|
||||
params={'url': url},
|
||||
)
|
||||
if not models.is_resolvable(url):
|
||||
raise ValidationError(
|
||||
_('Error: %(netloc)s is not resolvable in URL %(url)s'),
|
||||
|
|
|
@ -74,6 +74,15 @@ def test_check_action_unknown_action(command, monkeypatch):
|
|||
assert 'Unknown action not-a-server-action' in str(e_info.value)
|
||||
|
||||
|
||||
def test_check_action_providing_port(command):
|
||||
command.server_action = 'mock a server_action handler (ex: hobo-create)'
|
||||
action, action_args = 'server-action', {'url': 'https://test.org:443/'}
|
||||
|
||||
with pytest.raises(CommandError) as e_info:
|
||||
command.check_action(action, action_args)
|
||||
assert 'providing port is not supported on service url https://test.org:443/' in str(e_info.value)
|
||||
|
||||
|
||||
def test_check_action_unresolvable(command, monkeypatch):
|
||||
"""raise CommandError"""
|
||||
command.server_action = 'mock a server_action handler (ex: hobo-create)'
|
||||
|
|
Loading…
Reference in New Issue