manifestv2: misc fixes + add test for manifestv2 install

This commit is contained in:
Alexandre Aubin 2022-01-28 22:12:01 +01:00
parent d9873e085d
commit 9cb97640b9
3 changed files with 43 additions and 4 deletions

View file

@ -1949,7 +1949,7 @@ def _convert_v1_manifest_to_v2(manifest):
"ldap": "?", "ldap": "?",
"sso": "?", "sso": "?",
"disk": "50M", "disk": "50M",
"ram": {"build": "50M", "runtime": "10M", "include_swap": False} "ram": {"build": "50M", "runtime": "10M"}
} }
maintainer = manifest.get("maintainer", {}).get("name") maintainer = manifest.get("maintainer", {}).get("name")
@ -2301,7 +2301,8 @@ def _check_manifest_requirements(manifest: Dict, action: str):
# Ram for build # Ram for build
ram_build_requirement = manifest["integration"]["ram"]["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() ram, swap = ram_available()
if ram_include_swap: if ram_include_swap:

View file

@ -45,6 +45,7 @@ def clean():
"break_yo_system", "break_yo_system",
"legacy_app", "legacy_app",
"legacy_app__2", "legacy_app__2",
"manifestv2_app",
"full_domain_app", "full_domain_app",
"my_webapp", "my_webapp",
] ]
@ -115,7 +116,10 @@ def app_expected_files(domain, app):
if app.startswith("legacy_app"): if app.startswith("legacy_app"):
yield "/var/www/%s/index.html" % app yield "/var/www/%s/index.html" % app
yield "/etc/yunohost/apps/%s/settings.yml" % 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/install" % app
yield "/etc/yunohost/apps/%s/scripts/remove" % 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): def install_full_domain_app(domain):
app_install( app_install(
@ -195,6 +208,26 @@ def test_legacy_app_install_main_domain():
assert app_is_not_installed(main_domain, "legacy_app") 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(): def test_app_from_catalog():
main_domain = _get_maindomain() main_domain = _get_maindomain()

View file

@ -45,6 +45,11 @@ class AppResourceManager:
self.current = current self.current = current
self.wanted = wanted 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): def apply(self, rollback_if_failure, **context):
todos = list(self.compute_todos()) todos = list(self.compute_todos())
@ -233,7 +238,7 @@ class PermissionsResource(AppResource):
existing_perms = user_permission_list(short=True, apps=[self.app])["permissions"] existing_perms = user_permission_list(short=True, apps=[self.app])["permissions"]
for perm in existing_perms: 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) permission_delete(perm, force=True, sync_perm=False)
for perm, infos in self.permissions.items(): for perm, infos in self.permissions.items():