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.config.JmeterProperties;
|
||||||
import io.metersphere.constants.BackendListenerConstants;
|
import io.metersphere.constants.BackendListenerConstants;
|
||||||
import io.metersphere.constants.RunModeConstants;
|
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.engine.Engine;
|
||||||
import io.metersphere.jmeter.JMeterBase;
|
import io.metersphere.jmeter.JMeterBase;
|
||||||
import io.metersphere.jmeter.LocalRunner;
|
import io.metersphere.jmeter.LocalRunner;
|
||||||
import io.metersphere.service.BaseProjectApplicationService;
|
|
||||||
import io.metersphere.service.RemakeReportService;
|
import io.metersphere.service.RemakeReportService;
|
||||||
import io.metersphere.service.SystemParameterService;
|
|
||||||
import io.metersphere.utils.LoggerUtil;
|
import io.metersphere.utils.LoggerUtil;
|
||||||
import io.metersphere.xpack.api.service.ApiPoolDebugService;
|
import io.metersphere.xpack.api.service.ApiPoolDebugService;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
@ -56,10 +56,6 @@ public class JMeterService {
|
||||||
@Resource
|
@Resource
|
||||||
private RedisTemplate<String, Object> redisTemplate;
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
@Resource
|
@Resource
|
||||||
private SystemParameterService systemParameterService;
|
|
||||||
@Resource
|
|
||||||
private BaseProjectApplicationService projectApplicationService;
|
|
||||||
@Resource
|
|
||||||
private RemakeReportService remakeReportService;
|
private RemakeReportService remakeReportService;
|
||||||
@Resource
|
@Resource
|
||||||
private ExecThreadPoolExecutor execThreadPoolExecutor;
|
private ExecThreadPoolExecutor execThreadPoolExecutor;
|
||||||
|
@ -254,19 +250,10 @@ public class JMeterService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void verifyPool(String projectId, RunModeConfigDTO runConfig) {
|
public void verifyPool(String projectId, RunModeConfigDTO runModeConfigDTO) {
|
||||||
// 检查是否禁用了本地执行
|
ApiPoolDebugService debugService = CommonBeanFactory.getBean(ApiPoolDebugService.class);
|
||||||
if (runConfig != null && StringUtils.isEmpty(runConfig.getResourcePoolId())
|
if (debugService != null) {
|
||||||
&& CommonBeanFactory.getBean(ApiPoolDebugService.class) != null) {
|
debugService.verifyPool(projectId, runModeConfigDTO);
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,12 @@ package io.metersphere.xpack.api.service;
|
||||||
|
|
||||||
import io.metersphere.base.domain.TestResource;
|
import io.metersphere.base.domain.TestResource;
|
||||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||||
|
import io.metersphere.dto.RunModeConfigDTO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ApiPoolDebugService {
|
public interface ApiPoolDebugService {
|
||||||
public void run(JmeterRunRequestDTO request, List<TestResource> resources);
|
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.service.*;
|
||||||
import io.metersphere.utils.DiscoveryUtil;
|
import io.metersphere.utils.DiscoveryUtil;
|
||||||
import io.metersphere.utils.LoggerUtil;
|
import io.metersphere.utils.LoggerUtil;
|
||||||
|
import io.metersphere.xpack.api.service.ApiPoolDebugService;
|
||||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
|
@ -889,16 +890,9 @@ public class TestPlanService {
|
||||||
|
|
||||||
public void verifyPool(String projectId, RunModeConfigDTO runConfig) {
|
public void verifyPool(String projectId, RunModeConfigDTO runConfig) {
|
||||||
// 检查是否禁用了本地执行
|
// 检查是否禁用了本地执行
|
||||||
if (runConfig != null && StringUtils.isEmpty(runConfig.getResourcePoolId())) {
|
ApiPoolDebugService debugService = CommonBeanFactory.getBean(ApiPoolDebugService.class);
|
||||||
BaseSystemConfigDTO configDTO = systemParameterService.getBaseInfo();
|
if (debugService != null) {
|
||||||
if (StringUtils.equals(configDTO.getRunMode(), POOL)) {
|
debugService.verifyPool(projectId, runConfig);
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue