Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
q4speed 2020-05-25 15:24:27 +08:00
commit b6fef27f69
17 changed files with 66 additions and 34 deletions

View File

@ -54,7 +54,6 @@ public class ProjectController {
}
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresRoles(RoleConstants.TEST_MANAGER)
public Pager<List<ProjectDTO>> getProjectList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ProjectRequest request) {
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);

View File

@ -27,7 +27,7 @@ public class UserRoleController {
}
@GetMapping("/list/ws/{workspaceId}/{userId}")
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN}, logical = Logical.OR)
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public List<Role> getWorkspaceMemberRoles(@PathVariable String workspaceId, @PathVariable String userId) {
return userRoleService.getWorkspaceMemberRoles(workspaceId, userId);
}

View File

@ -8,6 +8,7 @@ import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.DashboardTestDTO;
import io.metersphere.dto.LoadTestDTO;
import io.metersphere.i18n.Translator;
@ -127,6 +128,7 @@ public class PerformanceTestService {
}
final LoadTestWithBLOBs loadTest = new LoadTestWithBLOBs();
loadTest.setUserId(SessionUtils.getUser().getId());
loadTest.setId(UUID.randomUUID().toString());
loadTest.setName(request.getName());
loadTest.setProjectId(request.getProjectId());
@ -210,6 +212,7 @@ public class PerformanceTestService {
testReport.setUpdateTime(engine.getStartTime());
testReport.setTestId(loadTest.getId());
testReport.setName(loadTest.getName());
testReport.setUserId(SessionUtils.getUser().getId());
// 启动测试
try {

View File

@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.Project;
import io.metersphere.base.domain.TestCase;
import io.metersphere.base.domain.TestCaseWithBLOBs;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
@ -13,6 +14,8 @@ import io.metersphere.track.dto.TestCaseDTO;
import io.metersphere.track.request.testcase.QueryTestCaseRequest;
import io.metersphere.track.request.testcase.TestCaseBatchRequest;
import io.metersphere.track.service.TestCaseService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -62,36 +65,43 @@ public class TestCaseController {
}
@PostMapping("/add")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void addTestCase(@RequestBody TestCaseWithBLOBs testCase){
testCaseService.addTestCase(testCase);
}
@PostMapping("/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestCase(@RequestBody TestCaseWithBLOBs testCase){
testCaseService.editTestCase(testCase);
}
@PostMapping("/delete/{testCaseId}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public int deleteTestCase(@PathVariable String testCaseId){
return testCaseService.deleteTestCase(testCaseId);
}
@PostMapping("/import/{projectId}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public ExcelResponse testCaseImport(MultipartFile file, @PathVariable String projectId) throws NoSuchFieldException {
return testCaseService.testCaseImport(file, projectId);
}
@GetMapping("/export/template")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void testCaseTemplateExport(HttpServletResponse response){
testCaseService.testCaseTemplateExport(response);
}
@PostMapping("/batch/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestCaseBath(@RequestBody TestCaseBatchRequest request){
testCaseService.editTestCaseBath(request);
}
@PostMapping("/batch/delete")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void deleteTestCaseBath(@RequestBody TestCaseBatchRequest request){
testCaseService.deleteTestCaseBath(request);
}

View File

@ -1,9 +1,12 @@
package io.metersphere.track.controller;
import io.metersphere.base.domain.TestCaseNode;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.track.dto.TestCaseNodeDTO;
import io.metersphere.track.request.testcase.DragNodeRequest;
import io.metersphere.track.service.TestCaseNodeService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -32,22 +35,26 @@ public class TestCaseNodeController {
}
@PostMapping("/add")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public String addNode(@RequestBody TestCaseNode node){
return testCaseNodeService.addNode(node);
}
@PostMapping("/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public int editNode(@RequestBody DragNodeRequest node){
return testCaseNodeService.editNode(node);
}
@PostMapping("/delete")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public int deleteNode(@RequestBody List<String> nodeIds){
//nodeIds 包含删除节点ID及其所有子节点ID
return testCaseNodeService.deleteNode(nodeIds);
}
@PostMapping("/drag")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void dragNode(@RequestBody DragNodeRequest node){
testCaseNodeService.dragNode(node);
}

View File

@ -1,9 +1,12 @@
package io.metersphere.track.controller;
import io.metersphere.base.domain.TestCaseReport;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.track.request.testCaseReport.CreateReportRequest;
import io.metersphere.track.dto.TestCaseReportMetricDTO;
import io.metersphere.track.service.TestCaseReportService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -27,16 +30,19 @@ public class TestCaseReportController {
}
@PostMapping("/add")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public String addByTemplateId(@RequestBody CreateReportRequest request){
return testCaseReportService.addTestCaseReportByTemplateId(request);
}
@PostMapping("/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void edit(@RequestBody TestCaseReport TestCaseReport){
testCaseReportService.editTestCaseReport(TestCaseReport);
}
@PostMapping("/delete/{id}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public int delete(@PathVariable String id){
return testCaseReportService.deleteTestCaseReport(id);
}

View File

@ -1,8 +1,11 @@
package io.metersphere.track.controller;
import io.metersphere.base.domain.TestCaseReportTemplate;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.track.request.testCaseReport.QueryTemplateRequest;
import io.metersphere.track.service.TestCaseReportTemplateService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -26,16 +29,19 @@ public class TestCaseReportTemplateController {
}
@PostMapping("/add")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void add(@RequestBody TestCaseReportTemplate testCaseReportTemplate){
testCaseReportTemplateService.addTestCaseReportTemplate(testCaseReportTemplate);
}
@PostMapping("/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void edit(@RequestBody TestCaseReportTemplate testCaseReportTemplate){
testCaseReportTemplateService.editTestCaseReportTemplate(testCaseReportTemplate);
}
@PostMapping("/delete/{id}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public int delete(@PathVariable String id){
return testCaseReportTemplateService.deleteTestCaseReportTemplate(id);
}

View File

@ -3,6 +3,7 @@ package io.metersphere.track.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.TestPlan;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
@ -12,6 +13,8 @@ import io.metersphere.track.dto.TestPlanDTOWithMetric;
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.service.TestPlanService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -56,16 +59,19 @@ public class TestPlanController {
}
@PostMapping("/add")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void addTestPlan(@RequestBody TestPlan testPlan){
testPlanService.addTestPlan(testPlan);
}
@PostMapping("/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestPlan(@RequestBody TestPlan testPlan){
testPlanService.editTestPlan(testPlan);
}
@PostMapping("/delete/{testPlanId}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public int deleteTestPlan(@PathVariable String testPlanId){
return testPlanService.deleteTestPlan(testPlanId);
}

View File

@ -4,12 +4,15 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.TestPlanTestCase;
import io.metersphere.base.domain.TestPlanTestCaseWithBLOBs;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.track.request.testcase.TestPlanCaseBatchRequest;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
import io.metersphere.track.dto.TestPlanCaseDTO;
import io.metersphere.track.service.TestPlanTestCaseService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -49,21 +52,25 @@ public class TestPlanTestCaseController {
}
@PostMapping("/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestCase(@RequestBody TestPlanTestCaseWithBLOBs testPlanTestCase){
testPlanTestCaseService.editTestCase(testPlanTestCase);
}
@PostMapping("/batch/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestCaseBath(@RequestBody TestPlanCaseBatchRequest request){
testPlanTestCaseService.editTestCaseBath(request);
}
@PostMapping("/batch/delete")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void deleteTestCaseBath(@RequestBody TestPlanCaseBatchRequest request){
testPlanTestCaseService.deleteTestCaseBath(request);
}
@PostMapping("/delete/{id}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public int deleteTestCase(@PathVariable String id){
return testPlanTestCaseService.deleteTestCase(id);
}

View File

@ -1,5 +1,5 @@
<template>
<el-button @click="exec()" plain :type="type" :icon="icon" :size="size">
<el-button v-permission="['test_manager', 'test_user']" @click="exec()" plain :type="type" :icon="icon" :size="size">
{{content}}
</el-button>
</template>

View File

@ -1,5 +1,6 @@
<template>
<ms-tip-button @click="exec"
<ms-tip-button v-permission="['test_manager', 'test_user']"
@click="exec"
@clickStop="clickStop"
:type="type"
:tip="tip"

View File

@ -23,7 +23,7 @@
</el-menu-item>
</el-submenu>
<el-submenu index="3" v-permission="['test_manager','test_user','test_viewer']" v-if="isCurrentWorkspaceUser">
<el-submenu index="3" v-permission="['test_manager']" v-if="isCurrentWorkspaceUser">
<template v-slot:title>
<font-awesome-icon class="icon workspace" :icon="['far', 'list-alt']" size="lg"/>
<span>{{$t('commons.workspace')}}</span>

View File

@ -14,7 +14,7 @@
@refresh="refresh"
:tree-nodes="treeNodes"
:type="'edit'"
:draggable="true"
:draggable="nodeTreeDraggable"
:select-node.sync="selectNode"
@refreshTable="refreshTable"
:current-project="currentProject"
@ -54,13 +54,14 @@
import NodeTree from '../common/NodeTree';
import TestCaseEdit from './components/TestCaseEdit';
import {CURRENT_PROJECT} from '../../../../common/js/constants';
import {CURRENT_PROJECT, ROLE_TEST_MANAGER, ROLE_TEST_USER} from '../../../../common/js/constants';
import TestCaseList from "./components/TestCaseList";
import SelectMenu from "../common/SelectMenu";
import TestCaseMove from "./components/TestCaseMove";
import MsContainer from "../../common/components/MsContainer";
import MsAsideContainer from "../../common/components/MsAsideContainer";
import MsMainContainer from "../../common/components/MsMainContainer";
import {hasRoles} from "../../../../common/js/utils";
export default {
name: "TestCase",
@ -81,6 +82,7 @@
selectParentNodes: [],
testCaseReadOnly: true,
selectNode: {},
nodeTreeDraggable: true,
}
},
mounted() {
@ -213,6 +215,9 @@
this.refresh();
},
getNodeTree() {
if (!hasRoles(ROLE_TEST_USER, ROLE_TEST_MANAGER)) {
this.nodeTreeDraggable = false;
}
if (this.currentProject) {
this.result = this.$get("/case/node/list/" + this.currentProject.id, response => {
this.treeNodes = response.data;

View File

@ -17,7 +17,6 @@
action=""
:on-exceed="handleExceed"
:beforeUpload="UploadValidate"
:on-success="handleSuccess"
:on-error="handleError"
:show-file-list="false"
:http-request="upload"
@ -82,18 +81,6 @@
this.errList = [];
return true;
},
handleSuccess(response) {
// let res = response.data;
// if (res.success) {
// this.$success(this.$t('test_track.case.import.success'));
// this.dialogVisible = false;
// this.$emit("refresh");
// } else {
// this.errList = res.errList;
// }
// this.fileList = [];
},
handleError(err, file, fileList) {
this.isLoading = false;
this.$error(err.message);
@ -106,8 +93,6 @@
this.dialogVisible = true;
},
downloadTemplate() {
// this.$get('/test/case/export/template');
// fileDownload('/test/case/export/template', {});
this.$fileDownload('/test/case/export/template');
},
upload(file) {

View File

@ -2,7 +2,7 @@
<div v-loading="result.loading">
<el-input :placeholder="$t('test_track.module.search')" v-model="filterText" size="small">
<template v-if="type == 'edit'" v-slot:append>
<el-button icon="el-icon-folder-add" @click="openEditNodeDialog('add')"></el-button>
<el-button v-permission="['test_manager', 'test_user']" icon="el-icon-folder-add" @click="openEditNodeDialog('add')"></el-button>
</template>
</el-input>
@ -24,7 +24,7 @@
<span class="node-title">{{node.label}}</span>
<span v-if="type == 'edit'" class="node-operate child">
<span v-if="type == 'edit'" class="node-operate child" v-permission="['test_manager', 'test_user']">
<el-tooltip
class="item"
effect="dark"

View File

@ -8,18 +8,16 @@
<el-menu-item :index="'/track/home'">
{{ $t("i18n.home") }}
</el-menu-item>
<el-submenu v-if="isCurrentWorkspaceUser"
index="3" popper-class="submenu" v-permission="['test_manager']" >
<el-submenu v-if="isCurrentWorkspaceUser" index="3" popper-class="submenu">
<template v-slot:title>{{$t('commons.project')}}</template>
<ms-recent-list :options="projectRecent"/>
<el-divider/>
<ms-show-all :index="'/track/project/all'"/>
<ms-create-button :index="'/track/project/create'" :title="$t('project.create')"/>
<ms-create-button v-permission="['test_manager', 'test_user']" :index="'/track/project/create'" :title="$t('project.create')"/>
</el-submenu>
<el-submenu v-if="isCurrentWorkspaceUser"
index="6" popper-class="submenu" v-permission="['test_manager', 'test_user']">
index="6" popper-class="submenu">
<template v-slot:title>{{$t('test_track.case.test_case')}}</template>
<ms-recent-list :options="caseRecent"/>
<el-divider/>
@ -27,14 +25,13 @@
<el-menu-item :index="testCaseEditPath" class="blank_item"></el-menu-item>
</el-submenu>
<el-submenu v-if="isCurrentWorkspaceUser"
index="7" popper-class="submenu" v-permission="['test_manager', 'test_user', 'test_viewer']">
<el-submenu v-if="isCurrentWorkspaceUser" index="7" popper-class="submenu">
<template v-slot:title>{{$t('test_track.plan.test_plan')}}</template>
<ms-recent-list :options="planRecent"/>
<el-divider/>
<ms-show-all :index="'/track/plan/all'"/>
<el-menu-item :index="testPlanViewPath" class="blank_item"></el-menu-item>
<ms-create-button :index="'/track/plan/create'" :title="$t('test_track.plan.create_plan')"/>
<ms-create-button v-permission="['test_manager', 'test_user']" :index="'/track/plan/create'" :title="$t('test_track.plan.create_plan')"/>
</el-submenu>
</el-menu>
</el-col>

View File

@ -19,8 +19,8 @@
</div>
</el-col>
<el-col :span="12" class="head-right">
<el-button plain size="mini" @click="handleSave">{{$t('commons.save')}}</el-button>
<el-button plain size="mini" @click="handleEdit">{{$t('test_track.plan_view.edit_component')}}</el-button>
<el-button v-permission="['test_manager', 'test_user']" plain size="mini" @click="handleSave">{{$t('commons.save')}}</el-button>
<el-button v-permission="['test_manager', 'test_user']" plain size="mini" @click="handleEdit">{{$t('test_track.plan_view.edit_component')}}</el-button>
</el-col>
</el-row>