refactor(接口测试): 优化接口删除权限显示

This commit is contained in:
wxg0103 2024-03-11 14:03:19 +08:00 committed by Craftsman
parent 152d744694
commit 43fc88fd9b
16 changed files with 34 additions and 23 deletions

View File

@ -253,7 +253,6 @@ public class PermissionConstants {
public static final String PROJECT_API_DEFINITION_ADD = "PROJECT_API_DEFINITION:READ+ADD"; public static final String PROJECT_API_DEFINITION_ADD = "PROJECT_API_DEFINITION:READ+ADD";
public static final String PROJECT_API_DEFINITION_UPDATE = "PROJECT_API_DEFINITION:READ+UPDATE"; public static final String PROJECT_API_DEFINITION_UPDATE = "PROJECT_API_DEFINITION:READ+UPDATE";
public static final String PROJECT_API_DEFINITION_DELETE = "PROJECT_API_DEFINITION:READ+DELETE"; public static final String PROJECT_API_DEFINITION_DELETE = "PROJECT_API_DEFINITION:READ+DELETE";
public static final String PROJECT_API_DEFINITION_RECOVER = "PROJECT_API_DEFINITION:READ+RECOVER";
public static final String PROJECT_API_DEFINITION_IMPORT = "PROJECT_API_DEFINITION:READ+IMPORT"; public static final String PROJECT_API_DEFINITION_IMPORT = "PROJECT_API_DEFINITION:READ+IMPORT";
public static final String PROJECT_API_DEFINITION_EXPORT = "PROJECT_API_DEFINITION:READ+EXPORT"; public static final String PROJECT_API_DEFINITION_EXPORT = "PROJECT_API_DEFINITION:READ+EXPORT";
public static final String PROJECT_API_DEFINITION_EXECUTE = "PROJECT_API_DEFINITION:READ+EXECUTE"; public static final String PROJECT_API_DEFINITION_EXECUTE = "PROJECT_API_DEFINITION:READ+EXECUTE";
@ -261,7 +260,6 @@ public class PermissionConstants {
public static final String PROJECT_API_DEFINITION_CASE_ADD = "PROJECT_API_DEFINITION_CASE:READ+ADD"; public static final String PROJECT_API_DEFINITION_CASE_ADD = "PROJECT_API_DEFINITION_CASE:READ+ADD";
public static final String PROJECT_API_DEFINITION_CASE_UPDATE = "PROJECT_API_DEFINITION_CASE:READ+UPDATE"; public static final String PROJECT_API_DEFINITION_CASE_UPDATE = "PROJECT_API_DEFINITION_CASE:READ+UPDATE";
public static final String PROJECT_API_DEFINITION_CASE_DELETE = "PROJECT_API_DEFINITION_CASE:READ+DELETE"; public static final String PROJECT_API_DEFINITION_CASE_DELETE = "PROJECT_API_DEFINITION_CASE:READ+DELETE";
public static final String PROJECT_API_DEFINITION_CASE_RECOVER = "PROJECT_API_DEFINITION_CASE:READ+RECOVER";
public static final String PROJECT_API_DEFINITION_CASE_EXECUTE = "PROJECT_API_DEFINITION_CASE:READ+EXECUTE"; public static final String PROJECT_API_DEFINITION_CASE_EXECUTE = "PROJECT_API_DEFINITION_CASE:READ+EXECUTE";
public static final String PROJECT_API_DEFINITION_MOCK_READ = "PROJECT_API_DEFINITION_MOCK:READ"; public static final String PROJECT_API_DEFINITION_MOCK_READ = "PROJECT_API_DEFINITION_MOCK:READ";
@ -277,7 +275,6 @@ public class PermissionConstants {
public static final String PROJECT_API_SCENARIO_ADD = "PROJECT_API_SCENARIO:READ+ADD"; public static final String PROJECT_API_SCENARIO_ADD = "PROJECT_API_SCENARIO:READ+ADD";
public static final String PROJECT_API_SCENARIO_UPDATE = "PROJECT_API_SCENARIO:READ+UPDATE"; public static final String PROJECT_API_SCENARIO_UPDATE = "PROJECT_API_SCENARIO:READ+UPDATE";
public static final String PROJECT_API_SCENARIO_DELETE = "PROJECT_API_SCENARIO:READ+DELETE"; public static final String PROJECT_API_SCENARIO_DELETE = "PROJECT_API_SCENARIO:READ+DELETE";
public static final String PROJECT_API_SCENARIO_RECOVER = "PROJECT_API_SCENARIO:READ+RECOVER";
public static final String PROJECT_API_SCENARIO_EXECUTE = "PROJECT_API_SCENARIO:READ+EXECUTE"; public static final String PROJECT_API_SCENARIO_EXECUTE = "PROJECT_API_SCENARIO:READ+EXECUTE";
public static final String PROJECT_API_SCENARIO_IMPORT = "PROJECT_API_SCENARIO:READ+IMPORT"; public static final String PROJECT_API_SCENARIO_IMPORT = "PROJECT_API_SCENARIO:READ+IMPORT";
public static final String PROJECT_API_SCENARIO_EXPORT = "PROJECT_API_SCENARIO:READ+EXPORT"; public static final String PROJECT_API_SCENARIO_EXPORT = "PROJECT_API_SCENARIO:READ+EXPORT";

View File

@ -454,6 +454,7 @@ permission.recover=恢复
permission.export=导出 permission.export=导出
permission.execute=执行 permission.execute=执行
permission.debug=调试 permission.debug=调试
permission.api_definition.delete_and_recover=删除/恢复
file_name_illegal_error=文件名不合法 file_name_illegal_error=文件名不合法
plugin_enable_error=插件未启用 plugin_enable_error=插件未启用

View File

@ -557,4 +557,6 @@ relate_source_type_not_blank=The associated resource type cannot be empty
api_import_schedule=API import schedule api_import_schedule=API import schedule
project.description.length_range=The description must be between {min} and {max} characters project.description.length_range=The description must be between {min} and {max} characters
api_test_environment_datasource_connect_failed=Data source connection failed api_test_environment_datasource_connect_failed=Data source connection failed
permission.api_definition.delete_and_recover=Delete/Recover

View File

@ -554,4 +554,6 @@ relate_source_type_not_blank=关联资源类型不能为空
api_import_schedule=接口定义-定时导入任务 api_import_schedule=接口定义-定时导入任务
project.description.length_range=项目描述长度必须在{min}和{max}之间 project.description.length_range=项目描述长度必须在{min}和{max}之间
api_test_environment_datasource_connect_failed=数据源连接失败 api_test_environment_datasource_connect_failed=数据源连接失败
permission.api_definition.delete_and_recover=删除/恢复

View File

@ -554,4 +554,6 @@ relate_source_type_not_blank=關聯資源類型不能為空
api_import_schedule=接口導入定時任務 api_import_schedule=接口導入定時任務
project.description.length_range=項目描述長度必須在{min}和{max}之間 project.description.length_range=項目描述長度必須在{min}和{max}之間
permission.api_definition.delete_and_recover=刪除/恢復

View File

@ -171,7 +171,7 @@ public class ApiDefinitionController {
@PostMapping(value = "/recover") @PostMapping(value = "/recover")
@Operation(summary = "接口测试-接口管理-恢复回收站接口定义") @Operation(summary = "接口测试-接口管理-恢复回收站接口定义")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_RECOVER) @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_DELETE)
@Log(type = OperationLogType.RECOVER, expression = "#msClass.recoverLog(#request)", msClass = ApiDefinitionLogService.class) @Log(type = OperationLogType.RECOVER, expression = "#msClass.recoverLog(#request)", msClass = ApiDefinitionLogService.class)
@CheckOwner(resourceId = "#request.getId()", resourceType = "api_definition") @CheckOwner(resourceId = "#request.getId()", resourceType = "api_definition")
public void recover(@Validated @RequestBody ApiDefinitionDeleteRequest request) { public void recover(@Validated @RequestBody ApiDefinitionDeleteRequest request) {
@ -180,7 +180,7 @@ public class ApiDefinitionController {
@PostMapping(value = "/batch-recover") @PostMapping(value = "/batch-recover")
@Operation(summary = "接口测试-接口管理-批量从回收站恢复接口定义") @Operation(summary = "接口测试-接口管理-批量从回收站恢复接口定义")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_RECOVER) @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_DELETE)
@CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "api_definition") @CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "api_definition")
public void batchRecover(@Validated @RequestBody ApiDefinitionBatchRequest request) { public void batchRecover(@Validated @RequestBody ApiDefinitionBatchRequest request) {
apiDefinitionService.batchRecover(request, SessionUtils.getUserId()); apiDefinitionService.batchRecover(request, SessionUtils.getUserId());

View File

@ -77,7 +77,7 @@ public class ApiTestCaseController {
@GetMapping("recover/{id}") @GetMapping("recover/{id}")
@Operation(summary = "接口测试-接口管理-接口用例-恢复") @Operation(summary = "接口测试-接口管理-接口用例-恢复")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_RECOVER) @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_DELETE)
@Log(type = OperationLogType.RECOVER, expression = "#msClass.recoverLog(#id)", msClass = ApiTestCaseLogService.class) @Log(type = OperationLogType.RECOVER, expression = "#msClass.recoverLog(#id)", msClass = ApiTestCaseLogService.class)
@CheckOwner(resourceId = "#id", resourceType = "api_test_case") @CheckOwner(resourceId = "#id", resourceType = "api_test_case")
public void recover(@PathVariable String id) { public void recover(@PathVariable String id) {
@ -179,7 +179,7 @@ public class ApiTestCaseController {
@PostMapping("/batch/recover") @PostMapping("/batch/recover")
@Operation(summary = "接口测试-接口管理-接口用例-批量恢复") @Operation(summary = "接口测试-接口管理-接口用例-批量恢复")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_RECOVER) @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_DELETE)
@CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "api_test_case") @CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "api_test_case")
public void batchRecover(@Validated @RequestBody ApiTestCaseBatchRequest request) { public void batchRecover(@Validated @RequestBody ApiTestCaseBatchRequest request) {
apiTestCaseRecoverService.batchRecover(request, SessionUtils.getUserId()); apiTestCaseRecoverService.batchRecover(request, SessionUtils.getUserId());

View File

@ -57,7 +57,7 @@ public class ApiScenarioBatchOperationController {
//需求补充回收站里的相关操作都不需要发通知 //需求补充回收站里的相关操作都不需要发通知
@PostMapping("/batch-operation/recover-gc") @PostMapping("/batch-operation/recover-gc")
@Operation(summary = "接口测试-接口场景批量操作-回收站列表-批量恢复") @Operation(summary = "接口测试-接口场景批量操作-回收站列表-批量恢复")
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_RECOVER) @RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_DELETE)
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
public ApiScenarioBatchOperationResponse recoverFromGc(@Validated @RequestBody ApiScenarioBatchRequest request) { public ApiScenarioBatchOperationResponse recoverFromGc(@Validated @RequestBody ApiScenarioBatchRequest request) {
apiValidateService.validateApiMenuInProject(request.getProjectId(), ApiResource.PROJECT.name()); apiValidateService.validateApiMenuInProject(request.getProjectId(), ApiResource.PROJECT.name());

View File

@ -143,7 +143,7 @@ public class ApiScenarioController {
//需求补充回收站里的相关操作都不需要发通知 //需求补充回收站里的相关操作都不需要发通知
@GetMapping("/recover/{id}") @GetMapping("/recover/{id}")
@Operation(summary = "接口测试-接口场景管理-删除场景到回收站") @Operation(summary = "接口测试-接口场景管理-删除场景到回收站")
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_RECOVER) @RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_DELETE)
@Log(type = OperationLogType.RESTORE, expression = "#msClass.restoreLog(#id)", msClass = ApiScenarioLogService.class) @Log(type = OperationLogType.RESTORE, expression = "#msClass.restoreLog(#id)", msClass = ApiScenarioLogService.class)
@CheckOwner(resourceId = "#id", resourceType = "api_scenario") @CheckOwner(resourceId = "#id", resourceType = "api_scenario")
public void recover(@PathVariable String id) { public void recover(@PathVariable String id) {

View File

@ -96,6 +96,7 @@ public class ApiScenarioReportService {
BeanUtils.copyBean(scenarioReportListDTO, scenarioReport); BeanUtils.copyBean(scenarioReportListDTO, scenarioReport);
scenarioReportListDTO.setCreateUserName(userMap.get(scenarioReport.getCreateUser())); scenarioReportListDTO.setCreateUserName(userMap.get(scenarioReport.getCreateUser()));
scenarioReportListDTO.setUpdateUserName(userMap.get(scenarioReport.getUpdateUser())); scenarioReportListDTO.setUpdateUserName(userMap.get(scenarioReport.getUpdateUser()));
result.add(scenarioReportListDTO);
}); });
return result; return result;
} }

