Skip to content

Commit

Permalink
App install/remove now has sync_perm setting
Browse files Browse the repository at this point in the history
  • Loading branch information
selfhoster1312 committed May 10, 2024
1 parent 5963b66 commit 02a5878
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
7 changes: 5 additions & 2 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ def app_install(
args=None,
no_remove_on_failure=False,
force=False,
sync_perm=True,
):
"""
Install apps
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")


Expand Down
21 changes: 12 additions & 9 deletions src/tests/test_sso_and_portalapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,34 @@ def setup_module(module):

assert os.system("systemctl is-active yunohost-portal-api >/dev/null") == 0

userlist = user_list()["users"]
users_to_add = [ user for user in [
User("alice", maindomain, dummy_password, fullname="Alice White", admin=True),
User("bob", maindomain, dummy_password, fullname="Bob Marley"),
] 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)

# 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),
User("bob", maindomain, dummy_password, fullname="Bob Marley"),
] if user.name not in userlist ]
users_add(users_to_add)


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)
Expand Down

0 comments on commit 02a5878

Please sign in to comment.