fix(接口自动化): JSON断言特殊符号处理

This commit is contained in:
fit2-zhao 2021-03-08 15:34:38 +08:00
parent 78b30352af
commit 9cdadf67ee
3 changed files with 8 additions and 5 deletions

View File

@ -15,7 +15,6 @@ import io.metersphere.api.service.ApiTestEnvironmentService;
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.ScriptEngineUtils;
import io.metersphere.commons.utils.SessionUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -108,7 +107,7 @@ public class MsScenario extends MsTestElement {
}
// 设置共享cookie
config.setEnableCookieShare(enableCookieShare);
Map<String,EnvironmentConfig> envConfig = new HashMap<>(16);
Map<String, EnvironmentConfig> envConfig = new HashMap<>(16);
// 兼容历史数据
if (environmentMap == null || environmentMap.isEmpty()) {
environmentMap = new HashMap<>(16);
@ -167,7 +166,9 @@ public class MsScenario extends MsTestElement {
headers.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
headerManager.add(new Header(keyValue.getName(), keyValue.getValue()))
);
tree.add(headerManager);
if (headerManager.getHeaders().size() > 0) {
tree.add(headerManager);
}
}
}

View File

@ -178,7 +178,9 @@ public abstract class MsTestElement {
config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
);
return arguments;
if (arguments.getArguments().size() > 0) {
return arguments;
}
}
return null;
}

View File

@ -96,7 +96,7 @@ public class MsAssertions extends MsTestElement {
assertion.setJsonValidationBool(true);
assertion.setExpectNull(false);
assertion.setInvert(false);
assertion.setIsRegex(true);
assertion.setIsRegex(false);
return assertion;
}