diff --git a/src/main/java/com/tencent/bk/sdk/iam/dto/ResponseData.java b/src/main/java/com/tencent/bk/sdk/iam/dto/ResponseData.java new file mode 100644 index 0000000..e96084c --- /dev/null +++ b/src/main/java/com/tencent/bk/sdk/iam/dto/ResponseData.java @@ -0,0 +1,11 @@ +package com.tencent.bk.sdk.iam.dto; + +import lombok.Data; + +import java.util.List; + +@Data +public class ResponseData { + Integer count; + List results; +} diff --git a/src/main/java/com/tencent/bk/sdk/iam/service/v2/V2ManagerService.java b/src/main/java/com/tencent/bk/sdk/iam/service/v2/V2ManagerService.java index c90ce8f..1c1669f 100644 --- a/src/main/java/com/tencent/bk/sdk/iam/service/v2/V2ManagerService.java +++ b/src/main/java/com/tencent/bk/sdk/iam/service/v2/V2ManagerService.java @@ -15,6 +15,7 @@ import com.tencent.bk.sdk.iam.dto.CallbackApplicationDTO; import com.tencent.bk.sdk.iam.dto.GradeManagerApplicationCreateDTO; import com.tencent.bk.sdk.iam.dto.GradeManagerApplicationUpdateDTO; +import com.tencent.bk.sdk.iam.dto.ResponseData; import com.tencent.bk.sdk.iam.dto.V2PageInfoDTO; import com.tencent.bk.sdk.iam.dto.action.GroupAction; import com.tencent.bk.sdk.iam.dto.application.ApplicationDTO; @@ -191,7 +192,7 @@ public GradeManagerApplicationResponse updateGradeManagerApplication(String grad /** * 用户组下模板列表 */ - public List listRoleGroupTemplates(Integer groupId, V2PageInfoDTO pageInfoDTO); + public ResponseData listRoleGroupTemplates(Integer groupId, V2PageInfoDTO pageInfoDTO); /** * 用户组成员续期(不需要审批版本) diff --git a/src/main/java/com/tencent/bk/sdk/iam/service/v2/impl/V2ManagerServiceImpl.java b/src/main/java/com/tencent/bk/sdk/iam/service/v2/impl/V2ManagerServiceImpl.java index 8fd1bf0..bb64819 100644 --- a/src/main/java/com/tencent/bk/sdk/iam/service/v2/impl/V2ManagerServiceImpl.java +++ b/src/main/java/com/tencent/bk/sdk/iam/service/v2/impl/V2ManagerServiceImpl.java @@ -19,6 +19,7 @@ import com.tencent.bk.sdk.iam.dto.GradeManagerApplicationCreateDTO; import com.tencent.bk.sdk.iam.dto.GradeManagerApplicationUpdateDTO; import com.tencent.bk.sdk.iam.dto.PageInfoDTO; +import com.tencent.bk.sdk.iam.dto.ResponseData; import com.tencent.bk.sdk.iam.dto.V2PageInfoDTO; import com.tencent.bk.sdk.iam.dto.action.GroupAction; import com.tencent.bk.sdk.iam.dto.application.ApplicationDTO; @@ -243,16 +244,16 @@ public ManagerGroupMemberVo getRoleGroupMemberV2(Integer groupId, V2PageInfoDTO } @Override - public List listRoleGroupTemplates(Integer groupId, V2PageInfoDTO pageInfoDTO) { + public ResponseData listRoleGroupTemplates(Integer groupId, V2PageInfoDTO pageInfoDTO) { AuthRequestContext.setRequestName("V2_MANAGER_ROLE_GROUP_TEMPLATES_LIST"); String url = v2BuildURLPage(String.format(V2IamUri.V2_MANAGER_ROLE_GROUP_TEMPLATES_LIST, iamConfiguration.getSystemId(), groupId), pageInfoDTO); try { String responseStr = apigwHttpClientService.doHttpGet(url); if (StringUtils.isNotBlank(responseStr)) { log.debug("list role group templates response|{}", responseStr); - ResponseDTO> responseInfo = JsonUtil.fromJson( + ResponseDTO> responseInfo = JsonUtil.fromJson( responseStr, - new TypeReference>>() { + new TypeReference>>() { }); if (responseInfo != null) { ResponseUtil.checkResponse(responseInfo); diff --git a/src/test/java/com/tencent/bk/sdk/iam/service/v2/impl/V2ManagerServiceTest.java b/src/test/java/com/tencent/bk/sdk/iam/service/v2/impl/V2ManagerServiceTest.java index 248dc63..9fe84be 100644 --- a/src/test/java/com/tencent/bk/sdk/iam/service/v2/impl/V2ManagerServiceTest.java +++ b/src/test/java/com/tencent/bk/sdk/iam/service/v2/impl/V2ManagerServiceTest.java @@ -13,9 +13,10 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.tencent.bk.sdk.iam.config.IamConfiguration; +import com.tencent.bk.sdk.iam.constants.ManagerScopesEnum; import com.tencent.bk.sdk.iam.dto.GradeManagerApplicationCreateDTO; import com.tencent.bk.sdk.iam.dto.GradeManagerApplicationUpdateDTO; -import com.tencent.bk.sdk.iam.dto.PageInfoDTO; +import com.tencent.bk.sdk.iam.dto.ResponseData; import com.tencent.bk.sdk.iam.dto.SubjectDTO; import com.tencent.bk.sdk.iam.dto.V2PageInfoDTO; import com.tencent.bk.sdk.iam.dto.V2QueryPolicyDTO; @@ -36,6 +37,7 @@ import com.tencent.bk.sdk.iam.dto.manager.ManagerResources; import com.tencent.bk.sdk.iam.dto.manager.ManagerRoleGroup; import com.tencent.bk.sdk.iam.dto.manager.ManagerScopes; +import com.tencent.bk.sdk.iam.dto.manager.RoleGroupMemberInfo; import com.tencent.bk.sdk.iam.dto.manager.dto.CreateManagerDTO; import com.tencent.bk.sdk.iam.dto.manager.dto.CreateSubsetManagerDTO; import com.tencent.bk.sdk.iam.dto.manager.dto.GroupMemberRenewApplicationDTO; @@ -52,6 +54,7 @@ import com.tencent.bk.sdk.iam.dto.response.GradeManagerApplicationResponse; import com.tencent.bk.sdk.iam.dto.response.GroupPermissionDetailResponseDTO; import com.tencent.bk.sdk.iam.dto.response.ManagerDetailResponse; +import com.tencent.bk.sdk.iam.dto.response.MemberGroupDetailsResponse; import com.tencent.bk.sdk.iam.dto.system.SystemFieldDTO; import com.tencent.bk.sdk.iam.service.IamActionService; import com.tencent.bk.sdk.iam.service.IamResourceService; @@ -66,23 +69,22 @@ import com.tencent.bk.sdk.iam.service.impl.SystemServiceImpl; import com.tencent.bk.sdk.iam.service.v2.V2ManagerService; import com.tencent.bk.sdk.iam.util.JsonUtil; -import java.util.Collections; -import java.util.Map; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.TimeUnit; @Disabled public class V2ManagerServiceTest { private IamConfiguration iamConfiguration = new IamConfiguration - ("", "", "", - "", ""); + ("", "", "", "", ""); private ApigwHttpClientServiceImpl apigwHttpClientService = new ApigwHttpClientServiceImpl(iamConfiguration); V2ManagerService v2ManagerService = new V2ManagerServiceImpl(apigwHttpClientService, iamConfiguration); ManagerService managerService = new ManagerServiceImpl(apigwHttpClientService, iamConfiguration); @@ -545,12 +547,12 @@ public void testBatchVerifyPermissions() { action.setId("pipeline_list"); ResourceDTO resource = ResourceDTO.builder() - .type("pipeline") - .id("p-42f8638d709a4fc9b6e9292f1c232456") - .system(iamConfiguration.getSystemId()) - .build(); + .type("pipeline") + .id("p-42f8638d709a4fc9b6e9292f1c232456") + .system(iamConfiguration.getSystemId()) + .build(); Map result = policyService.batchVerifyPermissions( - "mingshewhe", Collections.singletonList(action), Collections.singletonList(resource) + "mingshewhe", Collections.singletonList(action), Collections.singletonList(resource) ); System.out.println(result); } @@ -561,12 +563,12 @@ public void testV2BatchVerifyPermissions() { action.setId("pipeline_list"); ResourceDTO resource = ResourceDTO.builder() - .type("pipeline") - .id("p-42f8638d709a4fc9b6e9292f1c232456") - .system(iamConfiguration.getSystemId()) - .build(); + .type("pipeline") + .id("p-42f8638d709a4fc9b6e9292f1c232456") + .system(iamConfiguration.getSystemId()) + .build(); Map result = v2PolicyService.batchVerifyPermissions( - "mingshewhe", Collections.singletonList(action), Collections.singletonList(resource) + "mingshewhe", Collections.singletonList(action), Collections.singletonList(resource) ); System.out.println(result); } @@ -577,13 +579,35 @@ public void testV2BatchGetPolicyByActionList() { action.setId("pipeline_list"); ResourceDTO resource = ResourceDTO.builder() - .type("pipeline") - .id("p-42f8638d709a4fc9b6e9292f1c232456") - .system(iamConfiguration.getSystemId()) - .build(); + .type("pipeline") + .id("p-42f8638d709a4fc9b6e9292f1c232456") + .system(iamConfiguration.getSystemId()) + .build(); List actionPolilcyDTOList = v2PolicyService.batchGetPolicyByActionList( - "mingshewhe", Collections.singletonList(action), Collections.singletonList(resource) + "mingshewhe", Collections.singletonList(action), Collections.singletonList(resource) ); System.out.println(actionPolilcyDTOList); } + + @Test + public void testListRoleGroupTemplates() { + V2PageInfoDTO pageInfoDTO = new V2PageInfoDTO(); + pageInfoDTO.setPageSize(10); + pageInfoDTO.setPage(1); + ResponseData roleGroupMemberInfoResponseData = v2ManagerService.listRoleGroupTemplates( + 532267, pageInfoDTO + ); + System.out.println(roleGroupMemberInfoResponseData); + } + + @Test + public void testListMemberGroupsDetails() { + V2PageInfoDTO pageInfoDTO = new V2PageInfoDTO(); + pageInfoDTO.setPageSize(10); + pageInfoDTO.setPage(1); + List greysonfang = v2ManagerService.listMemberGroupsDetails( + ManagerScopesEnum.USER, "", "" + ); + System.out.println(greysonfang); + } }