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

75 lines
3.2 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-005 · 条件不满足时不能办理身份认证(接口级)
* REQ-048 [FL-1.2] 反向/等价类 P0
*
* 前置:通过已认证的调用方连接器调用"身份认证"接口可以正常打开 / 已准备无权限账号或错误数据
* 步骤:调用"身份认证"接口 → 使用无权限账号或错误数据办理身份认证 → 提交,查看提示与数据
* 预期:系统不允许办理身份认证,并说明原因。原有数据和状态不变。
*
* 身份认证的反向:Login 接口错误口令/空账号应被拒绝。
*/
export const meta = {
tc: 'TC-IDENTITY_API-005',
req: 'REQ-048',
title: '条件不满足时不能办理身份认证',
type: '反向/等价类',
priority: 'P0',
route: '',
needs: ['be']
}
export async function run(t) {
await t.step('前置:登录一次拿到「正向通过」证据', async () => {
await t.login()
t.assert(!!t.token, '合法 login 拿到 token,证明 Login 接口本身可达')
})
await t.step('反向 1:错误口令应被拒绝', 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: 'd4958348e22108119b3ef57b022c83f4bf857dd0b247eaab15b9a43d47ee3c503900f7135bf0de255bc33620c3cdc02a', // 末位从 b 改成 a
grant_type: 'password'
}).toString()
})
const json = await res.json()
t.assert(json.code !== 200, `错误口令被拒(code=${json.code} msg=${json.msg})`)
})
await t.step('反向 2:错误账号应被拒绝', 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: 'e2e_no_such_account_xyz',
password: 'd4958348e22108119b3ef57b022c83f4bf857dd0b247eaab15b9a43d47ee3c503900f7135bf0de255bc33620c3cdc02b',
grant_type: 'password'
}).toString()
})
const json = await res.json()
t.assert(json.code !== 200, `错误账号被拒(code=${json.code} msg=${json.msg})`)
})
await t.step('反向 3:空口令应被拒绝', 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: '',
grant_type: 'password'
}).toString()
})
const json = await res.json()
t.assert(json.code !== 200, `空口令被拒(code=${json.code})`)
})
await t.step('核对:原有 session 数据不变(合法 login 仍可工作)', async () => {
// 再次合法登录仍可成功,证明服务侧状态机没被错误请求污染
await t.login()
t.assert(!!t.token, '合法 login 仍可成功(不会因前面的错误请求被锁)')
})
}