fix(接口测试): 修复接口测试相关权限问题

--bug=1027038 --user=王孝刚 【接口测试】只读用户-快捷调试-可点击另存为新用例-进入创建用例页面-但是无法填名称
https://www.tapd.cn/55049933/s/1382020
--bug=1027033 --user=王孝刚
【接口测试】只读用户-接口定义-环境配置-可编辑环境
https://www.tapd.cn/55049933/s/1382022
--bug=1027012 --user=王孝刚
【接口测试】只读用户开启场景调试权限-场景详情-点击调试没反应
https://www.tapd.cn/55049933/s/1382025
--bug=1026828 --user=王孝刚
【系统设置】用户组和权限-项目管理员未开启性能测试报告的“删除权限”,导致用户不能修改性能测试的报告名称。
https://www.tapd.cn/55049933/s/1382027
This commit is contained in:
wxg0103 2023-06-14 19:06:08 +08:00 committed by 刘瑞斌
parent e12fd7ddcb
commit f84fc65467
11 changed files with 69 additions and 38 deletions

View File

@ -568,7 +568,7 @@ import { KeyValue } from '@/business/definition/model/ApiTestModel';
import { getCurrentProjectID, getCurrentUser } from 'metersphere-frontend/src/utils/token'; import { getCurrentProjectID, getCurrentUser } from 'metersphere-frontend/src/utils/token';
import { getUUID, objToStrMap, strMapToObj } from 'metersphere-frontend/src/utils'; import { getUUID, objToStrMap, strMapToObj } from 'metersphere-frontend/src/utils';
import { hasLicense, hasPermission } from 'metersphere-frontend/src/utils/permission'; import { hasLicense, hasPermissions } from 'metersphere-frontend/src/utils/permission';
import OutsideClick from './common/outside-click'; import OutsideClick from './common/outside-click';
import { import {
getReportMessageSocket, getReportMessageSocket,
@ -1723,7 +1723,7 @@ export default {
}); });
}, },
runDebug(runScenario) { runDebug(runScenario) {
if (!hasPermission('PROJECT_API_SCENARIO:READ+EDIT')) { if (!hasPermissions('PROJECT_API_SCENARIO:READ+DEBUG','PROJECT_API_SCENARIO:READ+RUN')) {
return; return;
} }
this.mergeScenario(this.scenarioDefinition); this.mergeScenario(this.scenarioDefinition);

View File

@ -65,18 +65,18 @@
<div <div
v-if="!ifFromVariableAdvance" v-if="!ifFromVariableAdvance"
class="header-right" class="header-right"
@click.stop @click.stop>
v-permission="[
'PROJECT_API_SCENARIO:READ+EDIT',
'PROJECT_API_SCENARIO:READ+CREATE',
'PROJECT_API_SCENARIO:READ+COPY',
]">
<slot name="message" v-show="!isMax"></slot> <slot name="message" v-show="!isMax"></slot>
<slot name="debugStepCode"></slot> <slot name="debugStepCode"></slot>
<slot name="button" v-if="showVersion"></slot> <slot name="button" v-if="showVersion"></slot>
<el-tooltip :content="$t('test_resource_pool.enable_disable')" placement="top" v-if="showBtn"> <el-tooltip :content="$t('test_resource_pool.enable_disable')" placement="top" v-if="showBtn"
v-permission="[
'PROJECT_API_SCENARIO:READ+EDIT',
'PROJECT_API_SCENARIO:READ+CREATE',
'PROJECT_API_SCENARIO:READ+COPY',
]">
<el-switch <el-switch
v-model="data.enable" v-model="data.enable"
class="enable-switch" class="enable-switch"
@ -91,6 +91,11 @@
circle circle
@click="copyRow" @click="copyRow"
style="padding: 5px" style="padding: 5px"
v-permission="[
'PROJECT_API_SCENARIO:READ+EDIT',
'PROJECT_API_SCENARIO:READ+CREATE',
'PROJECT_API_SCENARIO:READ+COPY',
]"
:disabled="(data.disabled && !data.root && !data.isCopy) || !showVersion || isDeleted" /> :disabled="(data.disabled && !data.root && !data.isCopy) || !showVersion || isDeleted" />
<el-button <el-button
@ -101,7 +106,12 @@
style="padding: 5px" style="padding: 5px"
circle circle
@click="remove" @click="remove"
:disabled="(data.disabled && !data.root && !data.isCopy) || !showVersion || isDeleted" /> :disabled="(data.disabled && !data.root && !data.isCopy) || !showVersion || isDeleted"
v-permission="[
'PROJECT_API_SCENARIO:READ+EDIT',
'PROJECT_API_SCENARIO:READ+CREATE',
'PROJECT_API_SCENARIO:READ+COPY',
]"/>
<step-extend-btns <step-extend-btns
style="display: contents" style="display: contents"
@ -114,6 +124,11 @@
@copy="copyRow" @copy="copyRow"
@remove="remove" @remove="remove"
@openScenario="openScenario" @openScenario="openScenario"
v-permission="[
'PROJECT_API_SCENARIO:READ+EDIT',
'PROJECT_API_SCENARIO:READ+CREATE',
'PROJECT_API_SCENARIO:READ+COPY',
]"
v-show="isMoreButton" /> v-show="isMoreButton" />
</div> </div>
</div> </div>

