fix(接口测试): 正则断言失效
--bug=1039800 --user=陈建星 【接口测试】断言-变量,正则匹配断言错误 https://www.tapd.cn/55049933/s/1503523
This commit is contained in:
parent
c1a2eeb752
commit
2aef4d50b9
|
@ -55,7 +55,7 @@ public class KeyValueInfo {
|
||||||
}
|
}
|
||||||
} else if (StringUtils.equals(this.condition, ParamConditionEnums.REGULAR_MATCH.name())) {
|
} else if (StringUtils.equals(this.condition, ParamConditionEnums.REGULAR_MATCH.name())) {
|
||||||
try {
|
try {
|
||||||
return this.value.matches(Pattern.quote(value));
|
return this.value.matches(value);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,8 @@ public class ResponseHeaderAssertionConverter extends AssertionConverter<MsRespo
|
||||||
String testString = expectedValue;
|
String testString = expectedValue;
|
||||||
if (StringUtils.isNotEmpty(regexTemplate)) {
|
if (StringUtils.isNotEmpty(regexTemplate)) {
|
||||||
testString = regexTemplate
|
testString = regexTemplate
|
||||||
.replace("%key", Pattern.quote(header))
|
.replace("%key", header)
|
||||||
.replace("%value", Pattern.quote(expectedValue));
|
.replace("%value", expectedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.startsWith(msAssertionCondition.name(), "NOT")) {
|
if (StringUtils.startsWith(msAssertionCondition.name(), "NOT")) {
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class VariableAssertionConverter extends AssertionConverter<MsVariableAss
|
||||||
"""
|
"""
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
if (variableValue != null) {
|
if (variableValue != null) {
|
||||||
result = Pattern.matches(Pattern.quote(expectation), variableValue);
|
result = Pattern.matches(expectation, variableValue);
|
||||||
} else {
|
} else {
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue