refactor(接口测试): 禁用本地执行授权校验优化
This commit is contained in:
parent
2b78ec74a4
commit
ad06b74256
|
@ -15,13 +15,13 @@ import io.metersphere.commons.utils.*;
|
|||
import io.metersphere.config.JmeterProperties;
|
||||
import io.metersphere.constants.BackendListenerConstants;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
import io.metersphere.dto.*;
|
||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||
import io.metersphere.dto.NodeDTO;
|
||||
import io.metersphere.dto.RunModeConfigDTO;
|
||||
import io.metersphere.engine.Engine;
|
||||
import io.metersphere.jmeter.JMeterBase;
|
||||
import io.metersphere.jmeter.LocalRunner;
|
||||
import io.metersphere.service.BaseProjectApplicationService;
|
||||
import io.metersphere.service.RemakeReportService;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import io.metersphere.xpack.api.service.ApiPoolDebugService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -56,10 +56,6 @@ public class JMeterService {
|
|||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@Resource
|
||||
private SystemParameterService systemParameterService;
|
||||
@Resource
|
||||
private BaseProjectApplicationService projectApplicationService;
|
||||
@Resource
|
||||
private RemakeReportService remakeReportService;
|
||||
@Resource
|
||||
private ExecThreadPoolExecutor execThreadPoolExecutor;
|
||||
|
@ -254,19 +250,10 @@ public class JMeterService {
|
|||
}
|
||||
}
|
||||
|
||||
public void verifyPool(String projectId, RunModeConfigDTO runConfig) {
|
||||
// 检查是否禁用了本地执行
|
||||
if (runConfig != null && StringUtils.isEmpty(runConfig.getResourcePoolId())
|
||||
&& CommonBeanFactory.getBean(ApiPoolDebugService.class) != null) {
|
||||
BaseSystemConfigDTO configDTO = systemParameterService.getBaseInfo();
|
||||
if (StringUtils.equals(configDTO.getRunMode(), POOL)) {
|
||||
ProjectConfig config = projectApplicationService.getProjectConfig(projectId);
|
||||
if (config == null || !config.getPoolEnable() || StringUtils.isEmpty(config.getResourcePoolId())) {
|
||||
MSException.throwException("请在【项目设置-应用管理-接口测试】中选择资源池");
|
||||
}
|
||||
runConfig = runConfig == null ? new RunModeConfigDTO() : runConfig;
|
||||
runConfig.setResourcePoolId(config.getResourcePoolId());
|
||||
}
|
||||
public void verifyPool(String projectId, RunModeConfigDTO runModeConfigDTO) {
|
||||
ApiPoolDebugService debugService = CommonBeanFactory.getBean(ApiPoolDebugService.class);
|
||||
if (debugService != null) {
|
||||
debugService.verifyPool(projectId, runModeConfigDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,12 @@ package io.metersphere.xpack.api.service;
|
|||
|
||||
import io.metersphere.base.domain.TestResource;
|
||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||
import io.metersphere.dto.RunModeConfigDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ApiPoolDebugService {
|
||||
public void run(JmeterRunRequestDTO request, List<TestResource> resources);
|
||||
|
||||
public void verifyPool(String projectId, RunModeConfigDTO runConfig);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import io.metersphere.request.ScheduleRequest;
|
|||
import io.metersphere.service.*;
|
||||
import io.metersphere.utils.DiscoveryUtil;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import io.metersphere.xpack.api.service.ApiPoolDebugService;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
|
@ -889,16 +890,9 @@ public class TestPlanService {
|
|||
|
||||
public void verifyPool(String projectId, RunModeConfigDTO runConfig) {
|
||||
// 检查是否禁用了本地执行
|
||||
if (runConfig != null && StringUtils.isEmpty(runConfig.getResourcePoolId())) {
|
||||
BaseSystemConfigDTO configDTO = systemParameterService.getBaseInfo();
|
||||
if (StringUtils.equals(configDTO.getRunMode(), POOL)) {
|
||||
ProjectConfig config = projectApplicationService.getProjectConfig(projectId);
|
||||
if (config == null || !config.getPoolEnable() || StringUtils.isEmpty(config.getResourcePoolId())) {
|
||||
MSException.throwException("请在【项目设置-应用管理-接口测试】中选择资源池");
|
||||
}
|
||||
runConfig = runConfig == null ? new RunModeConfigDTO() : runConfig;
|
||||
runConfig.setResourcePoolId(config.getResourcePoolId());
|
||||
}
|
||||
ApiPoolDebugService debugService = CommonBeanFactory.getBean(ApiPoolDebugService.class);
|
||||
if (debugService != null) {
|
||||
debugService.verifyPool(projectId, runConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue