mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Fix permission_reset idempotency
This commit is contained in:
parent
96bc95656c
commit
9cecd71437
2 changed files with 15 additions and 0 deletions
|
@ -217,6 +217,10 @@ def user_permission_reset(operation_logger, permission, sync_perm=True):
|
||||||
if existing_permission is None:
|
if existing_permission is None:
|
||||||
raise YunohostError('permission_not_found', permission=permission)
|
raise YunohostError('permission_not_found', permission=permission)
|
||||||
|
|
||||||
|
if existing_permission["allowed"] == ["all_users"]:
|
||||||
|
logger.warning("The permission was not updated all addition/removal requests already match the current state.")
|
||||||
|
return
|
||||||
|
|
||||||
# Update permission with default (all_users)
|
# Update permission with default (all_users)
|
||||||
|
|
||||||
operation_logger.related_to.append(('app', permission.split(".")[0]))
|
operation_logger.related_to.append(('app', permission.split(".")[0]))
|
||||||
|
|
|
@ -306,6 +306,17 @@ def test_permission_reset():
|
||||||
assert res['blog.main']['allowed'] == ["all_users"]
|
assert res['blog.main']['allowed'] == ["all_users"]
|
||||||
assert set(res['blog.main']['corresponding_users']) == set(["alice", "bob"])
|
assert set(res['blog.main']['corresponding_users']) == set(["alice", "bob"])
|
||||||
|
|
||||||
|
|
||||||
|
def test_permission_reset_idempotency():
|
||||||
|
# Reset permission
|
||||||
|
user_permission_reset("blog.main")
|
||||||
|
user_permission_reset("blog.main")
|
||||||
|
|
||||||
|
res = user_permission_list(full=True)['permissions']
|
||||||
|
assert res['blog.main']['allowed'] == ["all_users"]
|
||||||
|
assert set(res['blog.main']['corresponding_users']) == set(["alice", "bob"])
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Error on update function
|
# Error on update function
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Reference in a new issue