diff --git a/src/app.py b/src/app.py index f1abffd16..58ee7e017 100644 --- a/src/app.py +++ b/src/app.py @@ -1949,7 +1949,7 @@ def _convert_v1_manifest_to_v2(manifest): "ldap": "?", "sso": "?", "disk": "50M", - "ram": {"build": "50M", "runtime": "10M", "include_swap": False} + "ram": {"build": "50M", "runtime": "10M"} } maintainer = manifest.get("maintainer", {}).get("name") @@ -2301,7 +2301,8 @@ def _check_manifest_requirements(manifest: Dict, action: str): # Ram for build ram_build_requirement = manifest["integration"]["ram"]["build"] - ram_include_swap = manifest["integration"]["ram"]["include_swap"] + # Is "include_swap" really useful ? We should probably decide wether to always include it or not instead + ram_include_swap = manifest["integration"]["ram"].get("include_swap", False) ram, swap = ram_available() if ram_include_swap: diff --git a/src/tests/test_apps.py b/src/tests/test_apps.py index 2a808b5bd..6ff2c5271 100644 --- a/src/tests/test_apps.py +++ b/src/tests/test_apps.py @@ -45,6 +45,7 @@ def clean(): "break_yo_system", "legacy_app", "legacy_app__2", + "manifestv2_app", "full_domain_app", "my_webapp", ] @@ -115,7 +116,10 @@ def app_expected_files(domain, app): if app.startswith("legacy_app"): yield "/var/www/%s/index.html" % app yield "/etc/yunohost/apps/%s/settings.yml" % app - yield "/etc/yunohost/apps/%s/manifest.json" % app + if "manifestv2" in app: + yield "/etc/yunohost/apps/%s/manifest.toml" % app + else: + yield "/etc/yunohost/apps/%s/manifest.json" % app yield "/etc/yunohost/apps/%s/scripts/install" % app yield "/etc/yunohost/apps/%s/scripts/remove" % app @@ -157,6 +161,15 @@ def install_legacy_app(domain, path, public=True): ) +def install_manifestv2_app(domain, path, public=True): + + app_install( + os.path.join(get_test_apps_dir(), "manivestv2_app_ynh"), + args="domain={}&path={}&init_main_permission={}".format(domain, path, "visitors" if public else "all_users"), + force=True, + ) + + def install_full_domain_app(domain): app_install( @@ -195,6 +208,26 @@ def test_legacy_app_install_main_domain(): assert app_is_not_installed(main_domain, "legacy_app") +def test_manifestv2_app_install_main_domain(): + + main_domain = _get_maindomain() + + install_manifestv2_app(main_domain, "/manifestv2") + + app_map_ = app_map(raw=True) + assert main_domain in app_map_ + assert "/manifestv2" in app_map_[main_domain] + assert "id" in app_map_[main_domain]["/manifestv2"] + assert app_map_[main_domain]["/manifestv2"]["id"] == "manifestv2_app" + + assert app_is_installed(main_domain, "manifestv2_app") + assert app_is_exposed_on_http(main_domain, "/manifestv2", "Hextris") + + app_remove("manifestv2_app") + + assert app_is_not_installed(main_domain, "manifestv2_app") + + def test_app_from_catalog(): main_domain = _get_maindomain() diff --git a/src/utils/resources.py b/src/utils/resources.py index b7d3c1694..f64ad6134 100644 --- a/src/utils/resources.py +++ b/src/utils/resources.py @@ -45,6 +45,11 @@ class AppResourceManager: self.current = current self.wanted = wanted + if "resources" not in self.current: + self.current["resources"] = {} + if "resources" not in self.wanted: + self.wanted["resources"] = {} + def apply(self, rollback_if_failure, **context): todos = list(self.compute_todos()) @@ -233,7 +238,7 @@ class PermissionsResource(AppResource): existing_perms = user_permission_list(short=True, apps=[self.app])["permissions"] for perm in existing_perms: - if perm.split(".") not in self.permissions.keys(): + if perm.split(".")[0] not in self.permissions.keys(): permission_delete(perm, force=True, sync_perm=False) for perm, infos in self.permissions.items():