Files
ssw-mvp/docs/e2e/cases/TC-CONTROL_API-007.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

97 lines
5.1 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-CONTROL_API-007 · 条件不满足时不能办理执行过程控制
* REQ-067 [FL-6.1] 反向/状态迁移 P0
*
* 前置:1. 通过已认证的调用方连接器调用「执行过程控制」接口可以正常打开
* 2. 已准备无权限账号或错误数据
* 步骤:1. 打开通过已认证的调用方连接器调用「执行过程控制」接口
* 2. 使用无权限账号或错误数据办理执行过程控制
* 3. 点击提交,查看提示和数据
* 预期:系统不允许办理执行过程控制,并说明原因。原有数据和状态不变。
*
* 实现说明:
* Sandbox/Privacy 控制器对每个动作都做了状态机检查:
* - UploadProgram:仅 PENDING_DELIVER 可上传;
* - SubmitAudit :已审核/已通过/运行中禁止重复提交;
* - AuditApprove :仅 PENDING 中可批准;
* - Deliver :仅 APPROVED 可交付;
* 不存在的任务 ID 一律返回「交付任务不存在」。
*/
export const meta = {
tc: 'TC-CONTROL_API-007',
req: 'REQ-067',
title: '条件不满足时不能办理执行过程控制',
type: '反向/状态迁移',
priority: 'P0',
route: '',
needs: ['be']
}
export async function run(t) {
await t.login()
let pristineTask = null
await t.step('前置:从库中挑一个处于成功态的 SANDBOX 任务作为「不允许再办理」的反例', async () => {
const list = await t.apiList('/api/ssw/tdc/DeliveryTask', { deliveryType: 'SANDBOX', pageSize: 50 })
const succeeded = list.find((x) => x.runStatus === 'SUCCESS')
if (!succeeded) t.skip('库中没有 SUCCESS 状态的 SANDBOX 任务,跳过状态机反向用例')
pristineTask = succeeded
t.assert(true, `选定反向用例任务:id=${pristineTask.id} runStatus=${pristineTask.runStatus}`)
})
await t.step('反向 1:不存在的任务 ID 办理 → 全部动作均被「交付任务不存在」拒绝', async () => {
const fake = 'non-existent-' + t.runId
const checks = [
['PUT', `/api/ssw/tdc/Sandbox/${fake}/UploadProgram`, { programUri: '/x.py' }],
['PUT', `/api/ssw/tdc/Sandbox/${fake}/SubmitAudit`, {}],
['PUT', `/api/ssw/tdc/Sandbox/${fake}/AuditApprove`, {}],
['PUT', `/api/ssw/tdc/Sandbox/${fake}/Deliver`, {}]
]
for (const [method, url, body] of checks) {
const r = await t.api(method, url, body)
t.assert(r.code !== 200, `${method} ${url} 被拒绝(code=${r.code})`)
t.assert(/不存在|不存在或/i.test(r.msg || ''), `提示说明任务不存在(实际「${r.msg}」)`)
}
})
await t.step('反向 2:对已完成(SUCCESS)的任务再次 UploadProgram → 状态机拒绝', async () => {
const r = await t.api('PUT', `/api/ssw/tdc/Sandbox/${pristineTask.id}/UploadProgram`, {
programUri: '/x.py',
filename: 'hijack.py'
})
t.assert(r.code !== 200, `再次上传被拒(code=${r.code} msg=${r.msg})`)
t.assert(/状态|不允许/.test(r.msg || ''), `提示说明状态不允许(实际「${r.msg}」)`)
})
await t.step('反向 3:对已完成的任务再次 Deliver → 状态机拒绝', async () => {
const r = await t.api('PUT', `/api/ssw/tdc/Sandbox/${pristineTask.id}/Deliver`, {})
t.assert(r.code !== 200, `重复交付被拒(code=${r.code} msg=${r.msg})`)
t.assert(/已运行|不允许/.test(r.msg || ''), `提示说明已运行/不允许(实际「${r.msg}」)`)
})
await t.step('反向 4:审核驳回时缺 opinion → 被「驳回意见不能为空」拒绝', async () => {
const list = await t.apiList('/api/ssw/tdc/DeliveryTask', { deliveryType: 'SANDBOX', pageSize: 50 })
const pending = list.find((x) => x.auditStatus === 'PENDING')
if (!pending) return // 跳过;如果没在审核中的就跳过该子用例
const r = await t.api('PUT', `/api/ssw/tdc/Sandbox/${pending.id}/AuditReject`, { opinion: '' })
t.assert(r.code !== 200, `缺意见被拒(code=${r.code})`)
t.assert(/意见|为空/.test(r.msg || ''), `提示说明意见不能为空(实际「${r.msg}」)`)
})
await t.step('反向 5:上传非白名单扩展名 → 被「不支持的程序文件类型」拒绝', async () => {
const list = await t.apiList('/api/ssw/tdc/DeliveryTask', { deliveryType: 'SANDBOX', pageSize: 50 })
const fresh = list.find((x) => x.runStatus === 'PENDING_DELIVER' || x.runStatus === 'PENDING' || x.runStatus === 'REJECTED')
if (!fresh) return
const r = await t.api('PUT', `/api/ssw/tdc/Sandbox/${fresh.id}/UploadProgram`, {
programUri: '/tmp/evil.exe',
filename: 'evil.exe'
})
t.assert(r.code !== 200, `非白名单扩展名被拒(code=${r.code})`)
t.assert(/类型|不允许|支持/.test(r.msg || ''), `提示说明不支持的类型(实际「${r.msg}」)`)
})
await t.step('核对原有数据未被脏写:pristineTask 状态未变', async () => {
const after = await t.api('GET', `/api/ssw/tdc/DeliveryTask/${pristineTask.id}`)
t.assert(after.data?.runStatus === pristineTask.runStatus, `runStatus 保持 SUCCESS(实际 ${after.data?.runStatus})`)
})
}