fix(接口测试): 修复JSON格式化包含ObjectNode对象报错问题

--bug=1017936 --user=赵勇 场景中添加自定义SQL请求-调试执行成功,但是显示“停止”(偶现) https://www.tapd.cn/55049933/s/1260648
This commit is contained in:
fit2-zhao 2022-10-13 15:30:42 +08:00 committed by wxg0103
parent d77a66f7ba
commit 9c0761736b
3 changed files with 12 additions and 14 deletions

View File

@ -42,7 +42,6 @@ import org.apache.jmeter.protocol.http.util.HTTPConstants;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jorphan.collections.HashTree;
import org.codehaus.jackson.JsonNode;
import org.json.JSONObject;
import java.net.URL;
@ -306,17 +305,8 @@ public class MsHTTPSamplerProxy extends MsTestElement {
EnvironmentConfig environmentConfig = config.getConfig().get(this.getProjectId());
if (environmentConfig != null) {
String useEvnId = environmentConfig.getApiEnvironmentid();
if (this.authManager == null && environmentConfig.getAuthManager() != null && environmentConfig.getAuthManager().has("authManager")) {
try {
JsonNode authObject = environmentConfig.getAuthManager().get("authManager");
if (authObject != null) {
if (authObject.has("verification") && !StringUtils.equalsIgnoreCase(authObject.get("verification").asText(), "No Auth")) {
this.authManager = JSON.parseObject(authObject.toString(), MsAuthManager.class);
}
}
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
}
if (this.authManager == null && environmentConfig.getAuthManager() != null && environmentConfig.getAuthManager().getAuthManager() != null) {
this.authManager = environmentConfig.getAuthManager().getAuthManager();
}
if (StringUtils.isNotEmpty(useEvnId) && !StringUtils.equals(useEvnId, this.getEnvironmentId())) {
this.setEnvironmentId(useEvnId);

View File

@ -0,0 +1,9 @@
package io.metersphere.api.dto.scenario.environment;
import io.metersphere.api.dto.definition.request.auth.MsAuthManager;
import lombok.Data;
@Data
public class EnvAuthManager {
private MsAuthManager authManager;
}

View File

@ -9,7 +9,6 @@ import io.metersphere.api.dto.scenario.HttpConfig;
import io.metersphere.api.dto.scenario.TCPConfig;
import io.metersphere.environment.ssl.KeyStoreConfig;
import lombok.Data;
import org.codehaus.jackson.node.ObjectNode;
import java.util.ArrayList;
import java.util.List;
@ -31,7 +30,7 @@ public class EnvironmentConfig {
private MsJSR223Processor postStepProcessor;
//全局前后置脚本都配置
private GlobalScriptConfig globalScriptConfig;
private ObjectNode authManager;
private EnvAuthManager authManager;
private List<MsAssertions> assertions;
private boolean useErrorCode;
private boolean higherThanSuccess;