View File

@ -90,7 +90,11 @@
icon="el-icon-video-play" icon="el-icon-video-play"
class="ms-btn" class="ms-btn"
size="mini" size="mini"
circle /> circle
v-permission="[
'PROJECT_API_SCENARIO:READ+DEBUG',
'PROJECT_API_SCENARIO:READ+RUN'
]"/>
</el-tooltip> </el-tooltip>
<el-tooltip :content="$t('report.stop_btn')" placement="top" :enterable="false" v-else> <el-tooltip :content="$t('report.stop_btn')" placement="top" :enterable="false" v-else>
<el-button <el-button
@ -98,7 +102,11 @@
size="mini" size="mini"
style="color: white; padding: 0 0.1px; width: 24px; height: 24px" style="color: white; padding: 0 0.1px; width: 24px; height: 24px"
class="stop-btn" class="stop-btn"
circle> circle
v-permission="[
'PROJECT_API_SCENARIO:READ+DEBUG',
'PROJECT_API_SCENARIO:READ+RUN'
]">
<div style="transform: scale(0.66)"> <div style="transform: scale(0.66)">
<span style="margin-left: -4.5px; font-weight: bold">STOP</span> <span style="margin-left: -4.5px; font-weight: bold">STOP</span>
</div> </div>

View File

