App install/remove now has sync_perm setting

This commit is contained in:
selfhoster1312 2024-05-10 20:22:32 +02:00
parent 288d6b6b47
commit aeda36f610
2 changed files with 20 additions and 14 deletions

View file

@ -1025,6 +1025,7 @@ def app_install(
args=None,
no_remove_on_failure=False,
force=False,
sync_perm=True,
):
"""
Install apps
@ -1201,6 +1202,7 @@ def app_install(
label=manifest["name"],
show_tile=False,
protected=False,
sync_perm=sync_perm
)
# Prepare env. var. to pass to script
@ -1377,7 +1379,7 @@ def app_install(
@is_unit_operation()
def app_remove(operation_logger, app, purge=False, force_workdir=None):
def app_remove(operation_logger, app, purge=False, force_workdir=None, sync_perm=True):
"""
Remove app
@ -1476,7 +1478,8 @@ def app_remove(operation_logger, app, purge=False, force_workdir=None):
else:
logger.warning(m18n.n("app_not_properly_removed", app=app))
permission_sync_to_user()
if sync_perm:
permission_sync_to_user()
_assert_system_is_sane_for_app(manifest, "post")

View file

@ -43,6 +43,18 @@ def setup_module(module):
assert os.system("systemctl is-active yunohost-portal-api >/dev/null") == 0
domainlist = domain_list()["domains"]
domains = [ domain for domain in [ subdomain, secondarydomain ] if domain not in domainlist ]
domains_add(domains)
# Install app first, permissions will be synced after users_add
app_install(
os.path.join(get_test_apps_dir(), "hellopy_ynh"),
args=f"domain={maindomain}&init_main_permission=visitors",
force=True,
sync_perm=False,
)
userlist = user_list()["users"]
users_to_add = [ user for user in [
User("alice", maindomain, dummy_password, fullname="Alice White", admin=True),
@ -50,24 +62,15 @@ def setup_module(module):
] if user.name not in userlist ]
users_add(users_to_add)
domainlist = domain_list()["domains"]
domains = [ domain for domain in [ subdomain, secondarydomain ] if domain not in domainlist ]
domains_add(domains)
app_install(
os.path.join(get_test_apps_dir(), "hellopy_ynh"),
args=f"domain={maindomain}&init_main_permission=visitors",
force=True,
)
def teardown_module(module):
# Remove app first, permissions will be synced after users_remove
app_remove("hellopy", sync_perm=False)
userlist = user_list()["users"]
users = [ user for user in [ "alice", "bob" ] if user in userlist ]
users_remove(users)
app_remove("hellopy")
domainlist = domain_list()["domains"]
domains = [ domain for domain in [ subdomain, secondarydomain ] if domain in domainlist ]
domains_remove(domains)