Merge branch 'v1.3' of github.com:metersphere/metersphere into v1.3

This commit is contained in:
Captain.B 2020-10-10 17:51:53 +08:00
commit 80fdee00b9
13 changed files with 99 additions and 4 deletions

View File

@ -20,4 +20,12 @@ public interface ExtTestCaseMapper {
TestCase getMaxNumByProjectId(@Param("projectId") String projectId); TestCase getMaxNumByProjectId(@Param("projectId") String projectId);
/**
* 检查某工作空间下是否有某用例
* @param caseId
* @param workspaceId
* @return TestCase ID
*/
List<String> checkIsHave(@Param("caseId") String caseId, @Param("workspaceId") String workspaceId);
} }

View File

@ -251,4 +251,11 @@
<select id="getMaxNumByProjectId" resultType="io.metersphere.base.domain.TestCase"> <select id="getMaxNumByProjectId" resultType="io.metersphere.base.domain.TestCase">
select * from test_case where test_case.project_id = #{projectId} order by num desc limit 1; select * from test_case where test_case.project_id = #{projectId} order by num desc limit 1;
</select> </select>
<select id="checkIsHave" resultType="java.lang.String">
select distinct test_case.id
from test_case, project
where test_case.project_id = project.id
and project.workspace_id = #{workspaceId}
and test_case.id = #{caseId};
</select>
</mapper> </mapper>

View File

@ -15,4 +15,12 @@ public interface ExtTestCaseReviewMapper {
List<TestCaseReviewDTO> listByWorkspaceId(@Param("workspaceId") String workspaceId); List<TestCaseReviewDTO> listByWorkspaceId(@Param("workspaceId") String workspaceId);
List<TestReviewDTOWithMetric> listRelate(@Param("request") QueryTestReviewRequest request); List<TestReviewDTOWithMetric> listRelate(@Param("request") QueryTestReviewRequest request);
/**
* 检查某工作空间下是否有某测试评审
* @param reviewId
* @param workspaceId
* @return Review ID
*/
List<String> checkIsHave(@Param("reviewId") String reviewId, @Param("workspaceId") String workspaceId);
} }

View File

@ -58,4 +58,11 @@
order by test_case_review.update_time desc order by test_case_review.update_time desc
</select> </select>
<select id="checkIsHave" resultType="java.lang.String">
select distinct review_id
from project, test_case_review_project
where project.id = test_case_review_project.project_id
and project.workspace_id = #{workspaceId}
and test_case_review_project.review_id = #{reviewId};
</select>
</mapper> </mapper>

View File

