Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify code such that a user has an admin role type in case #382

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ test/_trial_temp
skaffold.yaml
test/yaml
test/workspace_group
test/workspace_group_user
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def check_user_role_type(

if user_role_type == "WORKSPACE_MEMBER":
_LOGGER.error(
f"User ID {user_id} does not have permission to workspace group."
f"[check_user_role_type] User ID {user_id} is WORKSPACE_MEMBER."
)
raise ERROR_PERMISSION_DENIED()

Expand Down
21 changes: 13 additions & 8 deletions src/spaceone/identity/service/workspace_group_user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ def add(
self.workspace_group_svc.check_new_users_exist_in_domain(new_users, domain_id)

workspace_group_old_users_info = workspace_group_vo.users or []
if workspace_group_old_users_info:
self.workspace_group_user_mgr.check_user_role_type(
workspace_group_old_users_info, user_id
)

user_vo = self.user_mgr.get_user(user_id, domain_id)
if user_vo.role_type == "USER":
if workspace_group_old_users_info:
self.workspace_group_user_mgr.check_user_role_type(
workspace_group_old_users_info, user_id
)

role_map = self.workspace_group_svc.get_role_map(new_users_info_list, domain_id)

Expand Down Expand Up @@ -185,10 +188,12 @@ def remove(
ERROR_NOT_FOUND(key="workspace_group_id", value=params.workspace_group_id)
workspace_group_dict = workspace_group_vo.to_mongo().to_dict()

workspace_group_users = workspace_group_vo.users
self.workspace_group_user_mgr.check_user_role_type(
workspace_group_users, user_id
)
user_vo = self.user_mgr.get_user(user_id, domain_id)
if user_vo.role_type == "USER":
workspace_group_users = workspace_group_vo.users
self.workspace_group_user_mgr.check_user_role_type(
workspace_group_users, user_id
)

old_users = workspace_group_dict["users"]
updated_users = self.workspace_group_svc.remove_users_from_workspace_group(
Expand Down
Loading