fix(接口测试): 修复JSON对象格式化内容包含@type报错问题
--bug=1012064 --user=赵勇 [接口测试]github#124031.19.2,已复测,post请求,请求体json类型,当属性名称为@type,值为正常的字符串,保存出现 http 500 https://www.tapd.cn/55049933/s/1132448
This commit is contained in:
parent
80553d5eb4
commit
db866363e3
|
@ -137,7 +137,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.72</version>
|
<version>1.2.80</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- openapi -->
|
<!-- openapi -->
|
||||||
|
|
|
@ -3,6 +3,7 @@ package io.metersphere.api.dto.automation.parse;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import io.metersphere.api.dto.automation.ApiScenarioModuleDTO;
|
import io.metersphere.api.dto.automation.ApiScenarioModuleDTO;
|
||||||
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
||||||
import io.metersphere.api.dto.definition.parse.ms.NodeTree;
|
import io.metersphere.api.dto.definition.parse.ms.NodeTree;
|
||||||
|
@ -13,7 +14,10 @@ import io.metersphere.api.parse.ApiImportAbstractParser;
|
||||||
import io.metersphere.api.service.ApiDefinitionService;
|
import io.metersphere.api.service.ApiDefinitionService;
|
||||||
import io.metersphere.api.service.ApiScenarioModuleService;
|
import io.metersphere.api.service.ApiScenarioModuleService;
|
||||||
import io.metersphere.api.service.ApiTestCaseService;
|
import io.metersphere.api.service.ApiTestCaseService;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.ApiDefinition;
|
||||||
|
import io.metersphere.base.domain.ApiDefinitionExample;
|
||||||
|
import io.metersphere.base.domain.ApiScenarioModule;
|
||||||
|
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||||
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
||||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
||||||
import io.metersphere.commons.constants.APITestStatus;
|
import io.metersphere.commons.constants.APITestStatus;
|
||||||
|
@ -22,7 +26,6 @@ import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.service.CheckPermissionService;
|
import io.metersphere.service.CheckPermissionService;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
@ -208,7 +211,7 @@ public class ApiScenarioImportUtil {
|
||||||
object.put("projectId", projectId);
|
object.put("projectId", projectId);
|
||||||
object.put("useEnvironment","");
|
object.put("useEnvironment","");
|
||||||
object.put("url","");
|
object.put("url","");
|
||||||
JSONObject objectNew = JSONObject.parseObject(object.toJSONString());
|
JSONObject objectNew = JSONObject.parseObject(object.toJSONString(), Feature.DisableSpecialKeyDetect);
|
||||||
objectNew.remove("refType");
|
objectNew.remove("refType");
|
||||||
objectNew.remove("referenced");
|
objectNew.remove("referenced");
|
||||||
test.setRequest(objectNew.toJSONString());
|
test.setRequest(objectNew.toJSONString());
|
||||||
|
@ -249,7 +252,7 @@ public class ApiScenarioImportUtil {
|
||||||
object.put("resourceId", apiTestCase.getId());
|
object.put("resourceId", apiTestCase.getId());
|
||||||
object.put("projectId", projectId);
|
object.put("projectId", projectId);
|
||||||
object.put("useEnvironment","");
|
object.put("useEnvironment","");
|
||||||
JSONObject objectNew = JSONObject.parseObject(object.toJSONString());
|
JSONObject objectNew = JSONObject.parseObject(object.toJSONString(),Feature.DisableSpecialKeyDetect);
|
||||||
objectNew.remove("refType");
|
objectNew.remove("refType");
|
||||||
objectNew.remove("referenced");
|
objectNew.remove("referenced");
|
||||||
apiTestCase.setRequest(objectNew.toJSONString());
|
apiTestCase.setRequest(objectNew.toJSONString());
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class MsScenarioParser extends MsAbstractParser<ScenarioImport> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScenarioImport parseMsFormat(String testStr, ApiTestImportRequest importRequest) {
|
private ScenarioImport parseMsFormat(String testStr, ApiTestImportRequest importRequest) {
|
||||||
ScenarioImport scenarioImport = JSON.parseObject(testStr, ScenarioImport.class);
|
ScenarioImport scenarioImport = JSON.parseObject(testStr, ScenarioImport.class,Feature.DisableSpecialKeyDetect);
|
||||||
List<ApiScenarioWithBLOBs> data = scenarioImport.getData();
|
List<ApiScenarioWithBLOBs> data = scenarioImport.getData();
|
||||||
|
|
||||||
Set<String> moduleIdSet = scenarioImport.getData().stream()
|
Set<String> moduleIdSet = scenarioImport.getData().stream()
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class MsDefinitionParser extends MsAbstractParser<ApiDefinitionImport> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiDefinitionImport parseMsFormat(String testStr, ApiTestImportRequest importRequest) {
|
private ApiDefinitionImport parseMsFormat(String testStr, ApiTestImportRequest importRequest) {
|
||||||
ApiDefinitionImport apiDefinitionImport = JSON.parseObject(testStr, ApiDefinitionImport.class);
|
ApiDefinitionImport apiDefinitionImport = JSON.parseObject(testStr, ApiDefinitionImport.class,Feature.DisableSpecialKeyDetect);
|
||||||
|
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> caseMap = new HashMap<>();
|
Map<String, List<ApiTestCaseWithBLOBs>> caseMap = new HashMap<>();
|
||||||
if (apiDefinitionImport.getCases() != null) {
|
if (apiDefinitionImport.getCases() != null) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.metersphere.api.dto.definition.parse;
|
package io.metersphere.api.dto.definition.parse;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import io.metersphere.api.dto.ApiTestImportRequest;
|
import io.metersphere.api.dto.ApiTestImportRequest;
|
||||||
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
||||||
import io.metersphere.api.dto.parse.postman.PostmanCollection;
|
import io.metersphere.api.dto.parse.postman.PostmanCollection;
|
||||||
|
@ -9,15 +10,15 @@ import io.metersphere.api.dto.parse.postman.PostmanKeyValue;
|
||||||
import io.metersphere.api.parse.PostmanAbstractParserParser;
|
import io.metersphere.api.parse.PostmanAbstractParserParser;
|
||||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||||
import io.metersphere.base.domain.ApiModule;
|
import io.metersphere.base.domain.ApiModule;
|
||||||
import io.metersphere.commons.constants.ProjectApplicationType;
|
|
||||||
import io.metersphere.dto.ProjectConfig;
|
|
||||||
import io.metersphere.service.ProjectApplicationService;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||||
import io.metersphere.base.domain.Project;
|
import io.metersphere.base.domain.Project;
|
||||||
import io.metersphere.base.mapper.ProjectMapper;
|
import io.metersphere.base.mapper.ProjectMapper;
|
||||||
|
import io.metersphere.commons.constants.ProjectApplicationType;
|
||||||
import io.metersphere.commons.utils.BeanUtils;
|
import io.metersphere.commons.utils.BeanUtils;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
|
import io.metersphere.dto.ProjectConfig;
|
||||||
|
import io.metersphere.service.ProjectApplicationService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -32,7 +33,7 @@ public class PostmanDefinitionParser extends PostmanAbstractParserParser<ApiDefi
|
||||||
public ApiDefinitionImport parse(InputStream source, ApiTestImportRequest request) {
|
public ApiDefinitionImport parse(InputStream source, ApiTestImportRequest request) {
|
||||||
String testStr = getApiTestStr(source);
|
String testStr = getApiTestStr(source);
|
||||||
this.projectId = request.getProjectId();
|
this.projectId = request.getProjectId();
|
||||||
PostmanCollection postmanCollection = JSON.parseObject(testStr, PostmanCollection.class);
|
PostmanCollection postmanCollection = JSON.parseObject(testStr, PostmanCollection.class, Feature.DisableSpecialKeyDetect);
|
||||||
List<PostmanKeyValue> variables = postmanCollection.getVariable();
|
List<PostmanKeyValue> variables = postmanCollection.getVariable();
|
||||||
ApiDefinitionImport apiImport = new ApiDefinitionImport();
|
ApiDefinitionImport apiImport = new ApiDefinitionImport();
|
||||||
List<ApiDefinitionWithBLOBs> results = new ArrayList<>();
|
List<ApiDefinitionWithBLOBs> results = new ArrayList<>();
|
||||||
|
|
|
@ -3,10 +3,13 @@ package io.metersphere.api.dto.definition.parse;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import io.metersphere.api.dto.ApiTestImportRequest;
|
import io.metersphere.api.dto.ApiTestImportRequest;
|
||||||
import io.metersphere.api.dto.definition.ApiModuleDTO;
|
import io.metersphere.api.dto.definition.ApiModuleDTO;
|
||||||
import io.metersphere.api.dto.definition.SwaggerApiExportResult;
|
import io.metersphere.api.dto.definition.SwaggerApiExportResult;
|
||||||
import io.metersphere.api.dto.definition.parse.swagger.*;
|
import io.metersphere.api.dto.definition.parse.swagger.SwaggerApiInfo;
|
||||||
|
import io.metersphere.api.dto.definition.parse.swagger.SwaggerInfo;
|
||||||
|
import io.metersphere.api.dto.definition.parse.swagger.SwaggerParams;
|
||||||
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
||||||
import io.metersphere.api.dto.definition.request.variable.JsonSchemaItem;
|
import io.metersphere.api.dto.definition.request.variable.JsonSchemaItem;
|
||||||
import io.metersphere.api.dto.definition.response.HttpResponse;
|
import io.metersphere.api.dto.definition.response.HttpResponse;
|
||||||
|
@ -33,6 +36,7 @@ import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -594,17 +598,17 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
}
|
}
|
||||||
swaggerApiInfo.setTags(Arrays.asList(moduleName));
|
swaggerApiInfo.setTags(Arrays.asList(moduleName));
|
||||||
// 设置请求体
|
// 设置请求体
|
||||||
JSONObject requestObject = JSON.parseObject(apiDefinition.getRequest()); // 将api的request属性转换成JSON对象以便获得参数
|
JSONObject requestObject = JSON.parseObject(apiDefinition.getRequest(), Feature.DisableSpecialKeyDetect); // 将api的request属性转换成JSON对象以便获得参数
|
||||||
JSONObject requestBody = buildRequestBody(requestObject);
|
JSONObject requestBody = buildRequestBody(requestObject);
|
||||||
swaggerApiInfo.setRequestBody(requestBody);
|
swaggerApiInfo.setRequestBody(requestBody);
|
||||||
// 设置响应体
|
// 设置响应体
|
||||||
JSONObject responseObject = JSON.parseObject(apiDefinition.getResponse());
|
JSONObject responseObject = JSON.parseObject(apiDefinition.getResponse(),Feature.DisableSpecialKeyDetect);
|
||||||
swaggerApiInfo.setResponses(buildResponseBody(responseObject));
|
swaggerApiInfo.setResponses(buildResponseBody(responseObject));
|
||||||
// 设置请求参数列表
|
// 设置请求参数列表
|
||||||
List<JSONObject> paramsList = buildParameters(requestObject);
|
List<JSONObject> paramsList = buildParameters(requestObject);
|
||||||
swaggerApiInfo.setParameters(paramsList);
|
swaggerApiInfo.setParameters(paramsList);
|
||||||
swaggerApiInfo.setDescription(apiDefinition.getDescription());
|
swaggerApiInfo.setDescription(apiDefinition.getDescription());
|
||||||
JSONObject methodDetail = JSON.parseObject(JSON.toJSONString(swaggerApiInfo));
|
JSONObject methodDetail = JSON.parseObject(JSON.toJSONString(swaggerApiInfo),Feature.DisableSpecialKeyDetect);
|
||||||
if (paths.getJSONObject(apiDefinition.getPath()) == null) {
|
if (paths.getJSONObject(apiDefinition.getPath()) == null) {
|
||||||
paths.put(apiDefinition.getPath(), new JSONObject());
|
paths.put(apiDefinition.getPath(), new JSONObject());
|
||||||
} // 一个路径下有多个发方法,如post,get,因此是一个 JSONObject 类型
|
} // 一个路径下有多个发方法,如post,get,因此是一个 JSONObject 类型
|
||||||
|
|
|
@ -3,6 +3,7 @@ package io.metersphere.api.dto.definition.request;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -302,7 +303,7 @@ public class ElementUtil {
|
||||||
}
|
}
|
||||||
if (element.get("clazzName") == null && element.getString("type").equals("TCPSampler")) {
|
if (element.get("clazzName") == null && element.getString("type").equals("TCPSampler")) {
|
||||||
if (element.getString("tcpPreProcessor") != null) {
|
if (element.getString("tcpPreProcessor") != null) {
|
||||||
JSONObject tcpPreProcessor = JSON.parseObject(element.getString("tcpPreProcessor"));
|
JSONObject tcpPreProcessor = JSON.parseObject(element.getString("tcpPreProcessor"), Feature.DisableSpecialKeyDetect);
|
||||||
if (tcpPreProcessor != null && tcpPreProcessor.get("clazzName") == null) {
|
if (tcpPreProcessor != null && tcpPreProcessor.get("clazzName") == null) {
|
||||||
tcpPreProcessor.fluentPut("clazzName", clazzMap.get(tcpPreProcessor.getString("type")));
|
tcpPreProcessor.fluentPut("clazzName", clazzMap.get(tcpPreProcessor.getString("type")));
|
||||||
element.fluentPut("tcpPreProcessor", tcpPreProcessor);
|
element.fluentPut("tcpPreProcessor", tcpPreProcessor);
|
||||||
|
@ -310,7 +311,7 @@ public class ElementUtil {
|
||||||
}
|
}
|
||||||
} else if (element.getString("type").equals("HTTPSamplerProxy")) {
|
} else if (element.getString("type").equals("HTTPSamplerProxy")) {
|
||||||
if (element.getString("authManager") != null) {
|
if (element.getString("authManager") != null) {
|
||||||
JSONObject authManager = JSON.parseObject(element.getString("authManager"));
|
JSONObject authManager = JSON.parseObject(element.getString("authManager"),Feature.DisableSpecialKeyDetect);
|
||||||
if (authManager != null && authManager.get("clazzName") == null) {
|
if (authManager != null && authManager.get("clazzName") == null) {
|
||||||
authManager.fluentPut("clazzName", clazzMap.get(authManager.getString("type")));
|
authManager.fluentPut("clazzName", clazzMap.get(authManager.getString("type")));
|
||||||
element.fluentPut("authManager", authManager);
|
element.fluentPut("authManager", authManager);
|
||||||
|
@ -388,7 +389,7 @@ public class ElementUtil {
|
||||||
if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())) {
|
if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())) {
|
||||||
environmentMap = environmentGroupProjectService.getEnvMap(environmentGroupId);
|
environmentMap = environmentGroupProjectService.getEnvMap(environmentGroupId);
|
||||||
} else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) {
|
} else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) {
|
||||||
environmentMap = JSON.parseObject(environmentJson, Map.class);
|
environmentMap = JSON.parseObject(environmentJson, Map.class,Feature.DisableSpecialKeyDetect);
|
||||||
}
|
}
|
||||||
Map<String, EnvironmentConfig> envConfig = new HashMap<>(16);
|
Map<String, EnvironmentConfig> envConfig = new HashMap<>(16);
|
||||||
if (environmentMap != null && !environmentMap.isEmpty()) {
|
if (environmentMap != null && !environmentMap.isEmpty()) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -216,7 +217,7 @@ public class MsScenario extends MsTestElement {
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
ApiScenarioWithBLOBs scenario = apiAutomationService.selectByPrimaryKey(this.getId());
|
ApiScenarioWithBLOBs scenario = apiAutomationService.selectByPrimaryKey(this.getId());
|
||||||
if (scenario != null && StringUtils.isNotEmpty(scenario.getScenarioDefinition())) {
|
if (scenario != null && StringUtils.isNotEmpty(scenario.getScenarioDefinition())) {
|
||||||
JSONObject element = JSON.parseObject(scenario.getScenarioDefinition());
|
JSONObject element = JSON.parseObject(scenario.getScenarioDefinition(), Feature.DisableSpecialKeyDetect);
|
||||||
// 历史数据处理
|
// 历史数据处理
|
||||||
ElementUtil.dataFormatting(element.getJSONArray("hashTree"));
|
ElementUtil.dataFormatting(element.getJSONArray("hashTree"));
|
||||||
this.setName(scenario.getName());
|
this.setName(scenario.getName());
|
||||||
|
@ -260,7 +261,7 @@ public class MsScenario extends MsTestElement {
|
||||||
if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())) {
|
if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())) {
|
||||||
this.environmentMap = environmentGroupProjectService.getEnvMap(environmentGroupId);
|
this.environmentMap = environmentGroupProjectService.getEnvMap(environmentGroupId);
|
||||||
} else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) {
|
} else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) {
|
||||||
this.environmentMap = JSON.parseObject(environmentJson, Map.class);
|
this.environmentMap = JSON.parseObject(environmentJson, Map.class,Feature.DisableSpecialKeyDetect);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.setEnvironmentEnable(false);
|
this.setEnvironmentEnable(false);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -182,7 +183,7 @@ public class MsJDBCPostProcessor extends MsTestElement {
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
this.setName(bloBs.getName());
|
this.setName(bloBs.getName());
|
||||||
this.setProjectId(bloBs.getProjectId());
|
this.setProjectId(bloBs.getProjectId());
|
||||||
JSONObject element = JSON.parseObject(bloBs.getRequest());
|
JSONObject element = JSON.parseObject(bloBs.getRequest(), Feature.DisableSpecialKeyDetect);
|
||||||
ElementUtil.dataFormatting(element);
|
ElementUtil.dataFormatting(element);
|
||||||
proxy = mapper.readValue(element.toJSONString(), new TypeReference<MsJDBCPostProcessor>() {
|
proxy = mapper.readValue(element.toJSONString(), new TypeReference<MsJDBCPostProcessor>() {
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -182,7 +183,7 @@ public class MsJDBCPreProcessor extends MsTestElement {
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
this.setName(bloBs.getName());
|
this.setName(bloBs.getName());
|
||||||
this.setProjectId(bloBs.getProjectId());
|
this.setProjectId(bloBs.getProjectId());
|
||||||
JSONObject element = JSON.parseObject(bloBs.getRequest());
|
JSONObject element = JSON.parseObject(bloBs.getRequest(), Feature.DisableSpecialKeyDetect);
|
||||||
ElementUtil.dataFormatting(element);
|
ElementUtil.dataFormatting(element);
|
||||||
proxy = mapper.readValue(element.toJSONString(), new TypeReference<MsJDBCPreProcessor>() {
|
proxy = mapper.readValue(element.toJSONString(), new TypeReference<MsJDBCPreProcessor>() {
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
@ -116,7 +117,7 @@ public class MsDubboSampler extends MsTestElement {
|
||||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
this.setProjectId(bloBs.getProjectId());
|
this.setProjectId(bloBs.getProjectId());
|
||||||
JSONObject element = JSON.parseObject(bloBs.getRequest());
|
JSONObject element = JSON.parseObject(bloBs.getRequest(), Feature.DisableSpecialKeyDetect);
|
||||||
ElementUtil.dataFormatting(element);
|
ElementUtil.dataFormatting(element);
|
||||||
proxy = mapper.readValue(element.toJSONString(), new TypeReference<MsDubboSampler>() {
|
proxy = mapper.readValue(element.toJSONString(), new TypeReference<MsDubboSampler>() {
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -289,7 +290,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
ApiTestCaseWithBLOBs bloBs = CommonBeanFactory.getBean(ApiTestCaseService.class).get(this.getId());
|
ApiTestCaseWithBLOBs bloBs = CommonBeanFactory.getBean(ApiTestCaseService.class).get(this.getId());
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
this.setProjectId(bloBs.getProjectId());
|
this.setProjectId(bloBs.getProjectId());
|
||||||
JSONObject element = JSON.parseObject(bloBs.getRequest());
|
JSONObject element = JSON.parseObject(bloBs.getRequest(), Feature.DisableSpecialKeyDetect);
|
||||||
ElementUtil.dataFormatting(element);
|
ElementUtil.dataFormatting(element);
|
||||||
proxy = mapper.readValue(element.toJSONString(), new TypeReference<MsHTTPSamplerProxy>() {
|
proxy = mapper.readValue(element.toJSONString(), new TypeReference<MsHTTPSamplerProxy>() {
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -240,7 +241,7 @@ public class MsJDBCSampler extends MsTestElement {
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
this.setName(bloBs.getName());
|
this.setName(bloBs.getName());
|
||||||
this.setProjectId(bloBs.getProjectId());
|
this.setProjectId(bloBs.getProjectId());
|
||||||
JSONObject element = JSON.parseObject(bloBs.getRequest());
|
JSONObject element = JSON.parseObject(bloBs.getRequest(), Feature.DisableSpecialKeyDetect);
|
||||||
ElementUtil.dataFormatting(element);
|
ElementUtil.dataFormatting(element);
|
||||||
proxy = mapper.readValue(element.toJSONString(), new TypeReference<MsJDBCSampler>() {
|
proxy = mapper.readValue(element.toJSONString(), new TypeReference<MsJDBCSampler>() {
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -195,7 +196,7 @@ public class MsTCPSampler extends MsTestElement {
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
this.setName(bloBs.getName());
|
this.setName(bloBs.getName());
|
||||||
this.setProjectId(bloBs.getProjectId());
|
this.setProjectId(bloBs.getProjectId());
|
||||||
JSONObject element = JSON.parseObject(bloBs.getRequest());
|
JSONObject element = JSON.parseObject(bloBs.getRequest(), Feature.DisableSpecialKeyDetect);
|
||||||
ElementUtil.dataFormatting(element);
|
ElementUtil.dataFormatting(element);
|
||||||
proxy = mapper.readValue(element.toJSONString(), new TypeReference<MsTCPSampler>() {
|
proxy = mapper.readValue(element.toJSONString(), new TypeReference<MsTCPSampler>() {
|
||||||
});
|
});
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class Body {
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isNotEmpty(this.getRaw())) {
|
if (StringUtils.isNotEmpty(this.getRaw())) {
|
||||||
JSONObject jsonObject = JSON.parseObject(this.getRaw(), Feature.OrderedField);
|
JSONObject jsonObject = JSON.parseObject(this.getRaw(), Feature.OrderedField,Feature.DisableSpecialKeyDetect);
|
||||||
if (!this.getRaw().contains("$ref")) {
|
if (!this.getRaw().contains("$ref")) {
|
||||||
jsonMockParse(jsonObject);
|
jsonMockParse(jsonObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.exec.api;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.metersphere.api.dto.definition.RunCaseRequest;
|
import io.metersphere.api.dto.definition.RunCaseRequest;
|
||||||
|
@ -192,7 +193,7 @@ public class ApiExecuteService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashTree generateHashTree(RunCaseRequest request, ApiTestCaseWithBLOBs testCaseWithBLOBs) throws Exception {
|
public HashTree generateHashTree(RunCaseRequest request, ApiTestCaseWithBLOBs testCaseWithBLOBs) throws Exception {
|
||||||
JSONObject elementObj = JSON.parseObject(testCaseWithBLOBs.getRequest());
|
JSONObject elementObj = JSON.parseObject(testCaseWithBLOBs.getRequest(), Feature.DisableSpecialKeyDetect);
|
||||||
ElementUtil.dataFormatting(elementObj);
|
ElementUtil.dataFormatting(elementObj);
|
||||||
|
|
||||||
MsTestElement element = mapper.readValue(elementObj.toJSONString(), new TypeReference<MsTestElement>() {
|
MsTestElement element = mapper.readValue(elementObj.toJSONString(), new TypeReference<MsTestElement>() {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.exec.scenario;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -177,7 +178,7 @@ public class ApiScenarioEnvService {
|
||||||
if (apiScenario != null) {
|
if (apiScenario != null) {
|
||||||
env.getProjectIds().add(apiScenario.getProjectId());
|
env.getProjectIds().add(apiScenario.getProjectId());
|
||||||
String scenarioDefinition = apiScenario.getScenarioDefinition();
|
String scenarioDefinition = apiScenario.getScenarioDefinition();
|
||||||
JSONObject element1 = JSON.parseObject(scenarioDefinition);
|
JSONObject element1 = JSON.parseObject(scenarioDefinition, Feature.DisableSpecialKeyDetect);
|
||||||
ElementUtil.dataFormatting(element1);
|
ElementUtil.dataFormatting(element1);
|
||||||
LinkedList<MsTestElement> hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>() {
|
LinkedList<MsTestElement> hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>() {
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.exec.scenario;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.metersphere.api.dto.definition.request.ElementUtil;
|
import io.metersphere.api.dto.definition.request.ElementUtil;
|
||||||
|
@ -194,7 +195,7 @@ public class ApiScenarioSerialService {
|
||||||
private MsTestElement parse(ApiTestCaseWithBLOBs caseWithBLOBs, String planId, String envId) {
|
private MsTestElement parse(ApiTestCaseWithBLOBs caseWithBLOBs, String planId, String envId) {
|
||||||
try {
|
try {
|
||||||
String api = caseWithBLOBs.getRequest();
|
String api = caseWithBLOBs.getRequest();
|
||||||
JSONObject element = JSON.parseObject(api);
|
JSONObject element = JSON.parseObject(api, Feature.DisableSpecialKeyDetect);
|
||||||
ElementUtil.dataFormatting(element);
|
ElementUtil.dataFormatting(element);
|
||||||
|
|
||||||
LinkedList<MsTestElement> list = new LinkedList<>();
|
LinkedList<MsTestElement> list = new LinkedList<>();
|
||||||
|
@ -205,7 +206,7 @@ public class ApiScenarioSerialService {
|
||||||
list.addAll(elements);
|
list.addAll(elements);
|
||||||
}
|
}
|
||||||
if (element.getString("type").equals("HTTPSamplerProxy")) {
|
if (element.getString("type").equals("HTTPSamplerProxy")) {
|
||||||
MsHTTPSamplerProxy httpSamplerProxy = JSON.parseObject(api, MsHTTPSamplerProxy.class);
|
MsHTTPSamplerProxy httpSamplerProxy = JSON.parseObject(api, MsHTTPSamplerProxy.class,Feature.DisableSpecialKeyDetect);
|
||||||
httpSamplerProxy.setHashTree(list);
|
httpSamplerProxy.setHashTree(list);
|
||||||
httpSamplerProxy.setName(planId);
|
httpSamplerProxy.setName(planId);
|
||||||
if (StringUtils.isNotEmpty(envId)) {
|
if (StringUtils.isNotEmpty(envId)) {
|
||||||
|
@ -214,7 +215,7 @@ public class ApiScenarioSerialService {
|
||||||
return httpSamplerProxy;
|
return httpSamplerProxy;
|
||||||
}
|
}
|
||||||
if (element.getString("type").equals("TCPSampler")) {
|
if (element.getString("type").equals("TCPSampler")) {
|
||||||
MsTCPSampler msTCPSampler = JSON.parseObject(api, MsTCPSampler.class);
|
MsTCPSampler msTCPSampler = JSON.parseObject(api, MsTCPSampler.class,Feature.DisableSpecialKeyDetect);
|
||||||
if (StringUtils.isNotEmpty(envId)) {
|
if (StringUtils.isNotEmpty(envId)) {
|
||||||
msTCPSampler.setUseEnvironment(envId);
|
msTCPSampler.setUseEnvironment(envId);
|
||||||
}
|
}
|
||||||
|
@ -223,7 +224,7 @@ public class ApiScenarioSerialService {
|
||||||
return msTCPSampler;
|
return msTCPSampler;
|
||||||
}
|
}
|
||||||
if (element.getString("type").equals("DubboSampler")) {
|
if (element.getString("type").equals("DubboSampler")) {
|
||||||
MsDubboSampler dubboSampler = JSON.parseObject(api, MsDubboSampler.class);
|
MsDubboSampler dubboSampler = JSON.parseObject(api, MsDubboSampler.class,Feature.DisableSpecialKeyDetect);
|
||||||
if (StringUtils.isNotEmpty(envId)) {
|
if (StringUtils.isNotEmpty(envId)) {
|
||||||
dubboSampler.setUseEnvironment(envId);
|
dubboSampler.setUseEnvironment(envId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.exec.utils;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
@ -38,7 +39,7 @@ public class GenerateHashTreeUtil {
|
||||||
|
|
||||||
public static MsScenario parseScenarioDefinition(String scenarioDefinition) {
|
public static MsScenario parseScenarioDefinition(String scenarioDefinition) {
|
||||||
if (StringUtils.isNotEmpty(scenarioDefinition)) {
|
if (StringUtils.isNotEmpty(scenarioDefinition)) {
|
||||||
MsScenario scenario = JSONObject.parseObject(scenarioDefinition, MsScenario.class);
|
MsScenario scenario = JSONObject.parseObject(scenarioDefinition, MsScenario.class, Feature.DisableSpecialKeyDetect);
|
||||||
if (scenario != null) {
|
if (scenario != null) {
|
||||||
parse(scenarioDefinition, scenario);
|
parse(scenarioDefinition, scenario);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +52,7 @@ public class GenerateHashTreeUtil {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
try {
|
try {
|
||||||
JSONObject element = JSON.parseObject(scenarioDefinition);
|
JSONObject element = JSON.parseObject(scenarioDefinition, Feature.DisableSpecialKeyDetect);
|
||||||
ElementUtil.dataFormatting(element);
|
ElementUtil.dataFormatting(element);
|
||||||
// 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取
|
// 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取
|
||||||
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
|
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
|
||||||
|
@ -74,7 +75,7 @@ public class GenerateHashTreeUtil {
|
||||||
public static LinkedList<MsTestElement> getScenarioHashTree(String definition) {
|
public static LinkedList<MsTestElement> getScenarioHashTree(String definition) {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
JSONObject element = JSON.parseObject(definition);
|
JSONObject element = JSON.parseObject(definition, Feature.DisableSpecialKeyDetect);
|
||||||
try {
|
try {
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
ElementUtil.dataFormatting(element);
|
ElementUtil.dataFormatting(element);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.jmeter;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import io.metersphere.commons.constants.DelimiterConstants;
|
import io.metersphere.commons.constants.DelimiterConstants;
|
||||||
import io.metersphere.dto.RequestResult;
|
import io.metersphere.dto.RequestResult;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -135,7 +136,7 @@ public class TestResult {
|
||||||
String itemAndScenarioName = "";
|
String itemAndScenarioName = "";
|
||||||
if (StringUtils.isNotEmpty(item.getScenario())) {
|
if (StringUtils.isNotEmpty(item.getScenario())) {
|
||||||
//第1个:当前场景, 第all_id_names个:最后一层场景
|
//第1个:当前场景, 第all_id_names个:最后一层场景
|
||||||
List<String> all_id_names = JSON.parseObject(item.getScenario(), List.class);
|
List<String> all_id_names = JSON.parseObject(item.getScenario(), List.class, Feature.DisableSpecialKeyDetect);
|
||||||
if (all_id_names.size() > 1) {
|
if (all_id_names.size() > 1) {
|
||||||
StringBuffer scenarioNames = new StringBuffer();
|
StringBuffer scenarioNames = new StringBuffer();
|
||||||
//因为要进行步骤统计,第一层级下的场景算作步骤,所以统计视角只按照第一级别场景来计算
|
//因为要进行步骤统计,第一层级下的场景算作步骤,所以统计视角只按照第一级别场景来计算
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class MsParser extends ApiImportAbstractParser {
|
||||||
@Override
|
@Override
|
||||||
public ApiImport parse(InputStream source, ApiTestImportRequest request) {
|
public ApiImport parse(InputStream source, ApiTestImportRequest request) {
|
||||||
String testStr = getApiTestStr(source);
|
String testStr = getApiTestStr(source);
|
||||||
ApiImport apiImport = JSON.parseObject(parsePluginFormat(testStr), ApiImport.class);
|
ApiImport apiImport = JSON.parseObject(parsePluginFormat(testStr), ApiImport.class,Feature.DisableSpecialKeyDetect);
|
||||||
apiImport.getScenarios().forEach(scenario -> setScenarioByRequest(scenario, request));
|
apiImport.getScenarios().forEach(scenario -> setScenarioByRequest(scenario, request));
|
||||||
return apiImport;
|
return apiImport;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class MsParser extends ApiImportAbstractParser {
|
||||||
@Override
|
@Override
|
||||||
public ApiDefinitionImport parseApi(InputStream source, ApiTestImportRequest request) {
|
public ApiDefinitionImport parseApi(InputStream source, ApiTestImportRequest request) {
|
||||||
String testStr = getApiTestStr(source);
|
String testStr = getApiTestStr(source);
|
||||||
ApiDefinitionImport apiImport = JSON.parseObject(testStr, ApiDefinitionImport.class);
|
ApiDefinitionImport apiImport = JSON.parseObject(testStr, ApiDefinitionImport.class,Feature.DisableSpecialKeyDetect);
|
||||||
return apiImport;
|
return apiImport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2,6 +2,7 @@ package io.metersphere.api.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import io.metersphere.base.domain.ApiScenarioReferenceId;
|
import io.metersphere.base.domain.ApiScenarioReferenceId;
|
||||||
import io.metersphere.base.domain.ApiScenarioReferenceIdExample;
|
import io.metersphere.base.domain.ApiScenarioReferenceIdExample;
|
||||||
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||||
|
@ -55,7 +56,7 @@ public class ApiScenarioReferenceIdService {
|
||||||
this.deleteByScenarioId(scenario.getId());
|
this.deleteByScenarioId(scenario.getId());
|
||||||
Map<String, ApiScenarioReferenceId> referenceIdMap = new HashMap<>();
|
Map<String, ApiScenarioReferenceId> referenceIdMap = new HashMap<>();
|
||||||
if (StringUtils.isNotEmpty(scenario.getScenarioDefinition())) {
|
if (StringUtils.isNotEmpty(scenario.getScenarioDefinition())) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(scenario.getScenarioDefinition());
|
JSONObject jsonObject = JSONObject.parseObject(scenario.getScenarioDefinition(), Feature.DisableSpecialKeyDetect);
|
||||||
if (!jsonObject.containsKey(MsHashTreeService.HASH_TREE)) {
|
if (!jsonObject.containsKey(MsHashTreeService.HASH_TREE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package io.metersphere.api.service;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import io.metersphere.api.dto.ApiScenarioReportDTO;
|
import io.metersphere.api.dto.ApiScenarioReportDTO;
|
||||||
import io.metersphere.api.dto.RequestResultExpandDTO;
|
import io.metersphere.api.dto.RequestResultExpandDTO;
|
||||||
import io.metersphere.api.dto.StepTreeDTO;
|
import io.metersphere.api.dto.StepTreeDTO;
|
||||||
|
@ -84,7 +85,7 @@ public class ApiScenarioReportStructureService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StepTreeDTO dataFormatting(ApiScenarioWithBLOBs apiScenario, String reportType) {
|
public static StepTreeDTO dataFormatting(ApiScenarioWithBLOBs apiScenario, String reportType) {
|
||||||
JSONObject element = JSON.parseObject(apiScenario.getScenarioDefinition());
|
JSONObject element = JSON.parseObject(apiScenario.getScenarioDefinition(), Feature.DisableSpecialKeyDetect);
|
||||||
StepTreeDTO dto = null;
|
StepTreeDTO dto = null;
|
||||||
if (element != null && element.getBoolean("enable")) {
|
if (element != null && element.getBoolean("enable")) {
|
||||||
element = getRefElement(element);
|
element = getRefElement(element);
|
||||||
|
@ -112,7 +113,7 @@ public class ApiScenarioReportStructureService {
|
||||||
if (StringUtils.equals(element.getString("type"), "scenario")) {
|
if (StringUtils.equals(element.getString("type"), "scenario")) {
|
||||||
ApiScenarioWithBLOBs scenarioWithBLOBs = CommonBeanFactory.getBean(ApiScenarioMapper.class).selectByPrimaryKey(element.getString("id"));
|
ApiScenarioWithBLOBs scenarioWithBLOBs = CommonBeanFactory.getBean(ApiScenarioMapper.class).selectByPrimaryKey(element.getString("id"));
|
||||||
if (scenarioWithBLOBs != null) {
|
if (scenarioWithBLOBs != null) {
|
||||||
return JSON.parseObject(scenarioWithBLOBs.getScenarioDefinition());
|
return JSON.parseObject(scenarioWithBLOBs.getScenarioDefinition(),Feature.DisableSpecialKeyDetect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,18 +247,18 @@ public class ApiScenarioReportStructureService {
|
||||||
if (reportResults.size() > 1) {
|
if (reportResults.size() > 1) {
|
||||||
for (int i = 0; i < reportResults.size(); i++) {
|
for (int i = 0; i < reportResults.size(); i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
dto.setValue(JSON.parseObject(new String(reportResults.get(i).getContent(), StandardCharsets.UTF_8), RequestResult.class));
|
dto.setValue(JSON.parseObject(new String(reportResults.get(i).getContent(), StandardCharsets.UTF_8), RequestResult.class,Feature.DisableSpecialKeyDetect));
|
||||||
dto.setErrorCode(reportResults.get(0).getErrorCode());
|
dto.setErrorCode(reportResults.get(0).getErrorCode());
|
||||||
} else {
|
} else {
|
||||||
StepTreeDTO step = new StepTreeDTO(dto.getLabel(), UUID.randomUUID().toString(), dto.getType(), (i + 1));
|
StepTreeDTO step = new StepTreeDTO(dto.getLabel(), UUID.randomUUID().toString(), dto.getType(), (i + 1));
|
||||||
step.setValue(JSON.parseObject(new String(reportResults.get(i).getContent(), StandardCharsets.UTF_8), RequestResult.class));
|
step.setValue(JSON.parseObject(new String(reportResults.get(i).getContent(), StandardCharsets.UTF_8), RequestResult.class,Feature.DisableSpecialKeyDetect));
|
||||||
step.setErrorCode(reportResults.get(i).getErrorCode());
|
step.setErrorCode(reportResults.get(i).getErrorCode());
|
||||||
dtoList.add(step);
|
dtoList.add(step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String content = new String(reportResults.get(0).getContent(), StandardCharsets.UTF_8);
|
String content = new String(reportResults.get(0).getContent(), StandardCharsets.UTF_8);
|
||||||
dto.setValue(JSON.parseObject(content, RequestResult.class));
|
dto.setValue(JSON.parseObject(content, RequestResult.class,Feature.DisableSpecialKeyDetect));
|
||||||
dto.setErrorCode(reportResults.get(0).getErrorCode());
|
dto.setErrorCode(reportResults.get(0).getErrorCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,10 +386,10 @@ public class ApiScenarioReportStructureService {
|
||||||
BeanUtils.copyBean(vo, item);
|
BeanUtils.copyBean(vo, item);
|
||||||
if (StringUtils.isNotEmpty(item.getContent())) {
|
if (StringUtils.isNotEmpty(item.getContent())) {
|
||||||
try {
|
try {
|
||||||
RequestResultExpandDTO resultExpandDTO = JSON.parseObject(item.getContent(), RequestResultExpandDTO.class);
|
RequestResultExpandDTO resultExpandDTO = JSON.parseObject(item.getContent(), RequestResultExpandDTO.class,Feature.DisableSpecialKeyDetect);
|
||||||
vo.setRequestResult(resultExpandDTO);
|
vo.setRequestResult(resultExpandDTO);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
vo.setRequestResult(JSON.parseObject(item.getContent(), RequestResult.class));
|
vo.setRequestResult(JSON.parseObject(item.getContent(), RequestResult.class,Feature.DisableSpecialKeyDetect));
|
||||||
}
|
}
|
||||||
if (vo.getRequestResult() != null) {
|
if (vo.getRequestResult() != null) {
|
||||||
vo.setPassAssertions(vo.getRequestResult().getPassAssertions());
|
vo.setPassAssertions(vo.getRequestResult().getPassAssertions());
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.metersphere.api.dto.ApiCaseEditRequest;
|
import io.metersphere.api.dto.ApiCaseEditRequest;
|
||||||
|
@ -705,7 +706,7 @@ public class ApiTestCaseService {
|
||||||
ApiTestCaseMapper batchMapper = sqlSession.getMapper(ApiTestCaseMapper.class);
|
ApiTestCaseMapper batchMapper = sqlSession.getMapper(ApiTestCaseMapper.class);
|
||||||
|
|
||||||
bloBs.forEach(apiTestCase -> {
|
bloBs.forEach(apiTestCase -> {
|
||||||
JSONObject req = JSON.parseObject(apiTestCase.getRequest());
|
JSONObject req = JSON.parseObject(apiTestCase.getRequest(), Feature.DisableSpecialKeyDetect);
|
||||||
req.put("useEnvironment", request.getEnvId());
|
req.put("useEnvironment", request.getEnvId());
|
||||||
String requestStr = JSON.toJSONString(req);
|
String requestStr = JSON.toJSONString(req);
|
||||||
apiTestCase.setRequest(requestStr);
|
apiTestCase.setRequest(requestStr);
|
||||||
|
@ -727,9 +728,9 @@ public class ApiTestCaseService {
|
||||||
ApiTestCaseMapper batchMapper = sqlSession.getMapper(ApiTestCaseMapper.class);
|
ApiTestCaseMapper batchMapper = sqlSession.getMapper(ApiTestCaseMapper.class);
|
||||||
|
|
||||||
bloBs.forEach(apiTestCase -> {
|
bloBs.forEach(apiTestCase -> {
|
||||||
MsHTTPSamplerProxy req = JSON.parseObject(apiTestCase.getRequest(), MsHTTPSamplerProxy.class);
|
MsHTTPSamplerProxy req = JSON.parseObject(apiTestCase.getRequest(), MsHTTPSamplerProxy.class,Feature.DisableSpecialKeyDetect);
|
||||||
try {
|
try {
|
||||||
JSONObject element = JSON.parseObject(apiTestCase.getRequest());
|
JSONObject element = JSON.parseObject(apiTestCase.getRequest(),Feature.DisableSpecialKeyDetect);
|
||||||
ElementUtil.dataFormatting(element);
|
ElementUtil.dataFormatting(element);
|
||||||
|
|
||||||
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
|
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package io.metersphere.api.service;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
||||||
import io.metersphere.api.dto.datacount.ApiMethodUrlDTO;
|
import io.metersphere.api.dto.datacount.ApiMethodUrlDTO;
|
||||||
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
||||||
|
@ -77,7 +78,7 @@ public class MsHashTreeService {
|
||||||
if (refType.equals(CASE)) {
|
if (refType.equals(CASE)) {
|
||||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(object.getString(ID));
|
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(object.getString(ID));
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
object = JSON.parseObject(bloBs.getRequest());
|
object = JSON.parseObject(bloBs.getRequest(), Feature.DisableSpecialKeyDetect);
|
||||||
object.put(ID, bloBs.getId());
|
object.put(ID, bloBs.getId());
|
||||||
object.put(NAME, bloBs.getName());
|
object.put(NAME, bloBs.getName());
|
||||||
hashTree.set(i, object);
|
hashTree.set(i, object);
|
||||||
|
@ -85,14 +86,14 @@ public class MsHashTreeService {
|
||||||
} else {
|
} else {
|
||||||
ApiScenarioWithBLOBs bloBs = apiScenarioMapper.selectByPrimaryKey(object.getString(ID));
|
ApiScenarioWithBLOBs bloBs = apiScenarioMapper.selectByPrimaryKey(object.getString(ID));
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
object = JSON.parseObject(bloBs.getScenarioDefinition());
|
object = JSON.parseObject(bloBs.getScenarioDefinition(),Feature.DisableSpecialKeyDetect);
|
||||||
hashTree.set(i, object);
|
hashTree.set(i, object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (SCENARIO.equals(object.getString(TYPE))) {
|
} else if (SCENARIO.equals(object.getString(TYPE))) {
|
||||||
ApiScenarioWithBLOBs bloBs = apiScenarioMapper.selectByPrimaryKey(object.getString(ID));
|
ApiScenarioWithBLOBs bloBs = apiScenarioMapper.selectByPrimaryKey(object.getString(ID));
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
object = JSON.parseObject(bloBs.getScenarioDefinition());
|
object = JSON.parseObject(bloBs.getScenarioDefinition(),Feature.DisableSpecialKeyDetect);
|
||||||
hashTree.set(i, object);
|
hashTree.set(i, object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +183,7 @@ public class MsHashTreeService {
|
||||||
ApiTestCaseInfo apiTestCase = apiTestCaseService.get(element.getString(ID));
|
ApiTestCaseInfo apiTestCase = apiTestCaseService.get(element.getString(ID));
|
||||||
if (apiTestCase != null) {
|
if (apiTestCase != null) {
|
||||||
if (StringUtils.equalsIgnoreCase(element.getString(REFERENCED), REF)) {
|
if (StringUtils.equalsIgnoreCase(element.getString(REFERENCED), REF)) {
|
||||||
JSONObject refElement = JSON.parseObject(apiTestCase.getRequest());
|
JSONObject refElement = JSON.parseObject(apiTestCase.getRequest(),Feature.DisableSpecialKeyDetect);
|
||||||
ElementUtil.dataFormatting(refElement);
|
ElementUtil.dataFormatting(refElement);
|
||||||
JSONArray array = refElement.getJSONArray(HASH_TREE);
|
JSONArray array = refElement.getJSONArray(HASH_TREE);
|
||||||
ElementUtil.copyBean(element, refElement);
|
ElementUtil.copyBean(element, refElement);
|
||||||
|
@ -255,7 +256,7 @@ public class MsHashTreeService {
|
||||||
? element.getBoolean(VARIABLE_ENABLE) : true;
|
? element.getBoolean(VARIABLE_ENABLE) : true;
|
||||||
|
|
||||||
if (StringUtils.equalsIgnoreCase(element.getString(REFERENCED), REF)) {
|
if (StringUtils.equalsIgnoreCase(element.getString(REFERENCED), REF)) {
|
||||||
element = JSON.parseObject(scenarioWithBLOBs.getScenarioDefinition());
|
element = JSON.parseObject(scenarioWithBLOBs.getScenarioDefinition(),Feature.DisableSpecialKeyDetect);
|
||||||
element.put(REFERENCED, REF);
|
element.put(REFERENCED, REF);
|
||||||
element.put(NAME, scenarioWithBLOBs.getName());
|
element.put(NAME, scenarioWithBLOBs.getName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package io.metersphere.log.aspect;
|
package io.metersphere.log.aspect;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.parser.Feature;
|
||||||
import io.metersphere.base.domain.OperatingLogWithBLOBs;
|
import io.metersphere.base.domain.OperatingLogWithBLOBs;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.i18n.Translator;
|
|
||||||
import io.metersphere.log.annotation.MsAuditLog;
|
import io.metersphere.log.annotation.MsAuditLog;
|
||||||
import io.metersphere.log.service.OperatingLogService;
|
import io.metersphere.log.service.OperatingLogService;
|
||||||
import io.metersphere.log.utils.ReflexObjectUtil;
|
import io.metersphere.log.utils.ReflexObjectUtil;
|
||||||
|
@ -188,7 +188,7 @@ public class MsLogAspect {
|
||||||
String content = expression.getValue(context, String.class);
|
String content = expression.getValue(context, String.class);
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isNotEmpty(content)) {
|
if (StringUtils.isNotEmpty(content)) {
|
||||||
OperatingLogDetails details = JSON.parseObject(content, OperatingLogDetails.class);
|
OperatingLogDetails details = JSON.parseObject(content, OperatingLogDetails.class, Feature.DisableSpecialKeyDetect);
|
||||||
if (StringUtils.isNotEmpty(details.getProjectId())) {
|
if (StringUtils.isNotEmpty(details.getProjectId())) {
|
||||||
msOperLog.setProjectId(details.getProjectId());
|
msOperLog.setProjectId(details.getProjectId());
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ public class MsLogAspect {
|
||||||
msOperLog.setCreateUser(details.getCreateUser());
|
msOperLog.setCreateUser(details.getCreateUser());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(content) && StringUtils.isNotEmpty(msLog.beforeValue())) {
|
if (StringUtils.isNotEmpty(content) && StringUtils.isNotEmpty(msLog.beforeValue())) {
|
||||||
OperatingLogDetails details = JSON.parseObject(content, OperatingLogDetails.class);
|
OperatingLogDetails details = JSON.parseObject(content, OperatingLogDetails.class,Feature.DisableSpecialKeyDetect);
|
||||||
List<DetailColumn> columns = ReflexObjectUtil.compared(JSON.parseObject(msLog.beforeValue(), OperatingLogDetails.class), details, msLog.module());
|
List<DetailColumn> columns = ReflexObjectUtil.compared(JSON.parseObject(msLog.beforeValue(), OperatingLogDetails.class), details, msLog.module());
|
||||||
details.setColumns(columns);
|
details.setColumns(columns);
|
||||||
msOperLog.setOperContent(JSON.toJSONString(details));
|
msOperLog.setOperContent(JSON.toJSONString(details));
|
||||||
|
|
Loading…
Reference in New Issue