fix(接口测试): 正则断言失效

--bug=1039800 --user=陈建星 【接口测试】断言-变量,正则匹配断言错误 https://www.tapd.cn/55049933/s/1503523
This commit is contained in:
AgAngle 2024-04-21 17:26:41 +08:00 committed by Craftsman
parent c1a2eeb752
commit 2aef4d50b9
3 changed files with 4 additions and 4 deletions

View File

@ -55,7 +55,7 @@ public class KeyValueInfo {
}
} else if (StringUtils.equals(this.condition, ParamConditionEnums.REGULAR_MATCH.name())) {
try {
return this.value.matches(Pattern.quote(value));
return this.value.matches(value);
} catch (Exception e) {
return false;
}

View File

@ -61,8 +61,8 @@ public class ResponseHeaderAssertionConverter extends AssertionConverter<MsRespo
String testString = expectedValue;
if (StringUtils.isNotEmpty(regexTemplate)) {
testString = regexTemplate
.replace("%key", Pattern.quote(header))
.replace("%value", Pattern.quote(expectedValue));
.replace("%key", header)
.replace("%value", expectedValue);
}
if (StringUtils.startsWith(msAssertionCondition.name(), "NOT")) {

View File

@ -82,7 +82,7 @@ public class VariableAssertionConverter extends AssertionConverter<MsVariableAss
"""
import java.util.regex.Pattern;
if (variableValue != null) {
result = Pattern.matches(Pattern.quote(expectation), variableValue);
result = Pattern.matches(expectation, variableValue);
} else {
result = false;
}