Files
ssw-mvp/docs/e2e/cases/TC-USAGE-025.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.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-025 · 正常办理使用存证
* REQ-046 [FL-6.6] 正向/场景法 P0
*
* 前置:1. 已绑定连接器的机构用户或已认证连接器
* 2. 【交付平台】或【数据使用控制】可以正常打开
* 3. 已准备好测试数据
* 步骤:1. 打开【交付平台】或【数据使用控制】
* 2. 按页面提示填写或选择正确的数据
* 3. 点击提交,查看办理结果
* 预期:使用存证办理成功,系统按要求完成处理,状态和记录正确。
*
* 注:REQ-046 强调「使用存证(按表/时长/次数细粒度管控)」,对应 ResourceGrant。
* 本用例验证授权四元组(granteeType + granteeId + scope + expireTime + remainingCalls)
* 落库正确,Check 接口按规则返回 allow/deny。
*/
export const meta = {
tc: 'TC-USAGE-025',
req: 'REQ-046',
title: '正常办理使用存证',
type: '正向/场景法',
priority: 'P0',
route: '/tdc/resource-grant',
needs: ['fe', 'be']
}
export async function run(t) {
let resource = null
const granteeId = `e2e-user-${t.runId}`
await t.step('前置:登录、打开【资源授权】并取一条已挂载的资源', async () => {
await t.login()
await t.goto('/tdc/resource-grant')
await t.expectTitle('资源授权')
const list = await t.apiList('/api/ssw/tdc/Resource', { pageSize: 100 })
resource = list.find((r) => r.mountStatus === 'MOUNTED') || list[0]
if (!resource) t.skip('库中无任何资源,无法做授权正向断言')
t.assert(true, `选定授权对象:${resource.name}(mountStatus=${resource.mountStatus || '未知'})`)
})
await t.step('正向:新建一条 USER + READ 授权', async () => {
const res = await t.api('POST', '/api/ssw/tdc/ResourceGrant', {
resourceId: resource.id,
granteeType: 'USER',
granteeId: granteeId,
scope: 'READ',
remainingCalls: 5,
status: 'ACTIVE'
})
t.assert(res.code === 200, `创建授权成功(code=${res.code})`)
})
await t.step('核对授权落库', async () => {
const list = await t.apiList('/api/ssw/tdc/ResourceGrant', { pageSize: 100 })
const row = list.find((r) => r.granteeId === granteeId && r.resourceId === resource.id)
t.assert(!!row, `授权落库可见(granteeId=${granteeId})`)
t.assert(row.scope === 'READ', `授权范围=READ(实际 ${row.scope})`)
t.assert(row.granteeType === 'USER', `granteeType=USER(实际 ${row.granteeType})`)
t.assert(row.remainingCalls === 5, `剩余次数=5(实际 ${row.remainingCalls})`)
t.assert(row.status === 'ACTIVE', `状态=ACTIVE(实际 ${row.status})`)
})
await t.step('正向:Check 接口放行', async () => {
const res = await t.api('POST', '/api/ssw/tdc/ResourceGrant/Check', {
resourceId: resource.id,
granteeType: 'USER',
granteeId: granteeId,
scope: 'READ'
})
t.assert(res.code === 200, `Check 接口返回(code=${res.code})`)
t.assert(res.data.allow === true, `授权放行(allow=${res.data.allow})`)
t.assert(typeof res.data.reason === 'string', `返回 reason 字符串:${res.data.reason}`)
})
await t.step('核对剩余次数被扣减', async () => {
const list = await t.apiList('/api/ssw/tdc/ResourceGrant', { pageSize: 100 })
const row = list.find((r) => r.granteeId === granteeId && r.resourceId === resource.id)
t.assert(row.remainingCalls === 4, `Check 一次后剩余次数从 5 减至 4(实际 ${row.remainingCalls})`)
})
t.expectConsoleClean()
}