Files
ssw-mvp/docs/e2e/cases/TC-CONNECTOR_API-001.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

77 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-CONNECTOR_API-001 · 正常办理连接器注册、更新、撤销
* REQ-060 [FL-3.1] 正向/场景法 P0
*
* 前置:已绑定连接器的机构用户 / 连接器接口可正常访问 / 已准备好测试数据
* 步骤:通过认证接口调用连接器注册、更新、撤销 → 查看办理结果
* 预期:注册、更新、撤销三个动作都成功,状态与记录正确
*
* 说明:UI 新建连接器因空间校验被挡(详见 TC-CONNECTOR-001),本用例全程走接口调用,
* 直接命中 ConnectorController.beforeSave 对字段的强校验。
*/
export const meta = {
tc: 'TC-CONNECTOR_API-001',
req: 'REQ-060',
title: '正常办理连接器注册、更新、撤销',
type: '正向/场景法',
priority: 'P0',
route: '',
needs: ['be']
}
export async function run(t) {
await t.login()
const code = t.uid('E2E-API')
const spaceList = await t.apiList('/api/ssw/tds/Space', { pageSize: 5 })
if (!spaceList.length) t.skip('库中没有空间,无法给连接器指定所属空间')
const spaceId = spaceList[0].id
let createdId = null
await t.step('注册:POST /api/ssw/tds/Connector 写入新连接器', async () => {
const body = {
connectorCode: code,
name: `测评-API-连接器-${t.runId}`,
spaceId,
orgName: '尚数网测评机构',
creditCode: '91330100MA2E2E2E2E',
type: 'BOTH',
deployMode: 'LOCAL',
endpoint: 'https://e2e.api.connector.local:8443',
capability: '{"roles":["PROVIDER","CONSUMER"],"protocol":"mTLS"}',
heartbeatInterval: 5
}
const r = await t.api('POST', '/api/ssw/tds/Connector', body)
t.assert(r.code === 200, `注册成功(实际 code=${r.code})`)
createdId = typeof r.data === 'string' ? r.data : (r.data?.id ?? r.id)
t.assert(!!createdId, `注册返回了 id(${createdId})`)
})
await t.step('更新:PUT /api/ssw/tds/Connector/{id} 修改备注', async () => {
const r = await t.api('PUT', `/api/ssw/tds/Connector/${createdId}`, {
connectorCode: code,
name: `测评-API-连接器-${t.runId}`,
spaceId,
desc: `API 更新于 ${t.runId}`
})
t.assert(r.code === 200, `更新成功(实际 code=${r.code})`)
const info = await t.api('GET', `/api/ssw/tds/Connector/${createdId}`)
t.assert(info.data?.desc?.includes(t.runId), `desc 已更新(${info.data?.desc})`)
})
await t.step('查询:列表与详情能命中刚刚注册的记录', async () => {
const list = await t.apiList('/api/ssw/tds/Connector', { keyword: code })
t.assert(list.some((r) => r.connectorCode === code), `列表能按 connectorCode 检索到`)
const info = await t.api('GET', `/api/ssw/tds/Connector/${createdId}`)
t.assert(info.code === 200 && info.data.connectorCode === code, `详情接口返回一致`)
})
await t.step('撤销:PUT /Cancel 注销连接器,写入 dataRetentionUntil', async () => {
const r = await t.api('PUT', `/api/ssw/tds/Connector/${createdId}/Cancel`, { reason: `API 撤销-${t.runId}` })
t.assert(r.code === 200, `撤销成功(实际 code=${r.code})`)
t.assert(r.data?.retentionYears === 3, `国标要求 dataRetentionUntil = now+3 年(${r.data?.retentionYears})`)
const info = await t.api('GET', `/api/ssw/tds/Connector/${createdId}`)
t.assert(info.data.status === 'CANCELLED', `状态置为 CANCELLED(实际 ${info.data.status})`)
t.assert(!!info.data.dataRetentionUntil, `已写入留存截止时间(${info.data.dataRetentionUntil})`)
})
}