- 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
70 lines
3.4 KiB
JavaScript
70 lines
3.4 KiB
JavaScript
/**
|
||
* TC-IDENTITY-005 · 条件不满足时不能办理身份认证
|
||
* REQ-002 [FL-1.2] 反向/等价类 P0
|
||
*
|
||
* 前置:【身份管理】可打开 / 已准备无权限账号或错误数据
|
||
* 步骤:使用无权限账号或错误数据办理身份认证 → 点击提交,查看提示与数据
|
||
* 预期:系统不允许办理身份认证,并说明原因。原有数据和状态不变。
|
||
*
|
||
* 身份认证的反向:登录页填错密码应被拒;调用 /api/oauth/Login 也应被拒。
|
||
* 因为这是『认证』类反向,口令维度是核心,所以走真实登录页 + API 双路。
|
||
*/
|
||
export const meta = {
|
||
tc: 'TC-IDENTITY-005',
|
||
req: 'REQ-002',
|
||
title: '条件不满足时不能办理身份认证',
|
||
type: '反向/等价类',
|
||
priority: 'P0',
|
||
route: '/login',
|
||
needs: ['fe', 'be']
|
||
}
|
||
|
||
export async function run(t) {
|
||
await t.step('前置:保证 session 未登录', async () => {
|
||
await t.logout()
|
||
t.assert(true, '已清掉 token,准备在登录页测错误口令')
|
||
})
|
||
|
||
await t.step('登录页:用 admin 账号 + 错误密码,应被拒且停在登录页', async () => {
|
||
await t.page.goto('http://localhost:5173/login', { waitUntil: 'domcontentloaded' })
|
||
await t.page.locator('.login-card input').first().fill('admin')
|
||
await t.page.locator('.login-card input[type="password"]').fill('wrong_pwd_e2e_')
|
||
await t.page.getByRole('button', { name: /登\s*录/ }).click()
|
||
// 等响应回来:要么仍在 /login,要么出现错误 message
|
||
await t.waitIdle()
|
||
const url = t.page.url()
|
||
t.assert(url.includes('/login'), `错误口令后仍在登录页(${url})`)
|
||
// 通过 context 查 storageState 比直接 page.evaluate 安全(避免跳走后撞 SecurityError)
|
||
await t.waitIdle()
|
||
const storage = await t.context.storageState()
|
||
const origin = storage.origins.find(o => o.origin === 'http://localhost:5173')
|
||
const hasToken = !!origin?.localStorage?.find(e => e.name === 'ssw_token_sswflow')?.value
|
||
t.assert(!hasToken, '错误口令没有写入 token')
|
||
})
|
||
|
||
await t.step('API 反向:直接打 /api/oauth/Login 错误口令,应回业务错误码', async () => {
|
||
const encrypted = 'd4958348' + 'ee' + 'wrongwrong'
|
||
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: encrypted, grant_type: 'password' }).toString()
|
||
})
|
||
const json = await res.json()
|
||
t.assert(json.code !== 200, `错误口令拒绝(code=${json.code} msg=${json.msg})`)
|
||
})
|
||
|
||
await t.step('原有数据不变:再走一次合法登录仍可拿到 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 && !!json.data?.token, `合法登录回 token(code=${json.code} token=${json.data?.token?.slice(0, 16)}…)`)
|
||
})
|
||
}
|