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

84 lines
3.4 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-027 · 查看使用存证的办理结果
* REQ-046 [FL-6.6] 正向/边界值 P1
*
* 前置:1. 已完成一次使用存证操作
* 2. 用户有查看记录的权限
* 步骤:1. 打开【交付平台】或【数据使用控制】
* 2. 查询刚办理的记录
* 3. 查看详情和相关记录
* 预期:能查到正确的使用存证结果,列表、详情和相关记录一致。
*
* 注:本用例验证 REQ-046 的细粒度查询能力:
* 1) ByResource / ByGrantee 查询;2) Check 接口按 scope 拒绝;
* 3) Revoke 后 Check 返回 EXPIRED/REVOKED。
*/
export const meta = {
tc: 'TC-USAGE-027',
req: 'REQ-046',
title: '查看使用存证的办理结果',
type: '正向/边界值',
priority: 'P1',
route: '/tdc/resource-grant',
needs: ['fe', 'be']
}
export async function run(t) {
let target = null
await t.step('前置:登录、打开【资源授权】并取一条 ACTIVE 授权', async () => {
await t.login()
await t.goto('/tdc/resource-grant')
await t.expectTitle('资源授权')
const list = await t.apiList('/api/ssw/tdc/ResourceGrant', { pageSize: 100 })
target = list.find((r) => r.status === 'ACTIVE') || list[0]
if (!target) t.skip('库中无任何授权记录,先执行 TC-USAGE-025 创建一条')
t.assert(true, `选定查看对象:grantee=${target.granteeId} scope=${target.scope}(${target.id})`)
})
await t.step('正向:按资源查授权(ByResource)', async () => {
const list = await t.api('GET', `/api/ssw/tdc/ResourceGrant/ByResource/${target.resourceId}`)
t.assert(Array.isArray(list.data), `ByResource 接口返回数组(${list.data?.length} 条)`)
t.assert(
list.data.some((x) => x.id === target.id),
`按资源查能找到目标授权`
)
})
await t.step('正向:按 grantee 查授权(ByGrantee)', async () => {
const res = await t.api('GET', `/api/ssw/tdc/ResourceGrant/ByGrantee?granteeType=${target.granteeType}&granteeId=${target.granteeId}`)
t.assert(Array.isArray(res.data), `ByGrantee 接口返回数组(${res.data?.length} 条)`)
t.assert(
res.data.some((x) => x.id === target.id),
`按 grantee 查能找到目标授权`
)
})
await t.step('边界值 1:用错误 scope 校验应拒绝', async () => {
const res = await t.api('POST', '/api/ssw/tdc/ResourceGrant/Check', {
resourceId: target.resourceId,
granteeType: target.granteeType,
granteeId: target.granteeId,
scope: target.scope === 'READ' ? 'ADMIN' : 'READ'
})
t.assert(res.code === 200, `Check 接口返回(code=${res.code})`)
t.assert(res.data.allow === false, `错误 scope 应被拒(allow=${res.data.allow})`)
})
await t.step('边界值 2:撤销授权后再次 Check 应被拒', async () => {
const rev = await t.api('POST', `/api/ssw/tdc/ResourceGrant/${target.id}/Revoke`)
t.assert(rev.code === 200, `撤销授权成功(code=${rev.code})`)
const check = await t.api('POST', '/api/ssw/tdc/ResourceGrant/Check', {
resourceId: target.resourceId,
granteeType: target.granteeType,
granteeId: target.granteeId,
scope: target.scope
})
t.assert(check.code === 200, `Check 接口返回(code=${check.code})`)
t.assert(check.data.allow === false, `撤销后 Check 必须被拒(allow=${check.data.allow})`)
})
t.expectConsoleClean()
}