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

87 lines
3.7 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-019 · 修改数据后使用环境校验失败
* REQ-044 [FL-6.4] 反向/错误推测 P0
*
* 前置:已准备测试副本和原始记录,用于前后对比。
* 步骤:1. 修改测试副本的关键内容,或使用无效凭证访问
* 2. 提交读取、验证或处理操作
* 3. 查看提示、原始记录和异常记录
* 预期:系统发现数据被修改或凭证无效后,不再继续处理。原始记录不变,并能查到异常记录。
*
* 注:REQ-044 强调「版本化防篡改」,反向校验点:
* 1. 修改已存在策略的 templateCode 为另一个已存在的 code → 唯一性冲突
* 2. 用无效 id 调用 info 接口 → 凭证无效场景
*/
export const meta = {
tc: 'TC-USAGE-019',
req: 'REQ-044',
title: '修改数据后使用环境校验失败',
type: '反向/错误推测',
priority: 'P0',
route: '/tds/policies',
needs: ['fe', 'be']
}
export async function run(t) {
const code1 = t.uid('E2E-USAGE-VERIFY1')
const code2 = t.uid('E2E-USAGE-VERIFY2')
await t.step('前置:登录、打开【使用控制策略】并准备两条策略', async () => {
await t.login()
await t.goto('/tds/policies')
await t.pickSpace()
// 直接调接口建两条策略,避免走 drawer 控件(更稳)
const r1 = await t.api('POST', '/api/ssw/tds/PolicyTemplate', {
templateCode: code1,
name: `测试策略A-${t.runId}`,
category: 'CONSTRAINT',
policyType: 'USAGE_ENV'
})
const r2 = await t.api('POST', '/api/ssw/tds/PolicyTemplate', {
templateCode: code2,
name: `测试策略B-${t.runId}`,
category: 'CONSTRAINT',
policyType: 'USAGE_ENV'
})
t.assert(r1.code === 200 && r2.code === 200, `前置策略准备成功(code1=${r1.code}, code2=${r2.code})`)
})
await t.step('篡改场景:把 code1 改成 code2 触发唯一性冲突', async () => {
const list = await t.apiList('/api/ssw/tds/PolicyTemplate', { keyword: code1 })
const target = list.find((r) => r.templateCode === code1)
if (!target) t.skip('找不到策略 code1,跳过本子步骤')
const res = await t.api('PUT', `/api/ssw/tds/PolicyTemplate/${target.id}`, {
id: target.id,
templateCode: code2, // 故意改成已存在的 code2
name: target.name,
category: target.category,
policyType: target.policyType
})
t.assert(res.code !== 200, `修改为已存在标识被拒(code=${res.code}, msg=${res.msg})`)
t.assert(
typeof res.msg === 'string' && res.msg.includes('已存在'),
`拒绝原因指向「已存在」:${res.msg}`
)
})
await t.step('凭证无效场景:用不存在的 id 读 info', async () => {
const fakeId = `FAKE-POLICY-${t.runId}`
const res = await t.api('GET', `/api/ssw/tds/PolicyTemplate/${fakeId}`)
// 无效 id 应被明确拒绝(400/404)或返回空 data(200),只要不是 500 服务器异常即视为正常处理
t.assert(res.code !== 500, `info 接口对无效 id 给出确定响应(code=${res.code},非 500 即视为正常拒绝/空数据)`)
t.log(`ℹ 无效 id 的 info 返回 code=${res.code} data=${String(res.data == null ? '' : JSON.stringify(res.data)).slice(0, 50)}`)
})
await t.step('核对原始记录未被篡改', async () => {
const r1 = await t.api('GET', `/api/ssw/tds/PolicyTemplate/${code1}`).catch(() => null)
// 上面 GET 不一定能直接走通,改用 list 找
const list = await t.apiList('/api/ssw/tds/PolicyTemplate', { keyword: code1 })
const row1 = list.find((r) => r.templateCode === code1)
t.assert(!!row1, `code1 仍以原 templateCode 存在(原始记录未丢)`)
})
t.expectConsoleClean()
}