@ -4,11 +4,11 @@ import io.metersphere.api.dto.APITestResult;
import io.metersphere.api.dto.QueryAPITestRequest; import io.metersphere.api.dto.QueryAPITestRequest;
import io.metersphere.base.domain.Project; import io.metersphere.base.domain.Project;
import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.base.mapper.ProjectMapper;
import io.metersphere.base.mapper.ext.ExtApiTestMapper; import io.metersphere.base.mapper.ext.*;
import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.LoadTestDTO; import io.metersphere.dto.LoadTestDTO;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
import io.metersphere.track.dto.TestPlanDTO;
import io.metersphere.track.request.testplan.QueryTestPlanRequest; import io.metersphere.track.request.testplan.QueryTestPlanRequest;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -26,6 +26,12 @@ public class CheckOwnerService {
private ExtApiTestMapper extApiTestMapper; private ExtApiTestMapper extApiTestMapper;
@Resource @Resource
private ExtLoadTestMapper extLoadTestMapper; private ExtLoadTestMapper extLoadTestMapper;
@Resource
private ExtTestCaseMapper extTestCaseMapper;
@Resource
private ExtTestPlanMapper extTestPlanMapper;
@Resource
private ExtTestCaseReviewMapper extTestCaseReviewMapper;
public void checkProjectOwner(String projectId) { public void checkProjectOwner(String projectId) {
String workspaceId = SessionUtils.getCurrentWorkspaceId(); String workspaceId = SessionUtils.getCurrentWorkspaceId();
@ -61,4 +67,31 @@ public class CheckOwnerService {
throw new UnauthorizedException(Translator.get("check_owner_test")); throw new UnauthorizedException(Translator.get("check_owner_test"));
} }
} }
public void checkTestCaseOwner(String caseId) {
String workspaceId = SessionUtils.getCurrentWorkspaceId();
List<String> list = extTestCaseMapper.checkIsHave(caseId, workspaceId);
if (CollectionUtils.size(list) != 1) {
throw new UnauthorizedException(Translator.get("check_owner_case"));
}
}
public void checkTestPlanOwner(String planId) {
String workspaceId = SessionUtils.getCurrentWorkspaceId();
io.metersphere.track.request.testcase.QueryTestPlanRequest request = new io.metersphere.track.request.testcase.QueryTestPlanRequest();
request.setWorkspaceId(workspaceId);
request.setId(planId);
List<TestPlanDTO> list = extTestPlanMapper.list(request);
if (CollectionUtils.size(list) != 1) {
throw new UnauthorizedException(Translator.get("check_owner_plan"));
}
}
public void checkTestReviewOwner(String reviewId) {
String workspaceId = SessionUtils.getCurrentWorkspaceId();
List<String> list = extTestCaseReviewMapper.checkIsHave(reviewId, workspaceId);
if (CollectionUtils.size(list) != 1) {
throw new UnauthorizedException(Translator.get("check_owner_review"));
}
}
} }

View File

@ -83,11 +83,13 @@ public class TestCaseController {
@GetMapping("/get/{testCaseId}") @GetMapping("/get/{testCaseId}")
public TestCaseWithBLOBs getTestCase(@PathVariable String testCaseId) { public TestCaseWithBLOBs getTestCase(@PathVariable String testCaseId) {
checkOwnerService.checkTestCaseOwner(testCaseId);
return testCaseService.getTestCase(testCaseId); return testCaseService.getTestCase(testCaseId);
} }
@GetMapping("/project/{testCaseId}") @GetMapping("/project/{testCaseId}")
public Project getProjectByTestCaseId(@PathVariable String testCaseId) { public Project getProjectByTestCaseId(@PathVariable String testCaseId) {
checkOwnerService.checkTestCaseOwner(testCaseId);
return testCaseService.getProjectByTestCaseId(testCaseId); return testCaseService.getProjectByTestCaseId(testCaseId);
} }
@ -106,6 +108,7 @@ public class TestCaseController {
@PostMapping("/delete/{testCaseId}") @PostMapping("/delete/{testCaseId}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public int deleteTestCase(@PathVariable String testCaseId) { public int deleteTestCase(@PathVariable String testCaseId) {
checkOwnerService.checkTestCaseOwner(testCaseId);
return testCaseService.deleteTestCase(testCaseId); return testCaseService.deleteTestCase(testCaseId);
} }

View File

@ -43,11 +43,13 @@ public class TestCaseNodeController {
@GetMapping("/list/plan/{planId}") @GetMapping("/list/plan/{planId}")
public List<TestCaseNodeDTO> getNodeByPlanId(@PathVariable String planId) { public List<TestCaseNodeDTO> getNodeByPlanId(@PathVariable String planId) {
checkOwnerService.checkTestPlanOwner(planId);
return testCaseNodeService.getNodeByPlanId(planId); return testCaseNodeService.getNodeByPlanId(planId);
} }
@GetMapping("/list/review/{reviewId}") @GetMapping("/list/review/{reviewId}")
public List<TestCaseNodeDTO> getNodeByReviewId(@PathVariable String reviewId) { public List<TestCaseNodeDTO> getNodeByReviewId(@PathVariable String reviewId) {
checkOwnerService.checkTestReviewOwner(reviewId);
return testCaseNodeService.getNodeByReviewId(reviewId); return testCaseNodeService.getNodeByReviewId(reviewId);
} }

View File

@ -9,6 +9,7 @@ import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.service.CheckOwnerService;
import io.metersphere.track.dto.TestCaseReviewDTO; import io.metersphere.track.dto.TestCaseReviewDTO;
import io.metersphere.track.dto.TestReviewDTOWithMetric; import io.metersphere.track.dto.TestReviewDTOWithMetric;
import io.metersphere.track.request.testreview.ReviewRelevanceRequest; import io.metersphere.track.request.testreview.ReviewRelevanceRequest;
@ -32,6 +33,8 @@ public class TestCaseReviewController {
TestCaseReviewService testCaseReviewService; TestCaseReviewService testCaseReviewService;
@Resource @Resource
TestReviewProjectService testReviewProjectService; TestReviewProjectService testReviewProjectService;
@Resource
CheckOwnerService checkOwnerService;
@PostMapping("/list/{goPage}/{pageSize}") @PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<TestCaseReviewDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryCaseReviewRequest request) { public Pager<List<TestCaseReviewDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryCaseReviewRequest request) {
@ -71,6 +74,7 @@ public class TestCaseReviewController {
@GetMapping("/delete/{reviewId}") @GetMapping("/delete/{reviewId}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void deleteCaseReview(@PathVariable String reviewId) { public void deleteCaseReview(@PathVariable String reviewId) {
checkOwnerService.checkTestReviewOwner(reviewId);
testCaseReviewService.deleteCaseReview(reviewId); testCaseReviewService.deleteCaseReview(reviewId);
} }
@ -103,12 +107,14 @@ public class TestCaseReviewController {
@PostMapping("/get/{reviewId}") @PostMapping("/get/{reviewId}")
public TestCaseReview getTestReview(@PathVariable String reviewId) { public TestCaseReview getTestReview(@PathVariable String reviewId) {
checkOwnerService.checkTestReviewOwner(reviewId);
return testCaseReviewService.getTestReview(reviewId); return testCaseReviewService.getTestReview(reviewId);
} }
@PostMapping("/edit/status/{reviewId}") @PostMapping("/edit/status/{reviewId}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestPlanStatus(@PathVariable String reviewId) { public void editTestPlanStatus(@PathVariable String reviewId) {
checkOwnerService.checkTestReviewOwner(reviewId);
testCaseReviewService.editTestReviewStatus(reviewId); testCaseReviewService.editTestReviewStatus(reviewId);
} }

View File

@ -8,6 +8,7 @@ import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.service.CheckOwnerService;
import io.metersphere.track.dto.TestCaseReportMetricDTO; import io.metersphere.track.dto.TestCaseReportMetricDTO;
import io.metersphere.track.dto.TestPlanDTO; import io.metersphere.track.dto.TestPlanDTO;
import io.metersphere.track.dto.TestPlanDTOWithMetric; import io.metersphere.track.dto.TestPlanDTOWithMetric;
@ -32,6 +33,8 @@ public class TestPlanController {
TestPlanService testPlanService; TestPlanService testPlanService;
@Resource @Resource
TestPlanProjectService testPlanProjectService; TestPlanProjectService testPlanProjectService;
@Resource
CheckOwnerService checkOwnerService;
@PostMapping("/list/{goPage}/{pageSize}") @PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<TestPlanDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) { public Pager<List<TestPlanDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
@ -70,6 +73,7 @@ public class TestPlanController {
@PostMapping("/get/{testPlanId}") @PostMapping("/get/{testPlanId}")
public TestPlan getTestPlan(@PathVariable String testPlanId) { public TestPlan getTestPlan(@PathVariable String testPlanId) {
checkOwnerService.checkTestPlanOwner(testPlanId);
return testPlanService.getTestPlan(testPlanId); return testPlanService.getTestPlan(testPlanId);
} }
@ -88,12 +92,14 @@ public class TestPlanController {
@PostMapping("/edit/status/{planId}") @PostMapping("/edit/status/{planId}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestPlanStatus(@PathVariable String planId) { public void editTestPlanStatus(@PathVariable String planId) {
checkOwnerService.checkTestPlanOwner(planId);
testPlanService.editTestPlanStatus(planId); testPlanService.editTestPlanStatus(planId);
} }
@PostMapping("/delete/{testPlanId}") @PostMapping("/delete/{testPlanId}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public int deleteTestPlan(@PathVariable String testPlanId) { public int deleteTestPlan(@PathVariable String testPlanId) {
checkOwnerService.checkTestPlanOwner(testPlanId);
return testPlanService.deleteTestPlan(testPlanId); return testPlanService.deleteTestPlan(testPlanId);
} }
@ -109,6 +115,7 @@ public class TestPlanController {
@GetMapping("/project/name/{planId}") @GetMapping("/project/name/{planId}")
public String getProjectNameByPlanId(@PathVariable String planId) { public String getProjectNameByPlanId(@PathVariable String planId) {
checkOwnerService.checkTestPlanOwner(planId);
return testPlanService.getProjectNameByPlanId(planId); return testPlanService.getProjectNameByPlanId(planId);
} }

View File

@ -161,4 +161,7 @@ test_track.length_less_than=The title is too long, the length must be less than
# check owner # check owner
check_owner_project=The current user does not have permission to operate this project check_owner_project=The current user does not have permission to operate this project
check_owner_test=The current user does not have permission to operate this test check_owner_test=The current user does not have permission to operate this test
check_owner_case=The current user does not have permission to operate this use case
check_owner_plan=The current user does not have permission to operate this plan
check_owner_review=The current user does not have permission to operate this review
upload_content_is_null=Imported content is empty upload_content_is_null=Imported content is empty

View File

@ -161,4 +161,7 @@ test_track.length_less_than=标题过长,字数必须小于
# check owner # check owner
check_owner_project=当前用户没有操作此项目的权限 check_owner_project=当前用户没有操作此项目的权限
check_owner_test=当前用户没有操作此测试的权限 check_owner_test=当前用户没有操作此测试的权限
check_owner_case=当前用户没有操作此用例的权限
check_owner_plan=当前用户没有操作此计划的权限
check_owner_review=当前用户没有操作此评审的权限
upload_content_is_null=导入内容为空 upload_content_is_null=导入内容为空

View File

@ -162,4 +162,7 @@ test_track.length_less_than=標題過長,字數必須小於
# check owner # check owner
check_owner_project=當前用戶沒有操作此項目的權限 check_owner_project=當前用戶沒有操作此項目的權限
check_owner_test=當前用戶沒有操作此測試的權限 check_owner_test=當前用戶沒有操作此測試的權限
check_owner_case=當前用戶沒有操作此用例的權限
check_owner_plan=當前用戶沒有操作此計劃的權限
check_owner_review=當前用戶沒有操作此評審的權限
upload_content_is_null=導入內容為空 upload_content_is_null=導入內容為空

View File

@ -35,7 +35,6 @@
@filter-change="filter" @filter-change="filter"
@select-all="handleSelectAll" @select-all="handleSelectAll"
@select="handleSelectionChange" @select="handleSelectionChange"
@row-click="showDetail"
row-key="id" row-key="id"
class="test-content adjust-table"> class="test-content adjust-table">
<el-table-column <el-table-column
@ -54,7 +53,13 @@
<el-table-column <el-table-column
prop="name" prop="name"
:label="$t('commons.name')" :label="$t('commons.name')"
show-overflow-tooltip> show-overflow-tooltip
>
<template v-slot:default="scope">
<div @mouseover="showDetail(scope.row)">
<p>{{ scope.row.name }}</p>
</div>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="priority" prop="priority"