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

58 lines
2.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-IDENTITY_API-011 · 正常办理身份认证(同 REQ-048,连接器之间交互)
* REQ-061 [FL-1.2] 正向/场景法 P0
*
* 前置:已绑定连接器的机构用户或已认证连接器 / 通过已认证的调用方连接器调用"身份认证"接口可以正常打开 / 已准备好测试数据
* 步骤:调用"身份认证"接口 → 按接口说明填写或选择正确的数据 → 提交,查看办理结果
* 预期:身份认证办理成功,系统按要求完成处理,状态和记录正确。
*
* 与 REQ-048 接口相同(§ 连接器之间交互的"身份认证"接口仍是 /api/oauth/Login)。
*/
export const meta = {
tc: 'TC-IDENTITY_API-011',
req: 'REQ-061',
title: '正常办理身份认证',
type: '正向/场景法',
priority: 'P0',
route: '',
needs: ['be']
}
export async function run(t) {
let token = null
await t.step('前置:当前页面无 token(清掉会话存根)', async () => {
await t.context.clearCookies().catch(() => {})
await t.page.evaluate(() => {
localStorage.removeItem('ssw_token_sswflow')
localStorage.removeItem('ssw_token_sswflow_expire')
}).catch(() => {})
t.assert(true, 'session 已清空')
})
await t.step('正向:连接器之间交互的身份认证接口仍走 /api/oauth/Login', async () => {
const res = await fetch('http://localhost:30000/api/oauth/Login', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'App-Code': 'sswflow', 'Jnpf-Origin': 'pc', 'Vue-Version': '3' },
body: new URLSearchParams({
account: 'admin',
password: 'd4958348e22108119b3ef57b022c83f4bf857dd0b247eaab15b9a43d47ee3c503900f7135bf0de255bc33620c3cdc02b',
grant_type: 'password'
}).toString()
})
const json = await res.json()
t.assert(json.code === 200, `Login 接口 code=${json.code}`)
token = json.data?.token
t.assert(!!token, `认证成功拿到 token(${token?.slice(0, 24)}…)`)
})
await t.step('核对:拿到的 token 能访问受保护的资源接口', async () => {
const cur = await fetch('http://localhost:30000/api/oauth/CurrentUser', {
headers: { Authorization: token, 'App-Code': 'sswflow', 'Jnpf-Origin': 'pc', 'Vue-Version': '3' }
})
const jcur = await cur.json()
t.assert(jcur.code === 200, `CurrentUser 用刚认证 token 访问 code=${jcur.code}`)
t.assert(jcur.data?.userInfo?.userId, `userId=${jcur.data?.userInfo?.userId}`)
})
}