View File

@ -42,7 +42,8 @@
"id": "PROJECT_API_DEFINITION:READ+UPDATE" "id": "PROJECT_API_DEFINITION:READ+UPDATE"
}, },
{ {
"id": "PROJECT_API_DEFINITION:READ+DELETE" "id": "PROJECT_API_DEFINITION:READ+DELETE",
"name": "permission.api_definition.delete_and_recover"
}, },
{ {
"id": "PROJECT_API_DEFINITION:READ+IMPORT" "id": "PROJECT_API_DEFINITION:READ+IMPORT"
@ -69,7 +70,8 @@
"id": "PROJECT_API_DEFINITION_CASE:READ+UPDATE" "id": "PROJECT_API_DEFINITION_CASE:READ+UPDATE"
}, },
{ {
"id": "PROJECT_API_DEFINITION_CASE:READ+DELETE" "id": "PROJECT_API_DEFINITION_CASE:READ+DELETE",
"name": "permission.api_definition.delete_and_recover"
}, },
{ {
"id": "PROJECT_API_DEFINITION_CASE:READ+EXECUTE" "id": "PROJECT_API_DEFINITION_CASE:READ+EXECUTE"
@ -90,7 +92,8 @@
"id": "PROJECT_API_DEFINITION_MOCK:READ+UPDATE" "id": "PROJECT_API_DEFINITION_MOCK:READ+UPDATE"
}, },
{ {
"id": "PROJECT_API_DEFINITION_MOCK:READ+DELETE" "id": "PROJECT_API_DEFINITION_MOCK:READ+DELETE",
"name": "permission.api_definition.delete_and_recover"
}, },
{ {
"id": "PROJECT_API_DEFINITION_MOCK:READ+EXECUTE" "id": "PROJECT_API_DEFINITION_MOCK:READ+EXECUTE"
@ -124,7 +127,8 @@
"id": "PROJECT_API_SCENARIO:READ+UPDATE" "id": "PROJECT_API_SCENARIO:READ+UPDATE"
}, },
{ {
"id": "PROJECT_API_SCENARIO:READ+DELETE" "id": "PROJECT_API_SCENARIO:READ+DELETE",
"name": "permission.api_definition.delete_and_recover"
}, },
{ {
"id": "PROJECT_API_SCENARIO:READ+EXECUTE" "id": "PROJECT_API_SCENARIO:READ+EXECUTE"

View File

@ -1343,7 +1343,7 @@ public class ApiDefinitionControllerTests extends BaseTest {
// @@校验权限 // @@校验权限
apiDefinitionDeleteRequest.setId(apiDefinition.getId()); apiDefinitionDeleteRequest.setId(apiDefinition.getId());
requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_RECOVER, RESTORE, apiDefinitionDeleteRequest); requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_DELETE, RESTORE, apiDefinitionDeleteRequest);
} }
@Test @Test
@ -1391,7 +1391,7 @@ public class ApiDefinitionControllerTests extends BaseTest {
checkLogModelList.add(new CheckLogModel(id, OperationLogType.RECOVER, BATCH_RESTORE)); checkLogModelList.add(new CheckLogModel(id, OperationLogType.RECOVER, BATCH_RESTORE));
} }
// @@校验权限 // @@校验权限
requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_RECOVER, BATCH_RESTORE, request); requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_DELETE, BATCH_RESTORE, request);
} }
@Test @Test

