fix(接口测试): 修复被禁用的断言还可以执行的缺陷

--bug=1039000 --user=王孝刚 【接口测试】场景-创建场景-添加响应头断言多个,保存后再禁用所有断言不生效
https://www.tapd.cn/55049933/s/1495749
This commit is contained in:
wxg0103 2024-04-12 13:17:46 +08:00 committed by Craftsman
parent bd5821acf2
commit 6533c45623
5 changed files with 8 additions and 5 deletions

View File

@ -34,7 +34,8 @@ public class ResponseHeaderAssertionConverter extends AssertionConverter<MsRespo
public boolean isHeaderAssertionValid(MsResponseHeaderAssertion.ResponseHeaderAssertionItem headerAssertionItem) { public boolean isHeaderAssertionValid(MsResponseHeaderAssertion.ResponseHeaderAssertionItem headerAssertionItem) {
return StringUtils.isNotBlank(headerAssertionItem.getHeader()) return StringUtils.isNotBlank(headerAssertionItem.getHeader())
&& StringUtils.isNotBlank(headerAssertionItem.getCondition()) && StringUtils.isNotBlank(headerAssertionItem.getCondition())
&& StringUtils.isNotBlank(headerAssertionItem.getExpectedValue()); && StringUtils.isNotBlank(headerAssertionItem.getExpectedValue())
&& BooleanUtils.isTrue(headerAssertionItem.getEnable());
} }
private ResponseAssertion parse2ResponseAssertion(MsResponseHeaderAssertion.ResponseHeaderAssertionItem msAssertion, private ResponseAssertion parse2ResponseAssertion(MsResponseHeaderAssertion.ResponseHeaderAssertionItem msAssertion,

View File

@ -63,7 +63,8 @@ public class VariableAssertionConverter extends AssertionConverter<MsVariableAss
public boolean isValid(MsVariableAssertion.VariableAssertionItem variableAssertionItem) { public boolean isValid(MsVariableAssertion.VariableAssertionItem variableAssertionItem) {
return StringUtils.isNotBlank(variableAssertionItem.getVariableName()) return StringUtils.isNotBlank(variableAssertionItem.getVariableName())
&& StringUtils.isNotBlank(variableAssertionItem.getCondition()); && StringUtils.isNotBlank(variableAssertionItem.getCondition())
&& BooleanUtils.isTrue(variableAssertionItem.getEnable());
} }
private static String parse2BeanshellJSR233Script(MsVariableAssertion.VariableAssertionItem variableAssertionItem) { private static String parse2BeanshellJSR233Script(MsVariableAssertion.VariableAssertionItem variableAssertionItem) {

View File

@ -3,6 +3,7 @@ package io.metersphere.project.api.assertion.body;
import io.metersphere.system.valid.EnumValue; import io.metersphere.system.valid.EnumValue;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
/** /**
@ -30,7 +31,7 @@ public class MsJSONPathAssertionItem extends MsBodyAssertionItem {
private String expectedValue; private String expectedValue;
public boolean isValid() { public boolean isValid() {
return StringUtils.isNotBlank(expression) && StringUtils.isNotBlank(condition); return StringUtils.isNotBlank(expression) && StringUtils.isNotBlank(condition) && BooleanUtils.isTrue(this.getEnable());
} }
} }

View File

@ -16,6 +16,6 @@ public class MsRegexAssertionItem extends MsBodyAssertionItem {
private String expression; private String expression;
public boolean isValid() { public boolean isValid() {
return StringUtils.isNotBlank(expression); return StringUtils.isNotBlank(expression) && Boolean.TRUE.equals(this.getEnable());
} }
} }

View File

@ -21,6 +21,6 @@ public class MsXPathAssertionItem extends MsBodyAssertionItem {
private String expectedValue; private String expectedValue;
public boolean isValid() { public boolean isValid() {
return StringUtils.isNotBlank(expression); return StringUtils.isNotBlank(expression) && Boolean.TRUE.equals(this.getEnable());
} }
} }