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 { 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 {
getReportMessageSocket,
@ -1723,7 +1723,7 @@ export default {
});
},
runDebug(runScenario) {
if (!hasPermission('PROJECT_API_SCENARIO:READ+EDIT')) {
if (!hasPermissions('PROJECT_API_SCENARIO:READ+DEBUG','PROJECT_API_SCENARIO:READ+RUN')) {
return;
}
this.mergeScenario(this.scenarioDefinition);

View File

@ -65,18 +65,18 @@
<div
v-if="!ifFromVariableAdvance"
class="header-right"
@click.stop
v-permission="[
'PROJECT_API_SCENARIO:READ+EDIT',
'PROJECT_API_SCENARIO:READ+CREATE',
'PROJECT_API_SCENARIO:READ+COPY',
]">
@click.stop>
<slot name="message" v-show="!isMax"></slot>
<slot name="debugStepCode"></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
v-model="data.enable"
class="enable-switch"
@ -91,6 +91,11 @@
circle
@click="copyRow"
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" />
<el-button
@ -101,7 +106,12 @@
style="padding: 5px"
circle
@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
style="display: contents"
@ -114,6 +124,11 @@
@copy="copyRow"
@remove="remove"
@openScenario="openScenario"
v-permission="[
'PROJECT_API_SCENARIO:READ+EDIT',
'PROJECT_API_SCENARIO:READ+CREATE',
'PROJECT_API_SCENARIO:READ+COPY',
]"
v-show="isMoreButton" />
</div>
</div>

View File

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

View File

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

View File

@ -33,7 +33,7 @@
v-if="testCase === undefined && !scenario">
{{ $t('commons.test') }}
<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') }}
</el-dropdown-item>
</el-dropdown-menu>

View File

@ -35,7 +35,7 @@
@command="handleCommand"
size="small"
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') }}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="load_case"

View File

@ -1,7 +1,7 @@
<template>
<div>
<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-switch v-model="commonConfig.enableHost" active-text="Hosts"/>
</el-form-item>

View File

@ -22,7 +22,7 @@
<slot name="other"></slot>
</div>
<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') }}
</el-button>
</div>

View File

@ -49,23 +49,23 @@
<form-section :title="$t('commons.api')" :init-active=true>
<p>{{ $t('api_test.request.headers') }}</p>
<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")
}}
</el-link>
</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>
<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') }}
</el-button>
<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') }}
</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')
}}
</el-button>
@ -105,9 +105,9 @@
<template v-slot:default="{row}">
<div>
<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')"
icon="el-icon-delete" @exec="remove(row)" type="danger"/>
icon="el-icon-delete" @exec="remove(row)" type="danger" :disabled="isReadOnly"/>
</div>
</template>
</el-table-column>

View File

@ -1,7 +1,7 @@
<template>
<div>
<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>
</template>

View File

@ -17,9 +17,9 @@
<template v-slot:default="scope">
<div>
<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"
@exec="handleDelete(scope.$index)"/>
@exec="handleDelete(scope.$index)" :disabled="isReadOnly"/>
</div>
</template>
</el-table-column>