diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/MsResponseCodeAssertion.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/MsResponseCodeAssertion.java index 05b80cb568..814677bf13 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/MsResponseCodeAssertion.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/MsResponseCodeAssertion.java @@ -1,7 +1,8 @@ package io.metersphere.api.dto.request.assertion; import com.fasterxml.jackson.annotation.JsonTypeName; -import jakarta.validation.constraints.Size; +import io.metersphere.system.valid.EnumValue; +import jakarta.validation.constraints.NotBlank; import lombok.Data; /** @@ -18,7 +19,8 @@ public class MsResponseCodeAssertion extends MsAssertion { * 不校验可搭配其他校验使用 * 取值参考 {@link io.metersphere.sdk.constants.MsAssertionCondition} */ - @Size(max = 50) + @NotBlank + @EnumValue(enumClass = io.metersphere.sdk.constants.MsAssertionCondition.class) private String condition; /** * 匹配值 diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/MsResponseHeaderAssertion.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/MsResponseHeaderAssertion.java index 608b1bfb02..829db6651e 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/MsResponseHeaderAssertion.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/MsResponseHeaderAssertion.java @@ -3,6 +3,7 @@ package io.metersphere.api.dto.request.assertion; import com.fasterxml.jackson.annotation.JsonTypeName; import io.metersphere.system.valid.EnumValue; import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; import lombok.Data; import java.util.List; @@ -40,6 +41,7 @@ public class MsResponseHeaderAssertion extends MsAssertion { * 匹配条件 * 取值参考 {@link io.metersphere.sdk.constants.MsAssertionCondition} */ + @NotBlank @EnumValue(enumClass = io.metersphere.sdk.constants.MsAssertionCondition.class) private String condition; /** diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/MsVariableAssertion.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/MsVariableAssertion.java index b36b1aea73..ea49eed8ba 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/MsVariableAssertion.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/MsVariableAssertion.java @@ -1,6 +1,8 @@ package io.metersphere.api.dto.request.assertion; import com.fasterxml.jackson.annotation.JsonTypeName; +import io.metersphere.system.valid.EnumValue; +import jakarta.validation.constraints.NotBlank; import lombok.Data; import java.util.List; @@ -29,6 +31,8 @@ public class MsVariableAssertion extends MsAssertion { * 匹配条件 * 值为 MsAssertionCondition */ + @NotBlank + @EnumValue(enumClass = io.metersphere.sdk.constants.MsAssertionCondition.class) private String condition; /** * 匹配值 diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/body/MsDocumentAssertionElement.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/body/MsDocumentAssertionElement.java index 5b5d515476..273a73667e 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/body/MsDocumentAssertionElement.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/body/MsDocumentAssertionElement.java @@ -4,6 +4,7 @@ import io.metersphere.sdk.constants.MsAssertionCondition; import io.metersphere.sdk.constants.ValueEnum; import io.metersphere.system.valid.EnumValue; import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; import lombok.Data; @@ -40,6 +41,7 @@ public class MsDocumentAssertionElement { * 匹配条件 * 取值参考 {@link MsAssertionCondition} */ + @NotBlank @EnumValue(enumClass = MsAssertionCondition.class) private String condition; /** diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/body/MsJSONPathAssertionItem.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/body/MsJSONPathAssertionItem.java index e7cd653fa7..9bd49e2391 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/body/MsJSONPathAssertionItem.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/assertion/body/MsJSONPathAssertionItem.java @@ -1,5 +1,7 @@ package io.metersphere.api.dto.request.assertion.body; +import io.metersphere.system.valid.EnumValue; +import jakarta.validation.constraints.NotBlank; import lombok.Data; import org.apache.commons.lang3.StringUtils; @@ -19,6 +21,8 @@ public class MsJSONPathAssertionItem extends MsBodyAssertionItem { * 匹配条件 * 取值参考 {@link io.metersphere.sdk.constants.MsAssertionCondition} */ + @NotBlank + @EnumValue(enumClass = io.metersphere.sdk.constants.MsAssertionCondition.class) private String condition; /** * 匹配值 diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/processors/ScriptProcessor.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/processors/ScriptProcessor.java index e76787a3d3..dcdaca3284 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/processors/ScriptProcessor.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/request/processors/ScriptProcessor.java @@ -3,6 +3,7 @@ package io.metersphere.api.dto.request.processors; import com.fasterxml.jackson.annotation.JsonTypeName; import io.metersphere.api.dto.request.http.KeyValueParam; import io.metersphere.project.constants.ScriptLanguageType; +import io.metersphere.system.valid.EnumValue; import jakarta.validation.Valid; import jakarta.validation.constraints.Size; import lombok.Data; @@ -25,6 +26,7 @@ public class ScriptProcessor extends MsProcessor { * {@link ScriptLanguageType} */ @Size(max = 20) + @EnumValue(enumClass = ScriptLanguageType.class) private String scriptLanguage; /** * 是否启用公共脚本 diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/processor/ScriptProcessorConverter.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/processor/ScriptProcessorConverter.java index 6387378006..c9ea658545 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/processor/ScriptProcessorConverter.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/processor/ScriptProcessorConverter.java @@ -30,7 +30,10 @@ public abstract class ScriptProcessorConverter extends MsProcessorConverter