View File

@ -2053,7 +2053,7 @@ public class ApiScenarioControllerTests extends BaseTest {
Assertions.assertEquals(resultResponse.getSuccess(), 0); Assertions.assertEquals(resultResponse.getSuccess(), 0);
//校验权限 //校验权限
this.requestPostPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_RECOVER, testUrl, request); this.requestPostPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_DELETE, testUrl, request);
//反例测试 ->参数校验项目ID为空 //反例测试 ->参数校验项目ID为空
request = new ApiScenarioBatchCopyMoveRequest(); request = new ApiScenarioBatchCopyMoveRequest();

View File

@ -500,7 +500,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
this.requestGet(RECOVER + "111").andExpect(ERROR_REQUEST_MATCHER); this.requestGet(RECOVER + "111").andExpect(ERROR_REQUEST_MATCHER);
// @@校验权限 // @@校验权限
requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_RECOVER, RECOVER + apiTestCase.getId()); requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_DELETE, RECOVER + apiTestCase.getId());
} }
//关注 //关注
@ -1050,7 +1050,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
//校验日志 //校验日志
checkLog(apiTestCase.getId(), OperationLogType.DELETE); checkLog(apiTestCase.getId(), OperationLogType.DELETE);
//校验权限 //校验权限
requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_RECOVER, BATCH_RECOVER, request); requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_DELETE, BATCH_RECOVER, request);
ApiTestCaseBatchRequest gcRequest = new ApiTestCaseBatchRequest(); ApiTestCaseBatchRequest gcRequest = new ApiTestCaseBatchRequest();
gcRequest.setProjectId(DEFAULT_PROJECT_ID); gcRequest.setProjectId(DEFAULT_PROJECT_ID);
gcRequest.setSelectAll(true); gcRequest.setSelectAll(true);

View File

@ -18,7 +18,8 @@
"id": "PROJECT_BUG:READ+UPDATE" "id": "PROJECT_BUG:READ+UPDATE"
}, },
{ {
"id": "PROJECT_BUG:READ+DELETE" "id": "PROJECT_BUG:READ+DELETE",
"name": "permission.api_definition.delete_and_recover"
}, },
{ {
"id": "PROJECT_BUG:READ+EXPORT" "id": "PROJECT_BUG:READ+EXPORT"

View File

@ -18,7 +18,8 @@
"id": "FUNCTIONAL_CASE:READ+UPDATE" "id": "FUNCTIONAL_CASE:READ+UPDATE"
}, },
{ {
"id": "FUNCTIONAL_CASE:READ+DELETE" "id": "FUNCTIONAL_CASE:READ+DELETE",
"name": "permission.api_definition.delete_and_recover"
}, },
{ {
"id": "FUNCTIONAL_CASE:READ+COMMENT", "id": "FUNCTIONAL_CASE:READ+COMMENT",