fix(接口测试): 修复SSL认证别名失效问题

This commit is contained in:
fit2-zhao 2021-12-17 19:33:19 +08:00 committed by fit2-zhao
parent 72fd7f8bd4
commit 04c3d46264
4 changed files with 26 additions and 20 deletions

View File

@ -12,7 +12,6 @@ import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.EnvironmentRequest; import io.metersphere.controller.request.EnvironmentRequest;
import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.CheckPermissionService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -26,13 +25,10 @@ public class ApiTestEnvironmentController {
@Resource @Resource
ApiTestEnvironmentService apiTestEnvironmentService; ApiTestEnvironmentService apiTestEnvironmentService;
@Resource @Resource
private CheckPermissionService checkPermissionService;
@Resource
private CommandService commandService; private CommandService commandService;
@GetMapping("/list/{projectId}") @GetMapping("/list/{projectId}")
public List<ApiTestEnvironmentWithBLOBs> list(@PathVariable String projectId) { public List<ApiTestEnvironmentWithBLOBs> list(@PathVariable String projectId) {
// checkPermissionService.checkProjectOwner(projectId);
return apiTestEnvironmentService.list(projectId); return apiTestEnvironmentService.list(projectId);
} }
@ -46,10 +42,6 @@ public class ApiTestEnvironmentController {
*/ */
@PostMapping("/list/{goPage}/{pageSize}") @PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<ApiTestEnvironmentWithBLOBs>> listByCondition(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody EnvironmentRequest environmentRequest) { public Pager<List<ApiTestEnvironmentWithBLOBs>> listByCondition(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody EnvironmentRequest environmentRequest) {
// List<String> projectIds = environmentRequest.getProjectIds();
// for (String projectId : projectIds) {
// checkPermissionService.checkProjectOwner(projectId);
// }
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, apiTestEnvironmentService.listByConditions(environmentRequest)); return PageUtils.setPageInfo(page, apiTestEnvironmentService.listByConditions(environmentRequest));
} }

View File

@ -551,6 +551,8 @@ public class MsHTTPSamplerProxy extends MsTestElement {
} }
if (StringUtils.isEmpty(this.alias)) { if (StringUtils.isEmpty(this.alias)) {
this.alias = sslConfig.getDefaultAlias(); this.alias = sslConfig.getDefaultAlias();
} else {
this.alias = sslConfig.getAlias(this.alias);
} }
if (StringUtils.isNotEmpty(this.alias)) { if (StringUtils.isNotEmpty(this.alias)) {

View File

@ -25,4 +25,14 @@ public class KeyStoreConfig {
} }
return null; return null;
} }
public String getAlias(String asName) {
if (CollectionUtils.isNotEmpty(entrys)) {
List<KeyStoreEntry> entryList = this.entrys.stream().filter(ks -> StringUtils.equals(asName, ks.getNewAsName())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(entryList) && CollectionUtils.isNotEmpty(files) && files.size() == 1) {
return entryList.get(0).getOriginalAsName();
}
}
return asName;
}
} }

View File

@ -22,18 +22,20 @@ public class ApiScenarioReportResultService {
private ApiScenarioReportResultMapper apiScenarioReportResultMapper; private ApiScenarioReportResultMapper apiScenarioReportResultMapper;
public void save(String reportId, List<RequestResult> queue) { public void save(String reportId, List<RequestResult> queue) {
queue.forEach(item -> { if (CollectionUtils.isNotEmpty(queue)) {
// 事物控制器出来的结果特殊处理 queue.forEach(item -> {
if (StringUtils.isNotEmpty(item.getName()) && item.getName().startsWith("Transaction=") && CollectionUtils.isEmpty(item.getSubRequestResults())) { // 事物控制器出来的结果特殊处理
LoggerUtil.debug("合并事物请求暂不入库"); if (StringUtils.isNotEmpty(item.getName()) && item.getName().startsWith("Transaction=") && CollectionUtils.isEmpty(item.getSubRequestResults())) {
} else if (StringUtils.isNotEmpty(item.getName()) && item.getName().startsWith("Transaction=") && CollectionUtils.isNotEmpty(item.getSubRequestResults())) { LoggerUtil.debug("合并事物请求暂不入库");
item.getSubRequestResults().forEach(subItem -> { } else if (StringUtils.isNotEmpty(item.getName()) && item.getName().startsWith("Transaction=") && CollectionUtils.isNotEmpty(item.getSubRequestResults())) {
apiScenarioReportResultMapper.insert(this.newApiScenarioReportResult(reportId, subItem)); item.getSubRequestResults().forEach(subItem -> {
}); apiScenarioReportResultMapper.insert(this.newApiScenarioReportResult(reportId, subItem));
} else { });
apiScenarioReportResultMapper.insert(this.newApiScenarioReportResult(reportId, item)); } else {
} apiScenarioReportResultMapper.insert(this.newApiScenarioReportResult(reportId, item));
}); }
});
}
} }
private ApiScenarioReportResult newApiScenarioReportResult(String reportId, RequestResult result) { private ApiScenarioReportResult newApiScenarioReportResult(String reportId, RequestResult result) {