- 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
58 lines
2.6 KiB
JavaScript
58 lines
2.6 KiB
JavaScript
/**
|
||
* TC-IDENTITY_API-004 · 正常办理身份认证(接口级)
|
||
* REQ-048 [FL-1.2] 正向/场景法 P0
|
||
*
|
||
* 前置:已绑定连接器的机构用户或已认证连接器 / 通过已认证的调用方连接器调用"身份认证"接口可以正常打开 / 已准备好测试数据
|
||
* 步骤:调用"身份认证"接口 → 按接口说明填写或选择正确的数据 → 提交,查看办理结果
|
||
* 预期:身份认证办理成功,系统按要求完成处理,状态和记录正确。
|
||
*
|
||
* 身份认证接口 = /api/oauth/Login(SSW 自研等价 JNPF)。在 JNPF 上调 Login 拿到 token 即视为「认证成功」。
|
||
*/
|
||
export const meta = {
|
||
tc: 'TC-IDENTITY_API-004',
|
||
req: 'REQ-048',
|
||
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, '已清掉 localStorage token,准备打 Login 接口')
|
||
})
|
||
|
||
await t.step('正向:调 /api/oauth/Login 拿到 token 即视为认证成功', 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}`)
|
||
t.assert(!!json.data?.token, `拿回 token(${json.data?.token?.slice(0, 30)}…)`)
|
||
token = json.data.token
|
||
})
|
||
|
||
await t.step('核对:拿到的 token 可访问需登录的接口 /api/oauth/CurrentUser', 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, `CurrentUser 返回 userId=${jcur.data?.userInfo?.userId}`)
|
||
})
|
||
}
|