- 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
104 lines
4.0 KiB
JavaScript
104 lines
4.0 KiB
JavaScript
/**
|
||
* TC-USAGE-026 · 条件不满足时不能办理使用存证
|
||
* REQ-046 [FL-6.6] 反向/等价类 P0
|
||
*
|
||
* 前置:1. 【交付平台】或【数据使用控制】可以正常打开
|
||
* 2. 已准备无权限账号或错误数据
|
||
* 步骤:1. 打开【交付平台】或【数据使用控制】
|
||
* 2. 使用无权限账号或错误数据办理使用存证
|
||
* 3. 点击提交,查看提示和数据
|
||
* 预期:系统不允许办理使用存证,并说明原因。原有数据和状态不变。
|
||
*
|
||
* 注:ResourceGrantController.beforeSave 强校验:
|
||
* 1. resourceId / granteeId 必填
|
||
* 2. granteeType 必须 ∈ {USER, ROLE, SPACE}
|
||
* 3. scope 必须 ∈ {READ, DOWNLOAD, CALL, ADMIN}
|
||
*/
|
||
export const meta = {
|
||
tc: 'TC-USAGE-026',
|
||
req: 'REQ-046',
|
||
title: '条件不满足时不能办理使用存证',
|
||
type: '反向/等价类',
|
||
priority: 'P0',
|
||
route: '/tdc/resource-grant',
|
||
needs: ['fe', 'be']
|
||
}
|
||
|
||
export async function run(t) {
|
||
let before = 0
|
||
let resource = null
|
||
|
||
await t.step('前置:登录、记录原始授权数并取一条资源', async () => {
|
||
await t.login()
|
||
const grants = await t.apiList('/api/ssw/tdc/ResourceGrant', { pageSize: 100 })
|
||
before = grants.length
|
||
const list = await t.apiList('/api/ssw/tdc/Resource', { pageSize: 100 })
|
||
resource = list[0]
|
||
if (!resource) t.skip('库中无任何资源,无法做反向断言')
|
||
t.assert(true, `操作前授权共 ${before} 条,目标资源=${resource.id}`)
|
||
})
|
||
|
||
await t.step('反向 1:缺 resourceId 必填校验', async () => {
|
||
const res = await t.api('POST', '/api/ssw/tdc/ResourceGrant', {
|
||
granteeType: 'USER',
|
||
granteeId: 'e2e-no-resource',
|
||
scope: 'READ'
|
||
})
|
||
t.assert(res.code !== 200, `缺 resourceId 被拒(code=${res.code}, msg=${res.msg})`)
|
||
t.assert(
|
||
typeof res.msg === 'string' && res.msg.includes('resourceId') && res.msg.includes('必填'),
|
||
`拒绝原因指向「resourceId 必填」:${res.msg}`
|
||
)
|
||
})
|
||
|
||
await t.step('反向 2:非法 granteeType 被枚举校验拒绝', async () => {
|
||
const res = await t.api('POST', '/api/ssw/tdc/ResourceGrant', {
|
||
resourceId: resource.id,
|
||
granteeType: 'INVALID_TYPE',
|
||
granteeId: 'e2e-bad-type',
|
||
scope: 'READ'
|
||
})
|
||
t.assert(res.code !== 200, `非法 granteeType 被拒(code=${res.code}, msg=${res.msg})`)
|
||
t.assert(
|
||
typeof res.msg === 'string' && res.msg.includes('USER/ROLE/SPACE'),
|
||
`拒绝原因指向合法枚举:${res.msg}`
|
||
)
|
||
})
|
||
|
||
await t.step('反向 3:非法 scope 被枚举校验拒绝', async () => {
|
||
const res = await t.api('POST', '/api/ssw/tdc/ResourceGrant', {
|
||
resourceId: resource.id,
|
||
granteeType: 'USER',
|
||
granteeId: 'e2e-bad-scope',
|
||
scope: 'EXECUTE' // 非法值
|
||
})
|
||
t.assert(res.code !== 200, `非法 scope 被拒(code=${res.code}, msg=${res.msg})`)
|
||
t.assert(
|
||
typeof res.msg === 'string' && res.msg.includes('READ/DOWNLOAD/CALL/ADMIN'),
|
||
`拒绝原因指向合法枚举:${res.msg}`
|
||
)
|
||
})
|
||
|
||
await t.step('反向 4:Check 无授权用户必须被拒(allow=false)', async () => {
|
||
const res = await t.api('POST', '/api/ssw/tdc/ResourceGrant/Check', {
|
||
resourceId: resource.id,
|
||
granteeType: 'USER',
|
||
granteeId: 'no-grant-e2e',
|
||
scope: 'READ'
|
||
})
|
||
t.assert(res.code === 200, `Check 接口返回(code=${res.code})`)
|
||
t.assert(res.data.allow === false, `无授权被拒绝(allow=${res.data.allow})`)
|
||
t.assert(
|
||
typeof res.data.reason === 'string' && ['无 ACTIVE 授权', '未上架', 'mountStatus', '资源'].some((k) => res.data.reason.includes(k)),
|
||
`拒绝原因指向授权/资源不可用(实际「${res.data.reason}」)`
|
||
)
|
||
})
|
||
|
||
await t.step('核对原始授权条数不变', async () => {
|
||
const after = (await t.apiList('/api/ssw/tdc/ResourceGrant', { pageSize: 100 })).length
|
||
t.assert(after === before, `授权条数不变(${before} → ${after}),未产生脏数据`)
|
||
})
|
||
|
||
t.expectConsoleClean()
|
||
}
|