From d00d692519e08c67f64f1f49f4b8aa8c54daabb6 Mon Sep 17 00:00:00 2001 From: Youngjin Jo Date: Mon, 30 Sep 2024 17:46:07 +0900 Subject: [PATCH] fix: modify code such that deleted original users when add workspace to workspace group Signed-off-by: Youngjin Jo --- src/spaceone/identity/service/workspace_service.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/spaceone/identity/service/workspace_service.py b/src/spaceone/identity/service/workspace_service.py index 62d02a21..a65c23cc 100644 --- a/src/spaceone/identity/service/workspace_service.py +++ b/src/spaceone/identity/service/workspace_service.py @@ -459,7 +459,10 @@ def _add_workspace_to_group( else: is_updatable = False else: - self._delete_role_bindings(workspace_id, domain_id) + workspace_group_dict = workspace_group_vo.to_dict() + users = workspace_group_dict.get("users", []) + user_ids = [user.get("user_id") for user in users] + self._delete_role_bindings(workspace_id, domain_id, user_ids=user_ids) self._create_role_bindings( workspace_group_vo.users, workspace_id, @@ -505,12 +508,17 @@ def _remove_workspace_from_group_with_workspace_vo( ) def _delete_role_bindings( - self, workspace_id: str, domain_id: str, existing_workspace_group_id: str = None + self, + workspace_id: str, + domain_id: str, + existing_workspace_group_id: str = None, + user_ids: List[str] = None, ): rb_vos = self.rb_mgr.filter_role_bindings( workspace_id=workspace_id, domain_id=domain_id, workspace_group_id=existing_workspace_group_id, + user_id=user_ids, ) for rb_vo in rb_vos: self.rb_mgr.delete_role_binding_by_vo(rb_vo)