diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index 5d3dd08502..6be0d1fe99 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -44,6 +44,9 @@ public class MsScenario extends MsTestElement { private List variables; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } if (environmentId != null) { ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class); ApiTestEnvironmentWithBLOBs environment = environmentService.get(environmentId); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java index 3bfecbfc1b..afc6f625dd 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java @@ -12,6 +12,7 @@ import io.metersphere.api.dto.definition.request.auth.MsAuthManager; import io.metersphere.api.dto.definition.request.configurations.MsHeaderManager; import io.metersphere.api.dto.definition.request.controller.MsIfController; import io.metersphere.api.dto.definition.request.extract.MsExtract; +import io.metersphere.api.dto.definition.request.processors.MsJSR223Processor; import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor; import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor; import io.metersphere.api.dto.definition.request.sampler.MsDubboSampler; @@ -37,6 +38,7 @@ import java.util.List; @JsonSubTypes({ @JsonSubTypes.Type(value = MsHTTPSamplerProxy.class, name = "HTTPSamplerProxy"), @JsonSubTypes.Type(value = MsHeaderManager.class, name = "HeaderManager"), + @JsonSubTypes.Type(value = MsJSR223Processor.class, name = "JSR223Processor"), @JsonSubTypes.Type(value = MsJSR223PostProcessor.class, name = "JSR223PostProcessor"), @JsonSubTypes.Type(value = MsJSR223PreProcessor.class, name = "JSR223PreProcessor"), @JsonSubTypes.Type(value = MsTestPlan.class, name = "TestPlan"), @@ -52,7 +54,7 @@ import java.util.List; @JsonSubTypes.Type(value = MsScenario.class, name = "scenario"), }) -@JSONType(seeAlso = {MsHTTPSamplerProxy.class, MsHeaderManager.class, MsJSR223PostProcessor.class, +@JSONType(seeAlso = {MsHTTPSamplerProxy.class, MsHeaderManager.class, MsJSR223Processor.class, MsJSR223PostProcessor.class, MsJSR223PreProcessor.class, MsTestPlan.class, MsThreadGroup.class, AuthManager.class, MsAssertions.class, MsExtract.class, MsTCPSampler.class, MsDubboSampler.class, MsJDBCSampler.class, MsConstantTimer.class, MsIfController.class, MsScenario.class}, typeKey = "type") @Data @@ -73,6 +75,9 @@ public abstract class MsTestElement { @JSONField(ordinal = 7) private String index; @JSONField(ordinal = 8) + private boolean enable = true; + + @JSONField(ordinal = 9) private LinkedList hashTree; // 公共环境逐层传递,如果自身有环境 以自身引用环境为准否则以公共环境作为请求环境 @@ -118,7 +123,8 @@ public abstract class MsTestElement { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(this.getId()); - element = mapper.readValue(apiDefinition.getRequest(), new TypeReference() {}); + element = mapper.readValue(apiDefinition.getRequest(), new TypeReference() { + }); hashTree.add(element); } catch (Exception ex) { ex.printStackTrace(); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java index 59cc74c491..f3fa1d3801 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java @@ -25,7 +25,9 @@ public class MsAssertions extends MsTestElement { private String type = "Assertions"; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { - addAssertions(tree); + if (this.isEnable()) { + addAssertions(tree); + } } private void addAssertions(HashTree hashTree) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/auth/MsAuthManager.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/auth/MsAuthManager.java index 8ef3a3ae2a..326aec4705 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/auth/MsAuthManager.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/auth/MsAuthManager.java @@ -52,6 +52,9 @@ public class MsAuthManager extends MsTestElement { private String environment; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } AuthManager authManager = new AuthManager(); authManager.setEnabled(true); authManager.setName(this.getUsername() + "AuthManager"); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/configurations/MsHeaderManager.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/configurations/MsHeaderManager.java index ee33dba7b8..50e77d1e09 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/configurations/MsHeaderManager.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/configurations/MsHeaderManager.java @@ -26,6 +26,9 @@ public class MsHeaderManager extends MsTestElement { private List headers; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } HeaderManager headerManager = new HeaderManager(); headerManager.setEnabled(true); headerManager.setName(this.getName() + "Headers"); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java index 4560c0da05..dd01f99994 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java @@ -20,12 +20,14 @@ import java.util.List; public class MsIfController extends MsTestElement { private String type = "IfController"; private String id; - private boolean enable = true; private String variable; private String operator; private String value; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } final HashTree groupTree = tree.add(ifController()); if (CollectionUtils.isNotEmpty(hashTree)) { hashTree.forEach(el -> { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java index ef505a4959..38dea36a09 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java @@ -25,6 +25,9 @@ import java.util.List; public class MsDNSCacheManager extends MsTestElement { public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } for (MsTestElement el : hashTree) { el.toHashTree(tree, el.getHashTree(), config); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java index a06d72673a..5064cfaa99 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java @@ -25,6 +25,9 @@ public class MsExtract extends MsTestElement { private String type = "Extract"; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } addRequestExtractors(tree); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java index d729b7ccff..237636e640 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java @@ -27,6 +27,9 @@ public class MsJSR223Processor extends MsTestElement { private String scriptLanguage; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } JSR223Sampler processor = new JSR223Sampler(); processor.setEnabled(true); processor.setName(this.getName() + "JSR223Processor"); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java index 75253ceaaa..be3af32823 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java @@ -28,6 +28,9 @@ public class MsJSR223PostProcessor extends MsTestElement { public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } JSR223PostProcessor processor = new JSR223PostProcessor(); processor.setEnabled(true); processor.setName(this.getName() + "JSR223PostProcessor"); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java index 8ebcea1129..d8344ddf7c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java @@ -27,6 +27,9 @@ public class MsJSR223PreProcessor extends MsTestElement { private String scriptLanguage; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } JSR223PreProcessor processor = new JSR223PreProcessor(); processor.setEnabled(true); processor.setName(this.getName() + "JSR223PreProcessor"); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java index c00425cfdc..1d8c5d0167 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java @@ -52,6 +52,9 @@ public class MsDubboSampler extends MsTestElement { private List attachmentArgs; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } if (this.getReferenced() != null && this.getReferenced().equals("Deleted")) { return; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index 5da51841a5..f856d8bf31 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -86,6 +86,9 @@ public class MsHTTPSamplerProxy extends MsTestElement { private List arguments; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } if (this.getReferenced() != null && this.getReferenced().equals("REF")) { this.getRefElement(this); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java index 64eaecb497..17ddaa54e5 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java @@ -40,6 +40,9 @@ public class MsJDBCSampler extends MsTestElement { private String environmentId; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } if (this.getReferenced() != null && this.getReferenced().equals("REF")) { this.getRefElement(this); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java index 9a563e0cb5..904e395a0f 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java @@ -50,6 +50,9 @@ public class MsTCPSampler extends MsTestElement { private String request; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } if (this.getReferenced() != null && this.getReferenced().equals("REF")) { this.getRefElement(this); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java index bdba212760..64eb4b8824 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java @@ -22,11 +22,12 @@ public class MsConstantTimer extends MsTestElement { @JSONField(ordinal = 10) private String id; @JSONField(ordinal = 11) - private boolean enable = true; - @JSONField(ordinal = 12) private String delay; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if (!this.isEnable()) { + return; + } final HashTree groupTree = tree.add(constantTimer()); if (CollectionUtils.isNotEmpty(hashTree)) { hashTree.forEach(el -> { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.java index 791044b1bb..85304da4ed 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.java @@ -12,7 +12,7 @@ public interface ExtTestCaseReviewMapper { List list(@Param("request") QueryCaseReviewRequest params); - List listByWorkspaceId(@Param("workspaceId") String workspaceId, @Param("userId") String userId); + List listByWorkspaceId(@Param("workspaceId") String workspaceId, @Param("userId") String userId, @Param("projectId") String projectId); List listRelate(@Param("request") QueryTestReviewRequest request); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.xml index 6c576ba1a2..af8ef0dd3a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.xml @@ -15,6 +15,9 @@ and test_case_review.name like CONCAT('%', #{request.name},'%') and project.workspace_id = #{request.workspaceId} + + and test_case_review_project.project_id = #{request.projectId} + order by @@ -32,6 +35,9 @@ test_case_review.id = test_case_review_project.review_id and test_case_review_project.project_id = project.id and project.workspace_id = #{workspaceId} + + and test_case_review_project.project_id = #{projectId} + and ( (test_case_review_users.review_id = test_case_review.id and test_case_review_users.user_id = #{userId} ) @@ -51,6 +57,9 @@ and test_case_review_users.user_id = #{request.reviewerId} + + and test_case_review_project.project_id = #{request.projectId} + and (test_case_review.creator = #{request.creator} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml index 7bfe1039c9..e0ba81e9bf 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml @@ -114,6 +114,9 @@ AND test_plan.workspace_id = #{request.workspaceId} + + AND test_plan_project.project_id = #{request.projectId} + AND test_plan.id = #{request.id} @@ -160,16 +163,22 @@ diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.java index a095f81620..3911f21c76 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.java @@ -19,7 +19,7 @@ public interface ExtTestPlanTestCaseMapper { List listByNodes(@Param("request") QueryTestPlanCaseRequest request); - List findRelateTestPlanId(@Param("userId") String userId, @Param("workspaceId") String workspaceId); + List findRelateTestPlanId(@Param("userId") String userId, @Param("workspaceId") String workspaceId, @Param("projectId") String projectId); List getRecentTestedTestCase(@Param("request") QueryTestPlanCaseRequest request); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml index 6bfdd21c04..c30dd42e73 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml @@ -270,8 +270,15 @@ select distinct plan_id from test_plan_test_case inner join test_plan on test_plan_test_case.plan_id = test_plan.id - where test_plan_test_case.executor = #{userId} - and test_plan.workspace_id = #{workspaceId} + inner join test_plan_project + on test_plan.id = test_plan_project.test_plan_id + + test_plan_test_case.executor = #{userId} + and test_plan.workspace_id = #{workspaceId} + + and test_plan_project.project_id = #{projectId} + +