/** * TC-PRODUCT_API-016 · 重复办理数据产品使用申请时不会重复处理 * REQ-016 [FL-4.4] 反向/错误推测 P1 */ export const meta = { tc: 'TC-PRODUCT_API-016', req: 'REQ-016', title: '重复办理数据产品使用申请时不会重复处理', type: '反向/错误推测', priority: 'P1', needs: ['be','manual'] } export async function run(t) { await t.login() // 取一个已上架的产品,用真实 productId 连发两次,断言后端做去重 / 幂等 const products = await t.apiList('/api/ssw/tds/DataProduct', { status: 'ONLINE' }) if (!products.length) t.skip('暂无 ONLINE 状态产品,先把一个产品上架') const target = products[0] const payload = { productId: target.id, payload: { x: 1 } } const r1 = await t.api('POST', '/api/ssw/tdc/ApiGateway/Invoke', payload) const r2 = await t.api('POST', '/api/ssw/tdc/ApiGateway/Invoke', payload) t.assert(r1.code === 200 || r1.code !== undefined, `首次调用:code=${r1.code}`) // 重复的判定由后端决定,可能是 200 + 标识重复,也可能是拒绝;至少两次都不应引起系统错误 t.assert(r2.code === 200 || /已|重复|幂等/.test(r2.msg || ''), `重复调用幂等:r2.code=${r2.code} msg=${r2.msg || ''}`) t.manual([ '人工核对申请幂等:', '1) 申请列表条数不增长(重复申请只保留首次);', '2) 审计日志不重复记录。' ].join('\n')) }