environment: avoid buggy base_url truncate at BO service creation (#69002)
This commit is contained in:
parent
7b8a0deaf6
commit
b739d3cab7
|
@ -150,7 +150,7 @@ def create_base_url(hostname, service):
|
|||
ph = urllib.parse.urlparse(hostname)
|
||||
parts = ph.netloc.split('.')
|
||||
if '-' in parts[0]:
|
||||
netloc = '%s-%s.%s' % (service, parts[0].split('-')[1], '.'.join(parts[1:]))
|
||||
netloc = '%s-%s.%s' % (service, parts[0].split('-', maxsplit=1)[1], '.'.join(parts[1:]))
|
||||
else:
|
||||
netloc = '%s.%s' % (service, '.'.join(parts[1:]))
|
||||
return '%s://%s' % (ph.scheme, netloc)
|
||||
|
|
|
@ -12,6 +12,7 @@ from requests import Response, exceptions
|
|||
from hobo.agent.common.management.commands.hobo_deploy import Command, CommandError, replace_file
|
||||
from hobo.agent.hobo.management.commands.hobo_deploy import Command as HoboCommand
|
||||
from hobo.environment.models import Combo, Hobo, Variable, Wcs
|
||||
from hobo.environment.utils import create_base_url
|
||||
from hobo.multitenant.middleware import TenantNotFound
|
||||
|
||||
|
||||
|
@ -29,6 +30,28 @@ def test_replace_file(tmpdir):
|
|||
assert handler.read() == content
|
||||
|
||||
|
||||
def test_create_base_url():
|
||||
hostname = 'https://hobo-publik-famille.test.entrouvert.org'
|
||||
service = 'payment'
|
||||
base_url = create_base_url(hostname, service)
|
||||
assert base_url == 'https://payment-publik-famille.test.entrouvert.org'
|
||||
|
||||
hostname = 'https://hobo.my-city.test.entrouvert.org'
|
||||
service = 'portal'
|
||||
base_url = create_base_url(hostname, service)
|
||||
assert base_url == 'https://portal.my-city.test.entrouvert.org'
|
||||
|
||||
hostname = 'https://hobo-mycity.test.entrouvert.org'
|
||||
service = 'agendas'
|
||||
base_url = create_base_url(hostname, service)
|
||||
assert base_url == 'https://agendas-mycity.test.entrouvert.org'
|
||||
|
||||
hostname = 'https://hobo.mycity.test.entrouvert.org'
|
||||
service = 'idp'
|
||||
base_url = create_base_url(hostname, service)
|
||||
assert base_url == 'https://idp.mycity.test.entrouvert.org'
|
||||
|
||||
|
||||
def test_handle_from_scratch():
|
||||
"""API using JSON from file or from stdin"""
|
||||
command = Command()
|
||||
|
|
Loading…
Reference in New Issue