environment: display netloc on network checks service (#50451)
This commit is contained in:
parent
6beaab79fe
commit
7cb75b9770
|
@ -1,4 +1,5 @@
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from hobo.environment.models import ServiceBase
|
||||
|
@ -8,13 +9,13 @@ def validate_service_url(url):
|
|||
service = ServiceBase(title='dummy', base_url=url)
|
||||
if not service.is_resolvable():
|
||||
raise ValidationError(
|
||||
_('Error: %(url)s is not resolvable'),
|
||||
_('Error: %(netloc)s is not resolvable in URL %(url)s'),
|
||||
code='not-resolvable',
|
||||
params={'url': url}
|
||||
params={'netloc': urlparse.urlsplit(url).netloc, 'url': url}
|
||||
)
|
||||
if not service.has_valid_certificate():
|
||||
raise ValidationError(
|
||||
_('Error: %(url)s has no valid certificate'),
|
||||
_('Error: no valid certificate for %(url)s'),
|
||||
code='invalid-certificate',
|
||||
params={'url': url}
|
||||
)
|
||||
|
|
|
@ -48,7 +48,7 @@ def test_check_action_unresolvable(monkeypatch):
|
|||
monkeypatch.setattr(ServiceBase, 'has_valid_certificate', lambda x: True)
|
||||
with pytest.raises(CommandError) as e_info:
|
||||
command.check_action(action, action_args)
|
||||
assert 'is not resolvable' in str(e_info.value)
|
||||
assert 'test.org is not resolvable in URL https://test.org/' in str(e_info.value)
|
||||
|
||||
def test_check_action_invalid_certificat(monkeypatch):
|
||||
"""raise CommandError"""
|
||||
|
@ -60,7 +60,7 @@ def test_check_action_invalid_certificat(monkeypatch):
|
|||
monkeypatch.setattr(ServiceBase, 'has_valid_certificate', lambda x: False)
|
||||
with pytest.raises(CommandError) as e_info:
|
||||
command.check_action(action, action_args)
|
||||
assert 'has no valid certificate' in str(e_info.value)
|
||||
assert 'no valid certificate for https://test.org/' in str(e_info.value)
|
||||
|
||||
def test_handle():
|
||||
kwargs = {'verbosity': 0,
|
||||
|
|
Loading…
Reference in New Issue