From 2ffb9707ff35dc7d32990124aafe09eb45793514 Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Tue, 14 Nov 2023 11:17:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E5=8F=AA=E6=9C=89=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=9A=84=E6=9D=83=E9=99=90=EF=BC=8C=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1032874 --user=陈建星 有测试计划执行的权限,无法执行功能用例 https://www.tapd.cn/55049933/s/1436100 --- .../controller/IssuesController.java | 3 +- .../controller/TestCaseController.java | 10 +---- .../controller/TestCaseNodeController.java | 4 +- .../controller/TestPlanController.java | 2 +- .../metersphere/service/TestCaseService.java | 41 ------------------- .../functional/FunctionalTestCaseEdit.vue | 41 ------------------- 6 files changed, 7 insertions(+), 94 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java b/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java index 1453df9643..fcd2238d8c 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java @@ -36,6 +36,7 @@ import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.collections.CollectionUtils; +import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -100,7 +101,7 @@ public class IssuesController { } @GetMapping("/get/case/{refType}/{id}") - @RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ) + @RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ, PermissionConstants.PROJECT_TRACK_PLAN_READ}, logical = Logical.OR) public List getIssues(@PathVariable String refType, @PathVariable String id) { return issuesService.getIssues(id, refType); } diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TestCaseController.java b/test-track/backend/src/main/java/io/metersphere/controller/TestCaseController.java index ab1bd52d08..f6ae9519c2 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/TestCaseController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/TestCaseController.java @@ -124,7 +124,7 @@ public class TestCaseController { } @GetMapping("/relationship/case/count/{id}") - @RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ) + @RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ, PermissionConstants.PROJECT_TRACK_PLAN_READ}, logical = Logical.OR) public int getRelationshipCase(@PathVariable("id") String id) { return testCaseService.getRelationshipCount(id); } @@ -160,7 +160,7 @@ public class TestCaseController { } @GetMapping("/relate/test/list/{caseId}") - @RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ) + @RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ, PermissionConstants.PROJECT_TRACK_PLAN_READ}, logical = Logical.OR) public List getRelateTest(@PathVariable String caseId) { return testCaseService.getRelateTest(caseId); } @@ -254,12 +254,6 @@ public class TestCaseController { return testCaseService.edit(request); } - @PostMapping(value = "/edit/testPlan", consumes = {"multipart/form-data"}) - @RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT, PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN}, logical = Logical.OR) - public String editTestCaseByTestPlan(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file", required = false) List files) { - return testCaseService.editTestCase(request, files); - } - @PostMapping("/delete/{testCaseId}") @MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testCaseId)", msClass = TestCaseService.class) @RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_DELETE) diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TestCaseNodeController.java b/test-track/backend/src/main/java/io/metersphere/controller/TestCaseNodeController.java index eb5db5aacf..8bbf8d0cfb 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/TestCaseNodeController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/TestCaseNodeController.java @@ -100,14 +100,14 @@ public class TestCaseNodeController { } @GetMapping("/list/plan/{planId}") - @RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ}) + @RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_PLAN_READ}) public List getNodeByPlanId(@PathVariable String planId) { trackCheckPermissionService.checkTestPlanOwner(planId); return testCaseNodeService.getNodeByPlanId(planId); } @PostMapping("/list/plan/{planId}") - @RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ}) + @RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_PLAN_READ}) public List getNodeByPlanId(@PathVariable String planId, @RequestBody(required = false) QueryTestPlanCaseRequest request) { trackCheckPermissionService.checkTestPlanOwner(planId); return testCaseNodeService.getNodeByPlanId(planId, Optional.ofNullable(request).orElse(new QueryTestPlanCaseRequest())); diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java b/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java index bee31ea448..e3466b7d19 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java @@ -162,7 +162,7 @@ public class TestPlanController { } @PostMapping("/edit/status/{planId}") - @RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_EDIT) + @RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ) @MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#planId)", content = "#msClass.getLogDetails(#planId)", msClass = TestPlanService.class) public void editTestPlanStatus(@PathVariable String planId) { checkPermissionService.checkTestPlanOwner(planId); diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java index fe6f84194e..ec8e8d468e 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java @@ -2444,47 +2444,6 @@ public class TestCaseService { return editTestCase(request); } - public String editTestCase(EditTestCaseRequest request, List files) { - String testCaseId = testPlanTestCaseMapper.selectByPrimaryKey(request.getId()).getCaseId(); - request.setId(testCaseId); - TestCaseWithBLOBs testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(testCaseId); - if (testCaseWithBLOBs == null) { - MSException.throwException(Translator.get("edit_load_test_not_found") + request.getId()); - } - testCaseWithBLOBs.setRemark(request.getRemark()); - // 新选择了一个文件,删除原来的文件 - List updatedFiles = request.getUpdatedFileList(); - List originFiles = attachmentService.getFileMetadataByCaseId(testCaseId); - List updatedFileIds = updatedFiles.stream().map(FileMetadata::getId).collect(Collectors.toList()); - List originFileIds = originFiles.stream().map(FileMetadata::getId).collect(Collectors.toList()); - // 相减 - List deleteFileIds = ListUtils.subtract(originFileIds, updatedFileIds); - fileService.deleteFileRelatedByIds(deleteFileIds); - - if (!CollectionUtils.isEmpty(deleteFileIds)) { - TestCaseFileExample testCaseFileExample = new TestCaseFileExample(); - testCaseFileExample.createCriteria().andFileIdIn(deleteFileIds); - testCaseFileMapper.deleteByExample(testCaseFileExample); - } - - - if (files != null) { - files.forEach(file -> { - final FileMetadata fileMetadata = fileService.saveFile(file, testCaseWithBLOBs.getProjectId()); - TestCaseFile testCaseFile = new TestCaseFile(); - testCaseFile.setFileId(fileMetadata.getId()); - testCaseFile.setCaseId(testCaseId); - testCaseFileMapper.insert(testCaseFile); - }); - } - setNode(request); - request.setStatus(null); // 不更新状态 - request.setRefId(testCaseWithBLOBs.getRefId()); - request.setVersionId(testCaseWithBLOBs.getVersionId()); - editTestCase(request); - return request.getId(); - } - public void minderEdit(TestCaseMinderEditRequest request) { deleteToGcBatch(request.getIds(), request.getProjectId()); testCaseNodeService.minderEdit(request); diff --git a/test-track/frontend/src/business/plan/view/comonents/functional/FunctionalTestCaseEdit.vue b/test-track/frontend/src/business/plan/view/comonents/functional/FunctionalTestCaseEdit.vue index 6c7d5df1f0..086a7942ed 100644 --- a/test-track/frontend/src/business/plan/view/comonents/functional/FunctionalTestCaseEdit.vue +++ b/test-track/frontend/src/business/plan/view/comonents/functional/FunctionalTestCaseEdit.vue @@ -304,44 +304,6 @@ export default { this.handleClose(); this.$emit("refresh"); }, - getOption(param) { - let formData = new FormData(); - let url = "/test/case/edit/testPlan"; - - if (this.$refs.otherInfo && this.$refs.otherInfo.uploadList) { - this.$refs.otherInfo.uploadList.forEach((f) => { - formData.append("file", f); - }); - } - - if (this.$refs.otherInfo && this.$refs.otherInfo.fileList) { - param.updatedFileList = this.$refs.otherInfo.fileList; - } else { - param.fileIds = []; - param.updatedFileList = []; - } - - // param.updatedFileList = this.fileList; - let requestJson = JSON.stringify(param, function (key, value) { - return key === "file" ? undefined : value; - }); - - formData.append( - "request", - new Blob([requestJson], { - type: "application/json ", - }) - ); - - return { - method: "POST", - url: url, - data: formData, - headers: { - "Content-Type": undefined, - }, - }; - }, saveCase(command) { let param = {}; param.id = this.testCase.id; @@ -354,7 +316,6 @@ export default { param.demandId = this.testCase.demandId; param.name = this.testCase.name; param.comment = this.testCase.comment; - let option = this.getOption(param); for (let i = 0; i < this.testCase.steptResults.length; i++) { let result = {}; result.actualResult = this.testCase.steptResults[i].actualResult; @@ -380,8 +341,6 @@ export default { param.results = JSON.stringify(param.results); param.actualResult = this.testCase.actualResult; testPlanTestCaseEdit(param).then((response) => { - this.$request(option); - this.$success(this.$t("commons.save_success")); this.updateTestCases(param); this.setPlanStatus(this.testCase.planId);