fix(接口测试): 修复快捷调试端口丢失的缺陷

--bug=1028194 --user=王孝刚 【接口测试】github#25927,【接口测试】快捷调试接口会出现端口丢失问题
https://www.tapd.cn/55049933/s/1399277
This commit is contained in:
wxg0103 2023-07-31 16:08:28 +08:00 committed by 刘瑞斌
parent 8bcabecac9
commit 7382b2ea08
3 changed files with 11 additions and 7 deletions

View File

@ -103,7 +103,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
} else if (config.isOperating() && StringUtils.isNotEmpty(config.getOperatingSampleTestName())) {
this.setName(config.getOperatingSampleTestName());
}
if (this.getReferenced() != null && MsTestElementConstants.REF.name().equals(this.getReferenced())) {
boolean ref = this.setRefElement();
if (!ref) {
@ -405,11 +405,12 @@ public class MsHTTPSamplerProxy extends MsTestElement {
String envPath = "";
try {
URL urlObject = new URL(url);
if (url.contains("${")){
if (url.contains("${")) {
envPath = url;
} else {
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), StandardCharsets.UTF_8.name()));
envPath = urlObject.getPath();
sampler.setPort(urlObject.getPort());
}
sampler.setProtocol(urlObject.getProtocol());
} catch (Exception e) {
@ -482,7 +483,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
try {
URL urlObject = new URL(url);
String envPath;
if (url.contains("${")){
if (url.contains("${")) {
envPath = url;
} else {
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), StandardCharsets.UTF_8.name()));

View File

@ -95,7 +95,7 @@ public class MockConfigService {
public List<MockConfigImportDTO> selectMockExpectConfigByApiIdIn(List<String> apiIds) {
if (CollectionUtils.isNotEmpty(apiIds)) {
return extMockExpectConfigMapper.selectByApiIdIn(apiIds);
return extMockExpectConfigMapper.selectByApiIdIn(apiIds);
} else {
return new ArrayList<>();
}
@ -848,7 +848,7 @@ public class MockConfigService {
String urlSuffix = this.getUrlSuffix(project.getSystemId(), request);
LogUtil.info("Mock urlSuffix:{}", urlSuffix);
LogUtil.info("Mock requestHeaderMap:{}", requestHeaderMap);
LogUtil.info("Mock requestMockParams:{}", requestMockParams);
LogUtil.info("Mock requestMockParams:{}", JSON.toJSONString(requestMockParams));
List<ApiDefinitionWithBLOBs> qualifiedApiList = apiDefinitionService.preparedUrl(project.getId(), method, urlSuffix, requestHeaderMap.get(MockApiHeaders.MOCK_API_RESOURCE_ID));
for (ApiDefinitionWithBLOBs api : qualifiedApiList) {
if (StringUtils.isEmpty(returnStr)) {
@ -885,7 +885,7 @@ public class MockConfigService {
String urlSuffix = this.getUrlSuffix(project.getSystemId(), request);
LogUtil.info("Mock urlSuffix:{}", urlSuffix);
LogUtil.info("Mock requestHeaderMap:{}", requestHeaderMap);
LogUtil.info("Mock requestMockParams:{}", requestMockParams);
LogUtil.info("Mock requestMockParams:{}", JSON.toJSONString(requestMockParams));
List<ApiDefinitionWithBLOBs> qualifiedApiList = apiDefinitionService.preparedUrl(project.getId(), method, urlSuffix, requestHeaderMap.get(MockApiHeaders.MOCK_API_RESOURCE_ID));
/*
GET/DELETE 这种通过url穿参数的接口在接口路径相同的情况下可能会出现这样的情况

View File

@ -278,6 +278,9 @@ export default {
this.debugForm.path = url;
this.debugForm.url = url;
}
if (!this.debugForm.url.startsWith('http') && !this.debugForm.url.startsWith('https')) {
this.debugForm.url = 'http://' + this.debugForm.url;
}
},
getURL(urlStr) {
try {
@ -304,7 +307,7 @@ export default {
}
return url;
} catch (e) {
if (!urlStr.startsWith("http") || !urlStr.startsWith("https")) {
if (!urlStr.startsWith("http") && !urlStr.startsWith("https")) {
urlStr = "http://" + urlStr;
}
return urlStr;