fix(接口测试): 环境配置host不生效

This commit is contained in:
AgAngle 2024-04-08 11:30:29 +08:00 committed by 刘瑞斌
parent fd5ad458be
commit b262b60c2c
1 changed files with 8 additions and 2 deletions

View File

@ -474,8 +474,13 @@ public class MsHTTPElementConverter extends AbstractJmeterElementConverter<MsHTT
return null; return null;
} }
String domain = httpConfig.getHostname().trim(); String domain = httpConfig.getHostname().trim();
int index = domain.indexOf(":");
if (index > -1) {
domain = domain.substring(0, index);
}
List<Host> hosts = new ArrayList<>(); List<Host> hosts = new ArrayList<>();
envConfig.getConfig().getHostConfig().getHosts().forEach(host -> { for (Host host : envConfig.getConfig().getHostConfig().getHosts()) {
if (StringUtils.isNotBlank(host.getDomain())) { if (StringUtils.isNotBlank(host.getDomain())) {
String hostDomain = host.getDomain().trim().replace(HTTP, StringUtils.EMPTY).replace(HTTPS, StringUtils.EMPTY); String hostDomain = host.getDomain().trim().replace(HTTP, StringUtils.EMPTY).replace(HTTPS, StringUtils.EMPTY);
if (StringUtils.equals(hostDomain, domain)) { if (StringUtils.equals(hostDomain, domain)) {
@ -483,7 +488,8 @@ public class MsHTTPElementConverter extends AbstractJmeterElementConverter<MsHTT
hosts.add(host); hosts.add(host);
} }
} }
}); }
if (CollectionUtils.isNotEmpty(hosts)) { if (CollectionUtils.isNotEmpty(hosts)) {
return dnsCacheManager(name + "DNSCacheManager", hosts); return dnsCacheManager(name + "DNSCacheManager", hosts);
} }