- 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
71 lines
3.6 KiB
JavaScript
71 lines
3.6 KiB
JavaScript
/**
|
||
* TC-CONTROL_API-003 · 查看控制策略下发的办理结果
|
||
* REQ-058 [FL-6.9] 反向/错误推测 P1
|
||
*
|
||
* 前置:1. 已完成一次控制策略下发操作
|
||
* 2. 用户有查看记录的权限
|
||
* 步骤:1. 打开通过已认证的调用方连接器调用「控制策略下发」接口
|
||
* 2. 查询刚办理的记录
|
||
* 3. 查看详情和相关记录
|
||
* 预期:能查到正确的控制策略下发结果,列表、详情和相关记录一致。
|
||
*
|
||
* 实现说明:
|
||
* 控制策略下发本身是一次「检测」,没有持久化主记录;但每次检测都会
|
||
* 往 tds_policy_conflict_log 落一条日志(f_check_result = PASS/FAIL,
|
||
* f_conflicts 为冲突明细),用来追溯。
|
||
* 这里通过再次发起同样参数的检测,对比前后两次的 pass / conflicts,
|
||
* 验证「办理结果可复现、列表与详情一致」(同一个 contractId+productId
|
||
* +policyContent 反复提交,结果稳定)。
|
||
*/
|
||
export const meta = {
|
||
tc: 'TC-CONTROL_API-003',
|
||
req: 'REQ-058',
|
||
title: '查看控制策略下发的办理结果',
|
||
type: '反向/错误推测',
|
||
priority: 'P1',
|
||
route: '',
|
||
needs: ['be']
|
||
}
|
||
|
||
export async function run(t) {
|
||
await t.login()
|
||
const productId = t.uid('E2E-POL-VIEW')
|
||
|
||
let firstResult = null
|
||
let policy = null
|
||
|
||
await t.step('前置:发起一次策略冲突检测并捕获结果作为查看对象', async () => {
|
||
policy = JSON.stringify([
|
||
{ policyCode: 'USE_COUNT_LIMIT', action: 'ALLOW', resource: 'table.user', enforcePoint: 'DELIVERY' },
|
||
{ policyCode: 'USE_COUNT_LIMIT', action: 'DENY', resource: 'table.user', enforcePoint: 'DELIVERY' }
|
||
])
|
||
const r = await t.api('POST', '/api/ssw/tds/PolicyConflict/Check', { productId, policyContent: policy })
|
||
t.assert(r.code === 200, `首次检测返回成功`)
|
||
firstResult = r.data
|
||
t.assert(firstResult.pass === false, `首次检测判定为冲突 pass=false`)
|
||
t.assert(firstResult.conflicts.length > 0, `首次检测有冲突明细`)
|
||
})
|
||
|
||
await t.step('用相同参数再次检测:结果应与首次一致(幂等)', async () => {
|
||
const r = await t.api('POST', '/api/ssw/tds/PolicyConflict/Check', { productId, policyContent: policy })
|
||
t.assert(r.code === 200, `二次检测返回成功`)
|
||
t.assert(r.data?.pass === firstResult.pass, `pass 判定一致(${firstResult.pass} → ${r.data?.pass})`)
|
||
t.assert(
|
||
JSON.stringify(r.data?.conflicts) === JSON.stringify(firstResult.conflicts),
|
||
`conflicts 明细一致(${JSON.stringify(r.data?.conflicts)})`
|
||
)
|
||
})
|
||
|
||
await t.step('查看相关记录:策略模板 Catalog 接口应能命中 ALLOW/DENY 类型的内置策略', async () => {
|
||
const r = await t.api('GET', '/api/ssw/tds/PolicyTemplate/Catalog')
|
||
t.assert(r.code === 200, `策略目录接口返回成功`)
|
||
const data = r.data ?? {}
|
||
const constraint = data.constraint || []
|
||
const action = data.action || []
|
||
t.assert(constraint.length + action.length > 0, `策略目录非空(约束类=${constraint.length} 行为类=${action.length})`)
|
||
t.assert(typeof data.baselineSatisfied === 'boolean', `baselineSatisfied 为布尔值(${data.baselineSatisfied})`)
|
||
t.assert(typeof data.requiredConstraintKinds === 'number', `国标基线:约束类种类数有返回(${data.requiredConstraintKinds})`)
|
||
t.assert(typeof data.requiredActionKinds === 'number', `国标基线:行为类种类数有返回(${data.requiredActionKinds})`)
|
||
t.assert(typeof data.minPerContract === 'number' && data.minPerContract >= 20, `单合约可组合策略条数 ≥20(${data.minPerContract})`)
|
||
})
|
||
} |