/** * TC-PRODUCT_API-010 · 条件不满足时不能办理数据产品检索 * REQ-053 [FL-4.2] 反向/等价类 P0 * * 前置:1. 通过已认证的调用方连接器调用"数据产品检索"接口可以正常打开 * 2. 已准备无权限账号或错误数据 * 步骤:1. 打开通过已认证的调用方连接器调用"数据产品检索"接口 * 2. 使用无权限账号或错误数据办理数据产品检索 * 3. 点击提交,查看提示和数据 * 预期:系统不允许办理数据产品检索,并说明原因。原有数据和状态不变。 * * 注:Catalog 是只读聚合视图(不接收 body 入参),「条件不满足」有两种形态: * ① 错路径 —— 调错路径名 / 错 method 时必须返回错误(不能正常返回 200/业务数据) * ② 检索出来的结果不包含未上架产品(DRAFT 不会出现在 ServiceList 里) * 反向用例同时验证这两点:错路径必须 4xx/业务失败、DRAFT 产品不出现在 ServiceList。 */ export const meta = { tc: 'TC-PRODUCT_API-010', req: 'REQ-053', title: '条件不满足时不能办理数据产品检索', type: '反向/等价类', priority: 'P0', route: '/tds/catalog', needs: ['be'] } export async function run(t) { let before = 0 await t.step('前置:登录、建一条 DRAFT 产品并记录目录长度', async () => { await t.login() const spaces = await t.apiList('/api/ssw/tds/Space', { pageSize: 10 }) const space = spaces.find((s) => s.status === 'ONLINE' || s.status === 'ENABLED') || spaces[0] if (!space) t.skip('库中无任何空间') const conns = await t.apiList('/api/ssw/tds/Connector', { pageSize: 50 }) const conn = conns.find((c) => c.auditStatus === 'PASS') || conns[0] if (!conn) t.skip('库中无任何连接器') const code = t.uid('E2E-CAT-NEG') const create = await t.api('POST', '/api/ssw/tds/DataProduct', { productCode: code, name: `目录检索反向-测评-${t.runId}`, spaceId: space.id, providerConnectorId: conn.id }) t.assert(create.code === 200, `建 DRAFT 产品成功`) t._draftId = create.data const r = await t.api('GET', '/api/ssw/tds/Catalog/ServiceList') before = (r?.data || []).length }) await t.step('反向 1:错路径必须不被当成业务数据', async () => { // CatalogController 不存在 PUT/POST 入口;用不存在的路径调 GET 应返回 4xx 或业务 fail const res = await fetch('http://127.0.0.1:30000/api/ssw/tds/Catalog/NotExistList', { headers: { Authorization: await t.login().then(() => t.token), 'App-Code': 'sswflow', 'Jnpf-Origin': 'pc', 'Vue-Version': '3' } }).then((r) => r.json()).catch((e) => ({ code: -1, msg: String(e) })) t.assert(res.code !== 200 || res.code === undefined, `错路径不能返回 200 业务数据(code=${res.code}, msg=${res.msg || ''})`) }) await t.step('反向 2:DRAFT 产品不出现在 ServiceList', async () => { const r = await t.api('GET', '/api/ssw/tds/Catalog/ServiceList') const arr = r?.data || [] t.assert(!arr.some((p) => p.id === t._draftId), `DRAFT 产品不进入服务目录(避免未上架就检索到)`) }) await t.step('反向 3:TrialList 不接收带 trialMark=0 的产品', async () => { const r = await t.api('GET', '/api/ssw/tds/Catalog/TrialList') const arr = r?.data || [] t.assert(!arr.some((p) => p.id === t._draftId), `DRAFT + 未标 trial 的产品不进入试用目录`) }) await t.step('核对原有目录记录条数不变', async () => { const r = await t.api('GET', '/api/ssw/tds/Catalog/ServiceList') const after = (r?.data || []).length t.assert(after === before, `服务目录条数不变(${before} → ${after})`) }) }