mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #953 from YunoHost/fix-app-map-with-app-on-root
[fix] Make sure to return '/' and not empty string for stuff on domain root
This commit is contained in:
commit
cb223be4d1
2 changed files with 19 additions and 3 deletions
|
@ -261,6 +261,8 @@ def app_map(app=None, raw=False, user=None):
|
|||
perm_domain, perm_path = perm_url.split("/", 1)
|
||||
perm_path = "/" + perm_path.rstrip("/")
|
||||
|
||||
perm_path = perm_path if perm_path.strip() != "" else "/"
|
||||
|
||||
return perm_domain, perm_path
|
||||
|
||||
this_app_perms = {p: i for p, i in permissions.items() if p.startswith(app_id + ".") and i["url"]}
|
||||
|
@ -296,7 +298,6 @@ def app_map(app=None, raw=False, user=None):
|
|||
continue
|
||||
|
||||
perm_domain, perm_path = _sanitized_absolute_url(perm_info["url"])
|
||||
|
||||
if perm_name.endswith(".main"):
|
||||
perm_label = label
|
||||
else:
|
||||
|
@ -1127,11 +1128,12 @@ def app_makedefault(operation_logger, app, domain=None):
|
|||
elif domain not in domain_list()['domains']:
|
||||
raise YunohostError('domain_unknown')
|
||||
|
||||
operation_logger.start()
|
||||
if '/' in app_map(raw=True)[domain]:
|
||||
raise YunohostError('app_make_default_location_already_used', app=app, domain=app_domain,
|
||||
other_app=app_map(raw=True)[domain]["/"]["id"])
|
||||
|
||||
operation_logger.start()
|
||||
|
||||
# TODO / FIXME : current trick is to add this to conf.json.persisten
|
||||
# This is really not robust and should be improved
|
||||
# e.g. have a flag in /etc/yunohost/apps/$app/ to say that this is the
|
||||
|
@ -1289,6 +1291,8 @@ def app_ssowatconf():
|
|||
perm_domain, perm_path = perm_url.split("/", 1)
|
||||
perm_path = "/" + perm_path.rstrip("/")
|
||||
|
||||
perm_path = perm_path if perm_path.strip() != "" else "/"
|
||||
|
||||
return perm_domain + perm_path
|
||||
|
||||
# Skipped
|
||||
|
|
|
@ -9,7 +9,7 @@ from conftest import message, raiseYunohostError
|
|||
from moulinette import m18n
|
||||
from moulinette.utils.filesystem import mkdir
|
||||
|
||||
from yunohost.app import app_install, app_remove, app_ssowatconf, _is_installed, app_upgrade
|
||||
from yunohost.app import app_install, app_remove, app_ssowatconf, _is_installed, app_upgrade, app_map
|
||||
from yunohost.domain import _get_maindomain, domain_add, domain_remove, domain_list
|
||||
from yunohost.utils.error import YunohostError
|
||||
from yunohost.tests.test_permission import check_LDAP_db_integrity, check_permission_for_apps
|
||||
|
@ -142,6 +142,12 @@ def test_legacy_app_install_main_domain():
|
|||
|
||||
install_legacy_app(main_domain, "/legacy")
|
||||
|
||||
app_map_ = app_map(raw=True)
|
||||
assert main_domain in app_map_
|
||||
assert '/legacy' in app_map_[main_domain]
|
||||
assert 'id' in app_map_[main_domain]['/legacy']
|
||||
assert app_map_[main_domain]['/legacy']['id'] == 'legacy_app'
|
||||
|
||||
assert app_is_installed(main_domain, "legacy_app")
|
||||
assert app_is_exposed_on_http(main_domain, "/legacy", "This is a dummy app")
|
||||
|
||||
|
@ -166,6 +172,12 @@ def test_legacy_app_install_secondary_domain_on_root(secondary_domain):
|
|||
|
||||
install_legacy_app(secondary_domain, "/")
|
||||
|
||||
app_map_ = app_map(raw=True)
|
||||
assert secondary_domain in app_map_
|
||||
assert '/' in app_map_[secondary_domain]
|
||||
assert 'id' in app_map_[secondary_domain]['/']
|
||||
assert app_map_[secondary_domain]['/']['id'] == 'legacy_app'
|
||||
|
||||
assert app_is_installed(secondary_domain, "legacy_app")
|
||||
assert app_is_exposed_on_http(secondary_domain, "/", "This is a dummy app")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue