fix(接口测试): 修复har文件导入时接口定义数据结构创建不完全的问题
--bug=1046522 --user=宋天阳 【接口测试】导入HAR格式接口-新增接口成功-编辑导入接口-保存无反应 https://www.tapd.cn/55049933/s/1579539
This commit is contained in:
parent
b9997f8356
commit
0b6a10e9a3
|
@ -242,7 +242,7 @@ public class HarParserApiDefinition extends HttpApiDefinitionImportAbstractParse
|
||||||
HarRequest harRequest = entry.request;
|
HarRequest harRequest = entry.request;
|
||||||
if (harRequest != null) {
|
if (harRequest != null) {
|
||||||
// css 、 js 略过
|
// css 、 js 略过
|
||||||
if (StringUtils.equalsIgnoreCase(harRequest.method, HttpMethodConstants.GET.name()) && StringUtils.endsWithAny(harRequest.url, ".css", ".js")) {
|
if (StringUtils.equalsIgnoreCase(harRequest.method, HttpMethodConstants.GET.name()) && StringUtils.endsWithAny(harRequest.url.toLowerCase(), ".css", ".js", ".png", ".jpg", ".jpeg")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String url = harRequest.url;
|
String url = harRequest.url;
|
||||||
|
|
|
@ -7,10 +7,12 @@ import io.metersphere.api.dto.converter.ApiImportFileParseResult;
|
||||||
import io.metersphere.api.dto.definition.ApiDefinitionMockDTO;
|
import io.metersphere.api.dto.definition.ApiDefinitionMockDTO;
|
||||||
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
|
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
|
||||||
import io.metersphere.api.dto.request.ImportRequest;
|
import io.metersphere.api.dto.request.ImportRequest;
|
||||||
|
import io.metersphere.api.dto.request.MsCommonElement;
|
||||||
import io.metersphere.api.dto.request.http.MsHTTPConfig;
|
import io.metersphere.api.dto.request.http.MsHTTPConfig;
|
||||||
import io.metersphere.api.dto.request.http.MsHTTPElement;
|
import io.metersphere.api.dto.request.http.MsHTTPElement;
|
||||||
import io.metersphere.api.dto.request.http.body.*;
|
import io.metersphere.api.dto.request.http.body.*;
|
||||||
import io.metersphere.api.parser.ApiDefinitionImportParser;
|
import io.metersphere.api.parser.ApiDefinitionImportParser;
|
||||||
|
import io.metersphere.plugin.api.spi.AbstractMsTestElement;
|
||||||
import io.metersphere.project.dto.environment.auth.NoAuth;
|
import io.metersphere.project.dto.environment.auth.NoAuth;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
|
@ -24,6 +26,7 @@ import java.io.InputStreamReader;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -109,6 +112,7 @@ public abstract class HttpApiDefinitionImportAbstractParser<T> implements ApiDef
|
||||||
httpConfig.setResponseTimeout(60000L);
|
httpConfig.setResponseTimeout(60000L);
|
||||||
request.setOtherConfig(httpConfig);
|
request.setOtherConfig(httpConfig);
|
||||||
request.setAuthConfig(new NoAuth());
|
request.setAuthConfig(new NoAuth());
|
||||||
|
// assertionConfig
|
||||||
Body body = new Body();
|
Body body = new Body();
|
||||||
body.setBinaryBody(new BinaryBody());
|
body.setBinaryBody(new BinaryBody());
|
||||||
body.setFormDataBody(new FormDataBody());
|
body.setFormDataBody(new FormDataBody());
|
||||||
|
@ -120,6 +124,12 @@ public abstract class HttpApiDefinitionImportAbstractParser<T> implements ApiDef
|
||||||
body.setNoneBody(new NoneBody());
|
body.setNoneBody(new NoneBody());
|
||||||
body.setBodyType(Body.BodyType.NONE.name());
|
body.setBodyType(Body.BodyType.NONE.name());
|
||||||
request.setBody(body);
|
request.setBody(body);
|
||||||
|
|
||||||
|
MsCommonElement commonElement = new MsCommonElement();
|
||||||
|
LinkedList<AbstractMsTestElement> children = new LinkedList<>();
|
||||||
|
children.add(commonElement);
|
||||||
|
request.setChildren(children);
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -680,6 +680,12 @@ public class ApiDefinitionImportService {
|
||||||
this.updateApiDefinitionRequest(importApi, msProtocolTestElement, request.getPlatform());
|
this.updateApiDefinitionRequest(importApi, msProtocolTestElement, request.getPlatform());
|
||||||
apiDefinitionPreImportAnalysisResult.getUpdateApiData().add(importApi);
|
apiDefinitionPreImportAnalysisResult.getUpdateApiData().add(importApi);
|
||||||
}
|
}
|
||||||
|
} else if (!StringUtils.equalsIgnoreCase(importApi.getProtocol(), "HTTP")) {
|
||||||
|
/*
|
||||||
|
非http的要进行更新,例如tcp最重要的是请求内容,不更新的话就会导致导入的内容丢失
|
||||||
|
而http判断是否一致主要还是请求里的key,不是value。只要key还不变就没关系
|
||||||
|
*/
|
||||||
|
apiDefinitionPreImportAnalysisResult.getUpdateApiData().add(importApi);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isSameApi) {
|
if (!isSameApi) {
|
||||||
|
|
Loading…
Reference in New Issue