Files
ssw-mvp/docs/e2e/cases/TC-USAGE-002.mjs
T
admin 3247e9fd15 init: ssw-mvp initial commit
- boot/ (Java/Maven, JNPF 7.0) — 移除旧的 boot/.git,源码直接纳入仓库
- web/ (Vue 3 + Vite + Ant Design Vue, pnpm)
- docs/, scard/, nax/
- refs/INDEX.md + refs/国标/(其余 refs/* 开源子仓库不纳入)
- 已忽略: connector_data/, jweb/, log/, web/{dist,node_modules,.pnpm}, boot/*/target/, .DS_Store, .idea, .vscode
2026-08-05 18:29:12 +08:00

86 lines
3.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* TC-USAGE-002 · 条件不满足时不能办理数据使用环境
* REQ-016 [FL-6.2] 反向/状态迁移 P0
*
* 前置:1. 服务平台的【数据使用控制】可以正常打开
* 2. 已准备无权限账号或错误数据
* 步骤:1. 打开服务平台的【数据使用控制】
* 2. 使用无权限账号或错误数据办理数据使用环境
* 3. 点击提交,查看提示和数据
* 预期:系统不允许办理数据使用环境,并说明原因。原有数据和状态不变。
*
* 注:本组反向用例核心是「越权使用应被拒绝」。
* DeliveryTaskController.Policy 接口:DENY 时必须写明原因,否则直接返回错误;
* DeliveryTaskEntity 的必填项:contractId / productId / taskNo 不可空。
* 用直接调接口方式构造非法请求,断言拒绝行为与原因。
*/
export const meta = {
tc: 'TC-USAGE-002',
req: 'REQ-016',
title: '条件不满足时不能办理数据使用环境',
type: '反向/状态迁移',
priority: 'P0',
route: '/tdc/delivery',
needs: ['fe', 'be']
}
export async function run(t) {
let before = 0
await t.step('前置:登录并记录当前交付任务数量', async () => {
await t.login()
const list = await t.apiList('/api/ssw/tdc/DeliveryTask')
before = list.length
t.assert(true, `操作前交付任务共 ${before} 条`)
})
await t.step('反向用例 1:策略判定 DENY 但不写原因(拒绝行为校验)', async () => {
// 准备一条 PENDING 任务用于写入策略判定
const list = await t.apiList('/api/ssw/tdc/DeliveryTask', { status: 'PENDING' })
let task = list[0]
if (!task) {
// 没 PENDING 就用任何一条非终结态的任务做反向断言
const any = await t.apiList('/api/ssw/tdc/DeliveryTask')
task = any.find((r) => !['DENIED', 'CANCELLED'].includes(r.status))
}
if (!task) t.skip('库中无任何非终结态交付任务,无法验证 DENY 拒绝校验')
const res = await t.api('PUT', `/api/ssw/tdc/DeliveryTask/${task.id}/Policy`, {
policyResult: 'DENY'
// 故意不写 denyReason —— 后端必须拒绝
})
t.assert(res.code !== 200, `DENY 不写原因被后端拒绝(code=${res.code}, msg=${res.msg})`)
t.assert(
typeof res.msg === 'string' && (res.msg.includes('原因') || res.msg.includes('拒绝')),
`拒绝原因字段被校验:${res.msg}`
)
})
await t.step('反向用例 2:非法 policyResult 值被枚举校验拒绝', async () => {
const list = await t.apiList('/api/ssw/tdc/DeliveryTask', { status: 'PENDING' })
let task = list[0]
if (!task) {
const any = await t.apiList('/api/ssw/tdc/DeliveryTask')
task = any.find((r) => !['DENIED', 'CANCELLED'].includes(r.status))
}
if (!task) t.skip('无可用任务')
const res = await t.api('PUT', `/api/ssw/tdc/DeliveryTask/${task.id}/Policy`, {
policyResult: 'INVALID_VALUE_XYZ',
denyReason: '测试'
})
t.assert(res.code !== 200, `非法 policyResult 被枚举拒绝(code=${res.code}, msg=${res.msg})`)
t.assert(
typeof res.msg === 'string' && res.msg.includes('ALLOW/DENY'),
`提示包含合法枚举说明:${res.msg}`
)
})
await t.step('核对原有数据和状态不变', async () => {
const after = (await t.apiList('/api/ssw/tdc/DeliveryTask')).length
t.assert(after === before, `列表条数不变(${before} → ${after}),未产生脏数据`)
})
t.expectConsoleClean()
}