Skip to content

Commit

Permalink
feat:新增用户管理相关接口 #100
Browse files Browse the repository at this point in the history
  • Loading branch information
fcfang123 committed Jul 5, 2024
1 parent b76485d commit db41a7b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 25 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ext {
set('lombokVersion', '1.18.10')
set("junitVersion", "5.4.2")

String iamVersion = (System.getProperty("iamVersion") ?: "1.0.53")
String iamVersion = (System.getProperty("iamVersion") ?: "1.0.54")
if (System.getProperty("snapshot") == "true") {
set('iamVersion', iamVersion + "-SNAPSHOT")
} else {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/tencent/bk/sdk/iam/dto/ResponseData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.tencent.bk.sdk.iam.dto;

import lombok.Data;

import java.util.List;

@Data
public class ResponseData<T> {
Integer count;
List<T> results;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -191,7 +192,7 @@ public GradeManagerApplicationResponse updateGradeManagerApplication(String grad
/**
* 用户组下模板列表
*/
public List<RoleGroupMemberInfo> listRoleGroupTemplates(Integer groupId, V2PageInfoDTO pageInfoDTO);
public ResponseData<RoleGroupMemberInfo> listRoleGroupTemplates(Integer groupId, V2PageInfoDTO pageInfoDTO);

/**
* 用户组成员续期(不需要审批版本)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -243,16 +244,16 @@ public ManagerGroupMemberVo getRoleGroupMemberV2(Integer groupId, V2PageInfoDTO
}

@Override
public List<RoleGroupMemberInfo> listRoleGroupTemplates(Integer groupId, V2PageInfoDTO pageInfoDTO) {
public ResponseData<RoleGroupMemberInfo> 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<List<RoleGroupMemberInfo>> responseInfo = JsonUtil.fromJson(
ResponseDTO<ResponseData<RoleGroupMemberInfo>> responseInfo = JsonUtil.fromJson(
responseStr,
new TypeReference<ResponseDTO<List<RoleGroupMemberInfo>>>() {
new TypeReference<ResponseDTO<ResponseData<RoleGroupMemberInfo>>>() {
});
if (responseInfo != null) {
ResponseUtil.checkResponse(responseInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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<String, Boolean> result = policyService.batchVerifyPermissions(
"mingshewhe", Collections.singletonList(action), Collections.singletonList(resource)
"mingshewhe", Collections.singletonList(action), Collections.singletonList(resource)
);
System.out.println(result);
}
Expand All @@ -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<String, Boolean> result = v2PolicyService.batchVerifyPermissions(
"mingshewhe", Collections.singletonList(action), Collections.singletonList(resource)
"mingshewhe", Collections.singletonList(action), Collections.singletonList(resource)
);
System.out.println(result);
}
Expand All @@ -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<ActionPolicyDTO> 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<RoleGroupMemberInfo> roleGroupMemberInfoResponseData = v2ManagerService.listRoleGroupTemplates(
532267, pageInfoDTO
);
System.out.println(roleGroupMemberInfoResponseData);
}

@Test
public void testListMemberGroupsDetails() {
V2PageInfoDTO pageInfoDTO = new V2PageInfoDTO();
pageInfoDTO.setPageSize(10);
pageInfoDTO.setPage(1);
List<MemberGroupDetailsResponse> greysonfang = v2ManagerService.listMemberGroupsDetails(
ManagerScopesEnum.USER, "", ""
);
System.out.println(greysonfang);
}
}

0 comments on commit db41a7b

Please sign in to comment.