mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-10 19:31:33 +08:00
feat(项目管理): 项目管理-应用设置-接口测试配置功能
This commit is contained in:
parent
b4dadd8806
commit
45afe7b8fb
@ -147,6 +147,8 @@ public class PermissionConstants {
|
||||
public static final String PROJECT_APPLICATION_UI_UPDATE = "PROJECT_APPLICATION_UI:UPDATE";
|
||||
public static final String PROJECT_APPLICATION_PERFORMANCE_TEST_READ = "PROJECT_APPLICATION_PERFORMANCE_TEST:READ";
|
||||
public static final String PROJECT_APPLICATION_PERFORMANCE_TEST_UPDATE = "PROJECT_APPLICATION_PERFORMANCE_TEST:UPDATE";
|
||||
public static final String PROJECT_APPLICATION_API_READ = "PROJECT_APPLICATION_API:READ";
|
||||
public static final String PROJECT_APPLICATION_API_UPDATE = "PROJECT_APPLICATION_API:UPDATE";
|
||||
/*------ end: PROJECT_APPLICATION ------*/
|
||||
public static final String PROJECT_BASE_INFO_READ = "PROJECT_BASE_INFO:READ";
|
||||
}
|
||||
|
@ -47,6 +47,38 @@ public enum ProjectApplicationType {
|
||||
APPLICATION_PERFORMANCE_TEST_SCRIPT_REVIEWER,
|
||||
|
||||
|
||||
//接口测试
|
||||
/**
|
||||
* 接口定义 URL可重复
|
||||
*/
|
||||
APPLICATION_API_URL_REPEATABLE,
|
||||
/**
|
||||
* 接口测试 报告保留范围
|
||||
*/
|
||||
APPLICATION_CLEAN_API_REPORT,
|
||||
/**
|
||||
* 接口测试 报告有效期
|
||||
*/
|
||||
APPLICATION_SHARE_API_REPORT,
|
||||
/**
|
||||
* 接口测试 执行资源池
|
||||
*/
|
||||
APPLICATION_API_RESOURCE_POOL,
|
||||
/**
|
||||
* 接口测试 脚本审核人
|
||||
*/
|
||||
APPLICATION_API_SCRIPT_REVIEWER,
|
||||
/**
|
||||
* 接口测试 自定义误报规则
|
||||
*/
|
||||
APPLICATION_API_ERROR_REPORT_RULE,
|
||||
/**
|
||||
* 接口测试 接口变更同步case
|
||||
*/
|
||||
APPLICATION_API_SYNC_CASE,
|
||||
|
||||
|
||||
|
||||
//缺陷管理
|
||||
/**
|
||||
* 同步缺陷 标识
|
||||
|
@ -111,5 +111,7 @@ permission.project_application_ui.read=UI test read
|
||||
permission.project_application_ui.update=UI test update
|
||||
permission.project_application_performance_test.read=Performance test read
|
||||
permission.project_application_performance_test.update=Performance test update
|
||||
permission.project_application_api.read=API test read
|
||||
permission.project_application_api.update=API test update
|
||||
permission.project_base_info.name=Project base info
|
||||
permission.project_log.name=Operation log
|
||||
|
@ -111,5 +111,7 @@ permission.project_application_ui.read=UI测试-查询
|
||||
permission.project_application_ui.update=UI测试-编辑
|
||||
permission.project_application_performance_test.read=性能测试-查询
|
||||
permission.project_application_performance_test.update=性能测试-编辑
|
||||
permission.project_application_api.read=接口测试-查询
|
||||
permission.project_application_api.update=接口测试-编辑
|
||||
permission.project_base_info.name=基本信息
|
||||
permission.project_log.name=日志
|
||||
|
@ -111,5 +111,7 @@ permission.project_application_ui.read=UI測試-查詢
|
||||
permission.project_application_ui.update=UI測試-編輯
|
||||
permission.project_application_performance_test.read=性能測試-查詢
|
||||
permission.project_application_performance_test.update=性能測試-編輯
|
||||
permission.project_application_api.read=接口測試-查詢
|
||||
permission.project_application_api.update=接口測試-編輯
|
||||
permission.project_base_info.name=基本信息
|
||||
permission.project_log.name=日誌
|
@ -4,11 +4,11 @@ import io.metersphere.project.domain.ProjectApplication;
|
||||
import io.metersphere.project.request.ProjectApplicationRequest;
|
||||
import io.metersphere.project.service.ProjectApplicationService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.log.annotation.Log;
|
||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.SessionUtils;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.service.UserService;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -27,8 +27,7 @@ import java.util.List;
|
||||
public class ProjectApplicationController {
|
||||
@Resource
|
||||
private ProjectApplicationService projectApplicationService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
|
||||
/**
|
||||
* ==========测试计划==========
|
||||
@ -92,7 +91,42 @@ public class ProjectApplicationController {
|
||||
@GetMapping("/performance-test/user/{projectId}")
|
||||
@Operation(summary = "应用设置-性能测试-获取审核人")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_PERFORMANCE_TEST_READ)
|
||||
public List<User> getCheckUser(@PathVariable String projectId) {
|
||||
public List<User> getReviewerUser(@PathVariable String projectId) {
|
||||
return projectApplicationService.getProjectUserList(StringUtils.defaultIfBlank(projectId, SessionUtils.getCurrentProjectId()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ==========接口测试==========
|
||||
*/
|
||||
|
||||
@PostMapping("/update/api")
|
||||
@Operation(summary = "应用设置-接口测试-配置")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_API_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateApiLog(#application)", msClass = ProjectApplicationService.class)
|
||||
public ProjectApplication updateApi(@Validated({Updated.class}) @RequestBody ProjectApplication application) {
|
||||
return projectApplicationService.update(application);
|
||||
}
|
||||
|
||||
@PostMapping("/api")
|
||||
@Operation(summary = "应用设置-接口测试-获取配置")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_API_READ)
|
||||
public List<ProjectApplication> getApi(@Validated @RequestBody ProjectApplicationRequest request) {
|
||||
return projectApplicationService.get(request);
|
||||
}
|
||||
|
||||
@GetMapping("/api/user/{projectId}")
|
||||
@Operation(summary = "应用设置-接口测试-获取审核人")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_API_READ)
|
||||
public List<User> getApiReviewerUser(@PathVariable String projectId) {
|
||||
return projectApplicationService.getProjectUserList(StringUtils.defaultIfBlank(projectId, SessionUtils.getCurrentProjectId()));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/api/resource/pool/{organizationId}")
|
||||
@Operation(summary = "应用设置-接口测试-获取资源池列表")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_API_READ)
|
||||
public List<OptionDTO> getResourcePoolList(@PathVariable String organizationId) {
|
||||
return projectApplicationService.getResourcePoolList(StringUtils.defaultIfBlank(organizationId, SessionUtils.getCurrentOrganizationId()));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package io.metersphere.project.mapper;
|
||||
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wx
|
||||
*/
|
||||
public interface ExtProjectTestResourcePoolMapper {
|
||||
|
||||
/**
|
||||
* 获取当前项目资源池列表
|
||||
* @param orgId
|
||||
* @return
|
||||
*/
|
||||
List<OptionDTO> getResourcePoolList(@Param("orgId") String orgId);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.project.mapper.ExtProjectTestResourcePoolMapper">
|
||||
|
||||
|
||||
<select id="getResourcePoolList" resultType="io.metersphere.sdk.dto.OptionDTO">
|
||||
SELECT
|
||||
id,
|
||||
NAME
|
||||
FROM
|
||||
test_resource_pool
|
||||
WHERE
|
||||
all_org = 1
|
||||
AND `enable` = 1
|
||||
AND deleted = 0
|
||||
UNION
|
||||
SELECT
|
||||
trp.id,
|
||||
trp.NAME
|
||||
FROM
|
||||
test_resource_pool trp
|
||||
LEFT JOIN test_resource_pool_organization trpo ON trp.id = trpo.test_resource_pool_id
|
||||
WHERE
|
||||
trpo.org_id = #{orgId}
|
||||
AND trp.`enable` = 1
|
||||
AND trp.deleted = 0
|
||||
</select>
|
||||
</mapper>
|
@ -3,6 +3,7 @@ package io.metersphere.project.service;
|
||||
import io.metersphere.project.domain.ProjectApplication;
|
||||
import io.metersphere.project.domain.ProjectApplicationExample;
|
||||
import io.metersphere.project.job.CleanUpReportJob;
|
||||
import io.metersphere.project.mapper.ExtProjectTestResourcePoolMapper;
|
||||
import io.metersphere.project.mapper.ExtProjectUserRoleMapper;
|
||||
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
||||
import io.metersphere.project.request.ProjectApplicationRequest;
|
||||
@ -10,6 +11,7 @@ import io.metersphere.sdk.constants.OperationLogConstants;
|
||||
import io.metersphere.sdk.constants.ProjectApplicationType;
|
||||
import io.metersphere.sdk.constants.ScheduleType;
|
||||
import io.metersphere.sdk.dto.LogDTO;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.log.constants.OperationLogModule;
|
||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.sechedule.BaseScheduleService;
|
||||
@ -17,7 +19,6 @@ import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.SessionUtils;
|
||||
import io.metersphere.system.domain.Schedule;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.mapper.ExtUserMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
@ -41,9 +42,12 @@ public class ProjectApplicationService {
|
||||
@Resource
|
||||
private ExtProjectUserRoleMapper extProjectUserRoleMapper;
|
||||
|
||||
@Resource
|
||||
private ExtProjectTestResourcePoolMapper extProjectTestResourcePoolMapper;
|
||||
|
||||
/**
|
||||
* 更新配置信息
|
||||
*
|
||||
* @param application
|
||||
* @return
|
||||
*/
|
||||
@ -74,8 +78,9 @@ public class ProjectApplicationService {
|
||||
//TODO 自定义id配置 &其他配置
|
||||
if (StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_TEST_PLAN_REPORT.name())
|
||||
|| StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_UI_REPORT.name())
|
||||
|| StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_PERFORMANCE_TEST_REPORT.name())) {
|
||||
//清除 测试计划/UI测试/性能测试 报告 定时任务
|
||||
|| StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_PERFORMANCE_TEST_REPORT.name())
|
||||
|| StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_API_REPORT.name())) {
|
||||
//清除 测试计划/UI测试/性能测试/接口测试 报告 定时任务
|
||||
this.doHandleSchedule(application);
|
||||
}
|
||||
}
|
||||
@ -132,11 +137,28 @@ public class ProjectApplicationService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 项目成员(脚本审核人)
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
public List<User> getProjectUserList(String projectId) {
|
||||
return extProjectUserRoleMapper.getProjectUserList(projectId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前项目 可用资源池
|
||||
*
|
||||
* @param organizationId
|
||||
* @return
|
||||
*/
|
||||
public List<OptionDTO> getResourcePoolList(String organizationId) {
|
||||
return extProjectTestResourcePoolMapper.getResourcePoolList(organizationId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试计划 日志
|
||||
*
|
||||
@ -168,6 +190,16 @@ public class ProjectApplicationService {
|
||||
return delLog(application, OperationLogModule.PROJECT_PROJECT_MANAGER, "性能测试配置");
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口测试 日志
|
||||
*
|
||||
* @param application
|
||||
* @return
|
||||
*/
|
||||
public LogDTO updateApiLog(ProjectApplication application) {
|
||||
return delLog(application, OperationLogModule.PROJECT_PROJECT_MANAGER, "接口测试配置");
|
||||
}
|
||||
|
||||
private LogDTO delLog(ProjectApplication application, String module, String content) {
|
||||
ProjectApplicationExample example = new ProjectApplicationExample();
|
||||
example.createCriteria().andTypeEqualTo(application.getType()).andProjectIdEqualTo(application.getProjectId());
|
||||
|
@ -151,6 +151,14 @@
|
||||
{
|
||||
"id": "PROJECT_APPLICATION_PERFORMANCE_TEST:UPDATE",
|
||||
"name": "permission.project_application_performance_test.update"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_APPLICATION_API:READ",
|
||||
"name": "permission.project_application_api.read"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_APPLICATION_API:UPDATE",
|
||||
"name": "permission.project_application_api.update"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -123,7 +123,6 @@ public class ProjectApplicationControllerTests extends BaseTest {
|
||||
// @@异常参数校验
|
||||
updatedGroupParamValidateTest(ProjectApplicationRequestDefinition.class, GET_UI_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ==========UI测试 end==========
|
||||
*/
|
||||
@ -139,7 +138,7 @@ public class ProjectApplicationControllerTests extends BaseTest {
|
||||
//获取脚本审核人
|
||||
public static final String GET_USER_URL = "/project/application/performance-test/user";
|
||||
|
||||
//应用配置 - UI测试 - 清理报告配置
|
||||
//应用配置 - 性能测试 - 清理报告配置
|
||||
@Test
|
||||
@Order(7)
|
||||
public void testPerformanceClean() throws Exception {
|
||||
@ -154,7 +153,7 @@ public class ProjectApplicationControllerTests extends BaseTest {
|
||||
|
||||
}
|
||||
|
||||
//应用管理 - UI测试 - 分享报告配置
|
||||
//应用管理 - 性能测试 - 分享报告配置
|
||||
@Test
|
||||
@Order(8)
|
||||
public void testPerformanceShare() throws Exception {
|
||||
@ -166,7 +165,7 @@ public class ProjectApplicationControllerTests extends BaseTest {
|
||||
this.requestPost(PERFORMANCE_UPDATE_URL, request);
|
||||
}
|
||||
|
||||
//应用管理 - UI测试 - 脚本审核
|
||||
//应用管理 - 性能测试 - 脚本审核
|
||||
@Test
|
||||
@Order(9)
|
||||
public void testPerformanceReviewer() throws Exception {
|
||||
@ -175,7 +174,7 @@ public class ProjectApplicationControllerTests extends BaseTest {
|
||||
this.requestPost(PERFORMANCE_UPDATE_URL, request);
|
||||
}
|
||||
|
||||
//应用管理 - UI测试 - 获取配置
|
||||
//应用管理 - 性能测试 - 获取配置
|
||||
@Test
|
||||
@Order(10)
|
||||
public void testGetPerformance() throws Exception {
|
||||
@ -187,11 +186,114 @@ public class ProjectApplicationControllerTests extends BaseTest {
|
||||
updatedGroupParamValidateTest(ProjectApplicationRequestDefinition.class, GET_PERFORMANCE_URL);
|
||||
}
|
||||
|
||||
//应用管理 - 性能测试 - 获取项目成员
|
||||
@Test
|
||||
@Order(11)
|
||||
public void testGetUser() throws Exception {
|
||||
this.requestGetWithOkAndReturn(GET_USER_URL + "/default-project-2");
|
||||
}
|
||||
/**
|
||||
* ==========性能测试 end==========
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* ==========接口测试 start==========
|
||||
*/
|
||||
// 接口测试
|
||||
public static final String API_UPDATE_URL = "/project/application/update/api";
|
||||
//获取配置
|
||||
public static final String GET_API_URL = "/project/application/api";
|
||||
//获取脚本审核人
|
||||
public static final String GET_API_USER_URL = "/project/application/api/user";
|
||||
//获取资源池
|
||||
public static final String GET_API_RESOURCE_POOL_URL = "/project/application/api/resource/pool";
|
||||
|
||||
//应用配置 - 接口测试 - URL可重复
|
||||
@Test
|
||||
@Order(12)
|
||||
public void testUrlRepeatable() throws Exception {
|
||||
ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_API_URL_REPEATABLE.name(), "true");
|
||||
this.requestPost(API_UPDATE_URL, request);
|
||||
|
||||
}
|
||||
|
||||
//应用配置 - 接口测试 - 清理报告配置
|
||||
@Test
|
||||
@Order(13)
|
||||
public void testApiClean() throws Exception {
|
||||
ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_CLEAN_API_REPORT.name(), TIME_TYPE_VALUE);
|
||||
this.requestPost(API_UPDATE_URL, request);
|
||||
}
|
||||
|
||||
//应用管理 - 接口测试 - 分享报告配置
|
||||
@Test
|
||||
@Order(14)
|
||||
public void testApiShare() throws Exception {
|
||||
ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_SHARE_API_REPORT.name(), TIME_TYPE_VALUE);
|
||||
this.requestPost(API_UPDATE_URL, request);
|
||||
}
|
||||
|
||||
//应用管理 - 接口测试 - 执行资源池
|
||||
@Test
|
||||
@Order(15)
|
||||
public void testApiResourcePool() throws Exception {
|
||||
ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_API_RESOURCE_POOL.name(), "local");
|
||||
this.requestPost(API_UPDATE_URL, request);
|
||||
}
|
||||
|
||||
//应用管理 - 接口测试 - 脚本审核
|
||||
@Test
|
||||
@Order(16)
|
||||
public void testApiReviewer() throws Exception {
|
||||
ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_API_SCRIPT_REVIEWER.name(), "admin");
|
||||
this.requestPost(API_UPDATE_URL, request);
|
||||
}
|
||||
|
||||
//应用管理 - 接口测试 - 自定义误报规则
|
||||
@Test
|
||||
@Order(17)
|
||||
public void testApiErrorReportRule() throws Exception {
|
||||
ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_API_ERROR_REPORT_RULE.name(), "true");
|
||||
this.requestPost(API_UPDATE_URL, request);
|
||||
}
|
||||
|
||||
//应用管理 - 接口测试 - 接口变更同步case
|
||||
@Test
|
||||
@Order(18)
|
||||
public void testApiSyncCase() throws Exception {
|
||||
ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_API_SYNC_CASE.name(), "true");
|
||||
this.requestPost(API_UPDATE_URL, request);
|
||||
}
|
||||
|
||||
//应用管理 - 接口测试 - 获取配置
|
||||
@Test
|
||||
@Order(19)
|
||||
public void testGetApi() throws Exception {
|
||||
List<String> types = Arrays.asList(ProjectApplicationType.APPLICATION_API_URL_REPEATABLE.name(), ProjectApplicationType.APPLICATION_CLEAN_API_REPORT.name(), ProjectApplicationType.APPLICATION_SHARE_API_REPORT.name(),
|
||||
ProjectApplicationType.APPLICATION_API_RESOURCE_POOL.name(), ProjectApplicationType.APPLICATION_API_SCRIPT_REVIEWER.name(), ProjectApplicationType.APPLICATION_API_ERROR_REPORT_RULE.name(),
|
||||
ProjectApplicationType.APPLICATION_API_SYNC_CASE.name());
|
||||
ProjectApplicationRequest request = this.getRequest(types);
|
||||
this.requestPostWithOkAndReturn(GET_API_URL, request);
|
||||
}
|
||||
|
||||
//应用管理 - 接口测试 - 获取项目成员
|
||||
@Test
|
||||
@Order(20)
|
||||
public void testGetApiUser() throws Exception {
|
||||
this.requestGetWithOkAndReturn(GET_API_USER_URL + "/default-project-2");
|
||||
}
|
||||
|
||||
|
||||
//应用管理 - 接口测试 - 获取资源池
|
||||
@Test
|
||||
@Order(21)
|
||||
public void testGetApiResourcePool() throws Exception {
|
||||
this.requestGetWithOkAndReturn(GET_API_RESOURCE_POOL_URL + "/default_organization");
|
||||
}
|
||||
/**
|
||||
* ==========接口测试 end==========
|
||||
*/
|
||||
|
||||
|
||||
private ProjectApplicationRequest getRequest(List<String> types) {
|
||||
|
Loading…
Reference in New Issue
Block a user