Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
6b68429a47
|
@ -44,21 +44,20 @@ public class ApiDefinitionController {
|
|||
@PostMapping(value = "/create", consumes = {"multipart/form-data"})
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
|
||||
public void create(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||
checkPermissionService.checkReadOnlyUser();
|
||||
checkPermissionService.checkProjectOwner(request.getProjectId());
|
||||
apiDefinitionService.create(request, bodyFiles);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/update", consumes = {"multipart/form-data"})
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
|
||||
public void update(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||
checkPermissionService.checkReadOnlyUser();
|
||||
checkPermissionService.checkProjectOwner(request.getProjectId());
|
||||
apiDefinitionService.update(request, bodyFiles);
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{id}")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
|
||||
public void delete(@PathVariable String id) {
|
||||
checkPermissionService.checkReadOnlyUser();
|
||||
apiDefinitionService.delete(id);
|
||||
}
|
||||
|
||||
|
|
|
@ -206,35 +206,17 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
this.getRest().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).forEach(keyValue ->
|
||||
keyValueMap.put(keyValue.getName(), keyValue.getValue())
|
||||
);
|
||||
// 这块是否使用jmeter自身机制?
|
||||
Map<String, String> pubKeyValueMap = new HashMap<>();
|
||||
if (config != null && config.getVariables() != null) {
|
||||
config.getVariables().stream().forEach(keyValue -> {
|
||||
pubKeyValueMap.put(keyValue.getName(), keyValue.getValue());
|
||||
});
|
||||
}
|
||||
for (String key : keyValueMap.keySet()) {
|
||||
if (keyValueMap.get(key) != null && keyValueMap.get(key).startsWith("$")) {
|
||||
String pubKey = keyValueMap.get(key).substring(2, keyValueMap.get(key).length() - 1);
|
||||
keyValueMap.put(key, pubKeyValueMap.get(pubKey));
|
||||
}
|
||||
}
|
||||
|
||||
Pattern p = Pattern.compile("(\\{)([\\w]+)(\\})");
|
||||
Matcher m = p.matcher(path);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
try {
|
||||
Pattern p = Pattern.compile("(\\{)([\\w]+)(\\})");
|
||||
Matcher m = p.matcher(path);
|
||||
while (m.find()) {
|
||||
String group = m.group(2);
|
||||
//替换并且把替换好的值放到sb中
|
||||
m.appendReplacement(sb, keyValueMap.get(group));
|
||||
path = path.replace("{" + group + "}", keyValueMap.get(group));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
//把符合的数据追加到sb尾
|
||||
m.appendTail(sb);
|
||||
return sb.toString();
|
||||
return path;
|
||||
}
|
||||
|
||||
private String getPostQueryParameters(String path) {
|
||||
|
|
|
@ -30,9 +30,6 @@ import io.metersphere.service.ScheduleService;
|
|||
import io.metersphere.track.dto.TestPlanDTO;
|
||||
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
|
||||
import io.metersphere.track.service.TestPlanApiCaseService;
|
||||
import io.metersphere.track.service.TestPlanScenarioCaseService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
|
@ -47,8 +44,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -343,7 +338,6 @@ public class ApiAutomationService {
|
|||
ParameterConfig config = new ParameterConfig();
|
||||
config.setConfig(envConfig);
|
||||
HashTree hashTree = request.getTestElement().generateHashTree(config);
|
||||
request.getTestElement().getJmx(hashTree);
|
||||
// 调用执行方法
|
||||
jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), ApiRunMode.SCENARIO.name());
|
||||
createAPIScenarioReportResult(request.getId(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(),
|
||||
|
|
|
@ -75,7 +75,7 @@ public class PerformanceTestController {
|
|||
@RequestPart("request") SaveTestPlanRequest request,
|
||||
@RequestPart(value = "file") List<MultipartFile> files
|
||||
) {
|
||||
checkPermissionService.checkReadOnlyUser();
|
||||
checkPermissionService.checkProjectOwner(request.getProjectId());
|
||||
return performanceTestService.save(request, files);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,6 @@ public class PerformanceTestController {
|
|||
@RequestPart("request") EditTestPlanRequest request,
|
||||
@RequestPart(value = "file", required = false) List<MultipartFile> files
|
||||
) {
|
||||
checkPermissionService.checkReadOnlyUser();
|
||||
checkPermissionService.checkPerformanceTestOwner(request.getId());
|
||||
return performanceTestService.edit(request, files);
|
||||
}
|
||||
|
@ -115,7 +114,6 @@ public class PerformanceTestController {
|
|||
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestBody DeleteTestPlanRequest request) {
|
||||
checkPermissionService.checkReadOnlyUser();
|
||||
checkPermissionService.checkPerformanceTestOwner(request.getId());
|
||||
performanceTestService.delete(request);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue