fix(任务中心): 修复任务中心测试计划列表权限问题

This commit is contained in:
wxg0103 2024-06-20 09:56:50 +08:00 committed by wxg0103
parent 3cf65b590b
commit 165bf2676f
10 changed files with 26 additions and 22 deletions

View File

@ -5,7 +5,6 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.definition.ApiReportDTO; import io.metersphere.api.dto.definition.ApiReportDTO;
import io.metersphere.api.dto.definition.ApiReportDetailDTO; import io.metersphere.api.dto.definition.ApiReportDetailDTO;
import io.metersphere.api.service.definition.ApiReportService; import io.metersphere.api.service.definition.ApiReportService;
import io.metersphere.plan.constants.TestPlanResourceConfig;
import io.metersphere.plan.dto.request.*; import io.metersphere.plan.dto.request.*;
import io.metersphere.plan.dto.response.TestPlanApiCasePageResponse; import io.metersphere.plan.dto.response.TestPlanApiCasePageResponse;
import io.metersphere.plan.dto.response.TestPlanAssociationResponse; import io.metersphere.plan.dto.response.TestPlanAssociationResponse;
@ -148,7 +147,7 @@ public class TestPlanApiCaseController {
@GetMapping("/report/get/{id}") @GetMapping("/report/get/{id}")
@Operation(summary = "测试计划-用例列表-执行结果获取") @Operation(summary = "测试计划-用例列表-执行结果获取")
@CheckOwner(resourceId = "#id", resourceType = "api_report") @CheckOwner(resourceId = "#id", resourceType = "api_report")
@RequiresPermissions(value = {PermissionConstants.TEST_PLAN_READ, PermissionConstants.TEST_PLAN_REPORT_READ}, logical = Logical.OR) @RequiresPermissions(value = {PermissionConstants.TEST_PLAN_REPORT_READ, PermissionConstants.TEST_PLAN_READ_EXECUTE}, logical = Logical.OR)
public ApiReportDTO get(@PathVariable String id) { public ApiReportDTO get(@PathVariable String id) {
testPlanApiCaseService.checkReportIsTestPlan(id); testPlanApiCaseService.checkReportIsTestPlan(id);
return apiReportService.get(id); return apiReportService.get(id);
@ -157,7 +156,7 @@ public class TestPlanApiCaseController {
@GetMapping("/report/get/detail/{reportId}/{stepId}") @GetMapping("/report/get/detail/{reportId}/{stepId}")
@Operation(summary = "测试计划-用例列表-执行结果获取-报告详情获取") @Operation(summary = "测试计划-用例列表-执行结果获取-报告详情获取")
@CheckOwner(resourceId = "#reportId", resourceType = "api_report") @CheckOwner(resourceId = "#reportId", resourceType = "api_report")
@RequiresPermissions(value = {PermissionConstants.TEST_PLAN_READ, PermissionConstants.TEST_PLAN_REPORT_READ}, logical = Logical.OR) @RequiresPermissions(value = {PermissionConstants.TEST_PLAN_REPORT_READ, PermissionConstants.TEST_PLAN_READ_EXECUTE}, logical = Logical.OR)
public List<ApiReportDetailDTO> getDetail(@PathVariable String reportId, public List<ApiReportDetailDTO> getDetail(@PathVariable String reportId,
@PathVariable String stepId) { @PathVariable String stepId) {
testPlanApiCaseService.checkReportIsTestPlan(reportId); testPlanApiCaseService.checkReportIsTestPlan(reportId);

View File

@ -128,7 +128,7 @@ public class TestPlanApiScenarioController {
@GetMapping("/report/get/{id}") @GetMapping("/report/get/{id}")
@Operation(summary = "测试计划-计划详情-场景用例列表-查看执行结果") @Operation(summary = "测试计划-计划详情-场景用例列表-查看执行结果")
@CheckOwner(resourceId = "#id", resourceType = "api_scenario_report") @CheckOwner(resourceId = "#id", resourceType = "api_scenario_report")
@RequiresPermissions(value = {PermissionConstants.TEST_PLAN_READ, PermissionConstants.TEST_PLAN_REPORT_READ}, logical = Logical.OR) @RequiresPermissions(value = {PermissionConstants.TEST_PLAN_REPORT_READ, PermissionConstants.TEST_PLAN_READ_EXECUTE}, logical = Logical.OR)
public ApiScenarioReportDTO get(@PathVariable String id) { public ApiScenarioReportDTO get(@PathVariable String id) {
testPlanApiScenarioService.checkReportIsTestPlan(id); testPlanApiScenarioService.checkReportIsTestPlan(id);
return apiScenarioReportService.get(id); return apiScenarioReportService.get(id);
@ -137,7 +137,7 @@ public class TestPlanApiScenarioController {
@GetMapping("report/get/detail/{reportId}/{stepId}") @GetMapping("report/get/detail/{reportId}/{stepId}")
@Operation(summary = "测试计划-计划详情-场景用例列表-执行结果详情获取") @Operation(summary = "测试计划-计划详情-场景用例列表-执行结果详情获取")
@CheckOwner(resourceId = "#reportId", resourceType = "api_scenario_report") @CheckOwner(resourceId = "#reportId", resourceType = "api_scenario_report")
@RequiresPermissions(value = {PermissionConstants.TEST_PLAN_READ, PermissionConstants.TEST_PLAN_REPORT_READ}, logical = Logical.OR) @RequiresPermissions(value = {PermissionConstants.TEST_PLAN_REPORT_READ, PermissionConstants.TEST_PLAN_READ_EXECUTE}, logical = Logical.OR)
public List<ApiScenarioReportDetailDTO> getDetail(@PathVariable String reportId, public List<ApiScenarioReportDetailDTO> getDetail(@PathVariable String reportId,
@PathVariable String stepId) { @PathVariable String stepId) {
testPlanApiScenarioService.checkReportIsTestPlan(reportId); testPlanApiScenarioService.checkReportIsTestPlan(reportId);

View File

@ -24,6 +24,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -97,7 +98,7 @@ public class TestPlanReportController {
@GetMapping("/get/{reportId}") @GetMapping("/get/{reportId}")
@Operation(summary = "测试计划-报告-详情") @Operation(summary = "测试计划-报告-详情")
@RequiresPermissions(PermissionConstants.TEST_PLAN_REPORT_READ) @RequiresPermissions(value = {PermissionConstants.TEST_PLAN_REPORT_READ, PermissionConstants.TEST_PLAN_READ_EXECUTE}, logical = Logical.OR)
@CheckOwner(resourceId = "#reportId", resourceType = "test_plan_report") @CheckOwner(resourceId = "#reportId", resourceType = "test_plan_report")
public TestPlanReportDetailResponse get(@PathVariable String reportId) { public TestPlanReportDetailResponse get(@PathVariable String reportId) {
return testPlanReportService.getReport(reportId); return testPlanReportService.getReport(reportId);
@ -121,7 +122,7 @@ public class TestPlanReportController {
@PostMapping("/detail/bug/page") @PostMapping("/detail/bug/page")
@Operation(summary = "测试计划-报告-详情-缺陷分页查询") @Operation(summary = "测试计划-报告-详情-缺陷分页查询")
@RequiresPermissions(PermissionConstants.TEST_PLAN_REPORT_READ) @RequiresPermissions(value = {PermissionConstants.TEST_PLAN_REPORT_READ, PermissionConstants.TEST_PLAN_READ_EXECUTE}, logical = Logical.OR)
@CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report") @CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report")
public Pager<List<BugDTO>> pageBug(@Validated @RequestBody TestPlanReportDetailPageRequest request) { public Pager<List<BugDTO>> pageBug(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
@ -131,7 +132,7 @@ public class TestPlanReportController {
@PostMapping("/detail/functional/case/page") @PostMapping("/detail/functional/case/page")
@Operation(summary = "测试计划-报告-详情-功能用例分页查询") @Operation(summary = "测试计划-报告-详情-功能用例分页查询")
@RequiresPermissions(PermissionConstants.TEST_PLAN_REPORT_READ) @RequiresPermissions(value = {PermissionConstants.TEST_PLAN_REPORT_READ, PermissionConstants.TEST_PLAN_READ_EXECUTE}, logical = Logical.OR)
@CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report") @CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report")
public Pager<List<ReportDetailCasePageDTO>> pageFunctionalCase(@Validated @RequestBody TestPlanReportDetailPageRequest request) { public Pager<List<ReportDetailCasePageDTO>> pageFunctionalCase(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
@ -141,7 +142,7 @@ public class TestPlanReportController {
@PostMapping("/detail/api/case/page") @PostMapping("/detail/api/case/page")
@Operation(summary = "测试计划-报告-详情-接口用例分页查询") @Operation(summary = "测试计划-报告-详情-接口用例分页查询")
@RequiresPermissions(PermissionConstants.TEST_PLAN_REPORT_READ) @RequiresPermissions(value = {PermissionConstants.TEST_PLAN_REPORT_READ, PermissionConstants.TEST_PLAN_READ_EXECUTE}, logical = Logical.OR)
@CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report") @CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report")
public Pager<List<ReportDetailCasePageDTO>> pageApiCase(@Validated @RequestBody TestPlanReportDetailPageRequest request) { public Pager<List<ReportDetailCasePageDTO>> pageApiCase(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
@ -151,7 +152,7 @@ public class TestPlanReportController {
@PostMapping("/detail/scenario/case/page") @PostMapping("/detail/scenario/case/page")
@Operation(summary = "测试计划-报告-详情-场景用例分页查询") @Operation(summary = "测试计划-报告-详情-场景用例分页查询")
@RequiresPermissions(PermissionConstants.TEST_PLAN_REPORT_READ) @RequiresPermissions(value = {PermissionConstants.TEST_PLAN_REPORT_READ, PermissionConstants.TEST_PLAN_READ_EXECUTE}, logical = Logical.OR)
@CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report") @CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report")
public Pager<List<ReportDetailCasePageDTO>> pageScenarioCase(@Validated @RequestBody TestPlanReportDetailPageRequest request) { public Pager<List<ReportDetailCasePageDTO>> pageScenarioCase(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
@ -161,7 +162,7 @@ public class TestPlanReportController {
@PostMapping("/detail/plan/report/page") @PostMapping("/detail/plan/report/page")
@Operation(summary = "测试计划-报告-集合报告详情") @Operation(summary = "测试计划-报告-集合报告详情")
@RequiresPermissions(PermissionConstants.TEST_PLAN_REPORT_READ) @RequiresPermissions(value = {PermissionConstants.TEST_PLAN_REPORT_READ, PermissionConstants.TEST_PLAN_READ_EXECUTE}, logical = Logical.OR)
@CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report") @CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report")
public Pager<List<TestPlanReportDetailResponse>> planReportPage(@Validated @RequestBody TestPlanReportDetailPageRequest request) { public Pager<List<TestPlanReportDetailResponse>> planReportPage(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),

View File

@ -453,7 +453,7 @@ public class TestPlanApiCaseControllerTests extends BaseTest {
// @@校验权限 // @@校验权限
requestGetPermissionTest(PermissionConstants.TEST_PLAN_READ, "/report/get/plan-test-report-id"); requestGetPermissionTest(PermissionConstants.TEST_PLAN_REPORT_READ, "/report/get/plan-test-report-id");
List<ApiReportDetail> reportsDetail = new ArrayList<>(); List<ApiReportDetail> reportsDetail = new ArrayList<>();
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
@ -471,7 +471,7 @@ public class TestPlanApiCaseControllerTests extends BaseTest {
this.requestGetWithOk("/report/get/detail/plan-test-report-id" + "/" + "plan-test-report-step-id1") this.requestGetWithOk("/report/get/detail/plan-test-report-id" + "/" + "plan-test-report-step-id1")
.andReturn(); .andReturn();
requestGetPermissionTest(PermissionConstants.TEST_PLAN_READ, "/report/get/detail/plan-test-report-id" + "/" + "plan-test-report-step-id1"); requestGetPermissionTest(PermissionConstants.TEST_PLAN_REPORT_READ, "/report/get/detail/plan-test-report-id" + "/" + "plan-test-report-step-id1");
} }
@Test @Test

View File

@ -500,7 +500,7 @@ public class TestPlanApiScenarioControllerTests extends BaseTest {
apiScenarioReportMapper.updateByPrimaryKeySelective(scenarioReport1); apiScenarioReportMapper.updateByPrimaryKeySelective(scenarioReport1);
// @@校验权限 // @@校验权限
requestGetPermissionTest(PermissionConstants.TEST_PLAN_READ, "/report/get/plan-test-scenario-report-id"); requestGetPermissionTest(PermissionConstants.TEST_PLAN_REPORT_READ, "/report/get/plan-test-scenario-report-id");
List<ApiScenarioReportDetail> reportsDetails = new ArrayList<>(); List<ApiScenarioReportDetail> reportsDetails = new ArrayList<>();
List<ApiScenarioReportDetailBlob> reportBlogs = new ArrayList<>(); List<ApiScenarioReportDetailBlob> reportBlogs = new ArrayList<>();
@ -527,7 +527,7 @@ public class TestPlanApiScenarioControllerTests extends BaseTest {
this.requestGetWithOk("/report/get/detail/plan-test-scenario-report-id/plan-test-scenario-report-step-id1") this.requestGetWithOk("/report/get/detail/plan-test-scenario-report-id/plan-test-scenario-report-step-id1")
.andReturn(); .andReturn();
requestGetPermissionTest(PermissionConstants.TEST_PLAN_READ, "/report/get/detail/plan-test-scenario-report-id/plan-test-scenario-report-step-id1"); requestGetPermissionTest(PermissionConstants.TEST_PLAN_REPORT_READ, "/report/get/detail/plan-test-scenario-report-id/plan-test-scenario-report-step-id1");
} }
} }

View File

@ -190,4 +190,5 @@ export default {
'common.name': 'name', 'common.name': 'name',
'common.stopped': 'Stopped', 'common.stopped': 'Stopped',
'common.config': 'Config', 'common.config': 'Config',
'common.executionResult': 'Execution result',
}; };

View File

@ -159,17 +159,17 @@
organization: { organization: {
stop: ['ORGANIZATION_TASK_CENTER:READ+STOP', 'PROJECT_TEST_PLAN:READ+EXECUTE'], stop: ['ORGANIZATION_TASK_CENTER:READ+STOP', 'PROJECT_TEST_PLAN:READ+EXECUTE'],
jump: ['PROJECT_TEST_PLAN:READ'], jump: ['PROJECT_TEST_PLAN:READ'],
report: ['PROJECT_TEST_PLAN:READ', 'PROJECT_TEST_PLAN_REPORT:READ'], report: ['PROJECT_TEST_PLAN:READ+EXECUTE', 'PROJECT_TEST_PLAN_REPORT:READ'],
}, },
system: { system: {
stop: ['SYSTEM_TASK_CENTER:READ+STOP', 'PROJECT_TEST_PLAN:READ+EXECUTE'], stop: ['SYSTEM_TASK_CENTER:READ+STOP', 'PROJECT_TEST_PLAN:READ+EXECUTE'],
jump: ['PROJECT_TEST_PLAN:READ'], jump: ['PROJECT_TEST_PLAN:READ'],
report: ['PROJECT_TEST_PLAN:READ', 'PROJECT_TEST_PLAN_REPORT:READ'], report: ['PROJECT_TEST_PLAN:READ+EXECUTE', 'PROJECT_TEST_PLAN_REPORT:READ'],
}, },
project: { project: {
stop: ['PROJECT_TEST_PLAN:READ+EXECUTE'], stop: ['PROJECT_TEST_PLAN:READ+EXECUTE'],
jump: ['PROJECT_TEST_PLAN:READ'], jump: ['PROJECT_TEST_PLAN:READ'],
report: ['PROJECT_TEST_PLAN:READ', 'PROJECT_TEST_PLAN_REPORT:READ'], report: ['PROJECT_TEST_PLAN:READ+EXECUTE', 'PROJECT_TEST_PLAN_REPORT:READ'],
}, },
}; };
@ -428,6 +428,9 @@
} }
function showDetail(id: string) { function showDetail(id: string) {
if (!hasJumpPermission.value) {
return;
}
openNewPage(RouteEnum.TEST_PLAN_INDEX_DETAIL, { openNewPage(RouteEnum.TEST_PLAN_INDEX_DETAIL, {
id, id,
}); });

View File

@ -45,8 +45,8 @@
<MsTag theme="light" :type="record.integrated ? 'primary' : undefined"> <MsTag theme="light" :type="record.integrated ? 'primary' : undefined">
{{ {{
record.integrated record.integrated
? t('report.detail.testPlanGroup.testGroupReport') ? t('report.detail.testPlanGroupReport')
: t('report.detail.testPlanGroup.testReport') : t('report.detail.testReport')
}} }}
</MsTag> </MsTag>
</template> </template>

View File

@ -45,4 +45,6 @@ export default {
'report.detail.testPlanGroup.result': 'Result', 'report.detail.testPlanGroup.result': 'Result',
'report.detail.testPlanGroup.useCasesCount': 'Use cases', 'report.detail.testPlanGroup.useCasesCount': 'Use cases',
'report.detail.testPlanGroup.viewReport': 'View Report', 'report.detail.testPlanGroup.viewReport': 'View Report',
'report.detail.testReport': 'Test report',
'report.detail.testPlanGroupReport': 'Test group report',
}; };

View File

@ -47,6 +47,4 @@ export default {
'report.detail.testPlanGroup.result': '结果', 'report.detail.testPlanGroup.result': '结果',
'report.detail.testPlanGroup.useCasesCount': '用例数', 'report.detail.testPlanGroup.useCasesCount': '用例数',
'report.detail.testPlanGroup.viewReport': '查看报告', 'report.detail.testPlanGroup.viewReport': '查看报告',
'report.detail.testPlanGroup.testGroupReport': '测试组报告',
'report.detail.testPlanGroup.testReport': '测试报告',
}; };