@ -29,7 +29,7 @@
</span> </span>
<span v-else> <span v-else>
<el-tooltip class="ms-num" effect="dark" :content="$t('api_test.automation.scenario.num_none')" placement="top"> <el-tooltip class="ms-num" effect="dark" :content="$t('api_test.automation.scenario.num_none')" placement="top">
<i class="el-icon-warning" /> <i class="el-icon-warning"/>
</el-tooltip> </el-tooltip>
</span> </span>
<span v-xpack v-if="scenario.versionEnable">{{ $t('project.version.name') }}: {{ scenario.versionName }}</span> <span v-xpack v-if="scenario.versionEnable">{{ $t('project.version.name') }}: {{ scenario.versionName }}</span>
@ -39,9 +39,9 @@
<el-tag size="small" class="ms-tag" v-if="scenario.referenced === 'Deleted'" type="danger"> <el-tag size="small" class="ms-tag" v-if="scenario.referenced === 'Deleted'" type="danger">
{{ $t('api_test.automation.reference_deleted') }} {{ $t('api_test.automation.reference_deleted') }}
</el-tag> </el-tag>
<el-tag size="small" class="ms-tag" v-if="scenario.referenced === 'Copy'"> {{ $t('commons.copy') }} </el-tag> <el-tag size="small" class="ms-tag" v-if="scenario.referenced === 'Copy'"> {{ $t('commons.copy') }}</el-tag>
<el-tag size="small" class="ms-tag" v-if="scenario.referenced === 'REF'" <el-tag size="small" class="ms-tag" v-if="scenario.referenced === 'REF'"
>{{ $t('api_test.scenario.reference') }} >{{ $t('api_test.scenario.reference') }}
</el-tag> </el-tag>
<span class="ms-tag ms-step-name-api">{{ getProjectName(scenario.projectId) }}</span> <span class="ms-tag ms-step-name-api">{{ getProjectName(scenario.projectId) }}</span>
<el-tooltip <el-tooltip
@ -51,12 +51,12 @@
:content="$t('api_test.scenario.base_scenario_step_is_empty')" :content="$t('api_test.scenario.base_scenario_step_is_empty')"
placement="top" placement="top"
style="margin-left: 5px"> style="margin-left: 5px">
<i class="el-icon-warning" /> <i class="el-icon-warning"/>
</el-tooltip> </el-tooltip>
</template> </template>
<template v-slot:debugStepCode> <template v-slot:debugStepCode>
<span v-if="node.data.testing" class="ms-test-running"> <span v-if="node.data.testing" class="ms-test-running">
<i class="el-icon-loading" style="font-size: 16px" /> <i class="el-icon-loading" style="font-size: 16px"/>
{{ $t('commons.testing') }} {{ $t('commons.testing') }}
</span> </span>
<span <span
@ -84,7 +84,11 @@
style="padding: 5px" style="padding: 5px"
class="ms-btn" class="ms-btn"
size="mini" size="mini"
circle /> circle
v-permission="[
'PROJECT_API_SCENARIO:READ+DEBUG',
'PROJECT_API_SCENARIO:READ+RUN'
]"/>
</el-tooltip> </el-tooltip>
<el-tooltip :content="$t('report.stop_btn')" placement="top" :enterable="false" v-else> <el-tooltip :content="$t('report.stop_btn')" placement="top" :enterable="false" v-else>
<el-button <el-button
@ -93,7 +97,11 @@
size="mini" size="mini"
style="color: white; padding: 0 0.1px; width: 24px; height: 24px" style="color: white; padding: 0 0.1px; width: 24px; height: 24px"
class="stop-btn" class="stop-btn"
circle> circle
v-permission="[
'PROJECT_API_SCENARIO:READ+DEBUG',
'PROJECT_API_SCENARIO:READ+RUN'
]">
<div style="transform: scale(0.66)"> <div style="transform: scale(0.66)">
<span style="margin-left: -4.5px; font-weight: bold">STOP</span> <span style="margin-left: -4.5px; font-weight: bold">STOP</span>
</div> </div>
@ -109,11 +117,11 @@ import MsTcpBasisParameters from '../../../definition/components/request/tcp/Tcp
import MsDubboBasisParameters from '../../../definition/components/request/dubbo/BasisParameters'; import MsDubboBasisParameters from '../../../definition/components/request/dubbo/BasisParameters';
import MsApiRequestForm from '../../../definition/components/request/http/ApiHttpRequestForm'; import MsApiRequestForm from '../../../definition/components/request/http/ApiHttpRequestForm';
import ApiBaseComponent from '../common/ApiBaseComponent'; import ApiBaseComponent from '../common/ApiBaseComponent';
import { getCurrentProjectID, getCurrentWorkspaceId } from 'metersphere-frontend/src/utils/token'; import {getCurrentProjectID, getCurrentWorkspaceId} from 'metersphere-frontend/src/utils/token';
import { getUUID, strMapToObj } from 'metersphere-frontend/src/utils'; import {getUUID, strMapToObj} from 'metersphere-frontend/src/utils';
import { STEP } from '@/business/automation/scenario/Setting'; import {STEP} from '@/business/automation/scenario/Setting';
import { getOwnerProjectIds, getProject } from '@/api/project'; import {getOwnerProjectIds, getProject} from '@/api/project';
import { checkScenarioEnv, getScenarioById, setScenarioDomain } from '@/api/scenario'; import {checkScenarioEnv, getScenarioById, setScenarioDomain} from '@/api/scenario';
export default { export default {
name: 'ApiScenarioComponent', name: 'ApiScenarioComponent',

View File

@ -33,7 +33,7 @@
v-if="testCase === undefined && !scenario"> v-if="testCase === undefined && !scenario">
{{ $t('commons.test') }} {{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as" <el-dropdown-item command="save_as" v-permission="['PROJECT_API_DEFINITION:READ+CREATE_CASE']"
>{{ $t('api_test.definition.request.save_as_case') }} >{{ $t('api_test.definition.request.save_as_case') }}
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>

View File

@ -35,7 +35,7 @@
@command="handleCommand" @command="handleCommand"
size="small" size="small"
v-if="!runLoading" v-if="!runLoading"
v-permission="['PROJECT_API_DEFINITION:READ+EDIT_API']"> v-permission="['PROJECT_API_DEFINITION:READ+EDIT_API', 'PROJECT_API_DEFINITION:READ+CREATE_CASE']">
{{ $t('commons.test') }} {{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="load_case" <el-dropdown-item command="load_case"

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<el-form :model="commonConfig" :rules="rules" ref="commonConfig" :disabled="isReadOnly" label-width="30px"> <el-form :model="commonConfig" :rules="rules" ref="commonConfig" :disabled="isReadOnly" label-width="30px">
<ms-api-scenario-variables :show-copy="false" :items="commonConfig.variables"/> <ms-api-scenario-variables :show-copy="false" :items="commonConfig.variables" :is-read-only="isReadOnly"/>
<el-form-item> <el-form-item>
<el-switch v-model="commonConfig.enableHost" active-text="Hosts"/> <el-switch v-model="commonConfig.enableHost" active-text="Hosts"/>
</el-form-item> </el-form-item>

View File

@ -22,7 +22,7 @@
<slot name="other"></slot> <slot name="other"></slot>
</div> </div>
<div class="ms_btn"> <div class="ms_btn">
<el-button type="primary" @click="confirm" @keydown.enter.native.prevent size="small"> <el-button type="primary" @click="confirm" @keydown.enter.native.prevent size="small" :disabled="isReadOnly">
{{ $t('commons.confirm') }} {{ $t('commons.confirm') }}
</el-button> </el-button>
</div> </div>

View File

@ -49,23 +49,23 @@
<form-section :title="$t('commons.api')" :init-active=true> <form-section :title="$t('commons.api')" :init-active=true>
<p>{{ $t('api_test.request.headers') }}</p> <p>{{ $t('api_test.request.headers') }}</p>
<el-row> <el-row>
<el-link class="ms-el-link" @click="batchAdd" style="color: #783887"> {{ <el-link class="ms-el-link" @click="batchAdd" style="color: #783887" :disabled="isReadOnly"> {{
$t("commons.batch_add") $t("commons.batch_add")
}} }}
</el-link> </el-link>
</el-row> </el-row>
<ms-api-key-value :items="condition.headers" :isShowEnable="true" :suggestions="headerSuggestions"/> <ms-api-key-value :items="condition.headers" :isShowEnable="true" :suggestions="headerSuggestions" :is-read-only="isReadOnly"/>
</form-section> </form-section>
<div style="margin-top: 20px"> <div style="margin-top: 20px">
<el-button v-if="!condition.id" type="primary" style="float: right" size="mini" @click="add"> <el-button v-if="!condition.id" type="primary" style="float: right" size="mini" @click="add" :disabled="isReadOnly">
{{ $t('commons.add') }} {{ $t('commons.add') }}
</el-button> </el-button>
<div v-else> <div v-else>
<el-button type="primary" style="float: right;margin-left: 10px" size="mini" @click="clear"> <el-button type="primary" style="float: right;margin-left: 10px" size="mini" @click="clear" :disabled="isReadOnly">
{{ $t('commons.clear') }} {{ $t('commons.clear') }}
</el-button> </el-button>
<el-button type="primary" style="float: right" size="mini" @click="update(condition)">{{ <el-button type="primary" style="float: right" size="mini" @click="update(condition)" :disabled="isReadOnly">{{
$t('commons.update') $t('commons.update')
}} }}
</el-button> </el-button>
@ -105,9 +105,9 @@
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<div> <div>
<ms-table-operator-button :tip="$t('api_test.automation.copy')" <ms-table-operator-button :tip="$t('api_test.automation.copy')"
icon="el-icon-document-copy" @exec="copy(row)"/> icon="el-icon-document-copy" @exec="copy(row)" :disabled="isReadOnly"/>
<ms-table-operator-button :tip="$t('api_test.automation.remove')" <ms-table-operator-button :tip="$t('api_test.automation.remove')"
icon="el-icon-delete" @exec="remove(row)" type="danger"/> icon="el-icon-delete" @exec="remove(row)" type="danger" :disabled="isReadOnly"/>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<ms-database-from :config="currentConfig" :callback="saveConfig" ref="databaseFrom" :is-read-only="isReadOnly"/> <ms-database-from :config="currentConfig" :callback="saveConfig" ref="databaseFrom" :is-read-only="isReadOnly"/>
<ms-database-config-list @rowSelect="rowSelect" v-if="configs.length > 0" :table-data="configs"/> <ms-database-config-list @rowSelect="rowSelect" v-if="configs.length > 0" :table-data="configs" :is-read-only="isReadOnly"/>
</div> </div>
</template> </template>

View File

@ -17,9 +17,9 @@
<template v-slot:default="scope"> <template v-slot:default="scope">
<div> <div>
<ms-table-operator-button :tip="$t('commons.copy')" icon="el-icon-document-copy" type="success" <ms-table-operator-button :tip="$t('commons.copy')" icon="el-icon-document-copy" type="success"
@exec="handleCopy(scope.$index, scope.row)"/> @exec="handleCopy(scope.$index, scope.row)" :disabled="isReadOnly"/>
<ms-table-operator-button :tip="$t('commons.delete')" icon="el-icon-delete" type="danger" <ms-table-operator-button :tip="$t('commons.delete')" icon="el-icon-delete" type="danger"
@exec="handleDelete(scope.$index)"/> @exec="handleDelete(scope.$index)" :disabled="isReadOnly"/>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>