/** * TC-IDENTITY_API-008 · 条件不满足时不能办理身份更新(接口级) * REQ-049 [FL-1.3] 反向/等价类 P0 * * 前置:通过已认证的调用方连接器调用"身份更新"接口可以正常打开 / 已准备无权限账号或错误数据 * 步骤:调用"身份更新"接口 → 使用无权限账号或错误数据办理身份更新 → 提交,查看提示与数据 * 预期:系统不允许办理身份更新,并说明原因。原有数据和状态不变。 */ export const meta = { tc: 'TC-IDENTITY_API-008', req: 'REQ-049', title: '条件不满足时不能办理身份更新', type: '反向/等价类', priority: 'P0', route: '', needs: ['be'] } export async function run(t) { let beforeMember = null await t.step('前置:登录、记录一条 NORMAL 会员基线', async () => { await t.login() const list = await t.apiList('/api/ssw/tdc/Member', { pageSize: 20 }) const target = list.find((m) => m.status !== 'CANCELLED') if (!target) t.skip('库内找不到 NORMAL 状态 Member') beforeMember = { ...target } t.assert(true, `基线 id=${target.id} email=${target.email}`) }) await t.step('反向 1:对不存在 id 调用 UpdateProfile 应被业务拒绝', async () => { const r = await t.api('PUT', '/api/ssw/tdc/Member/NON_EXIST_E2E_ID/UpdateProfile', { email: 'should_not_apply@x.com' }) t.assert(r && String(r.code) !== '200', `不存在 id 被拒(code=${r?.code} msg=${r?.msg})`) }) await t.step('反向 2:用伪造 token 调用 UpdateProfile 应被 sa-token 拦截', async () => { const r = await t.api('PUT', `/api/ssw/tdc/Member/${beforeMember.id}/UpdateProfile`, { email: 'fake_token_should_not_apply@x.com' }, { token: 'bearer invalid.token.fake' }) t.assert(r && String(r.code) !== '200', `伪造 token 被拒(code=${r?.code})`) }) await t.step('核对:原会员数据未被脏改', async () => { const after = await t.api('GET', `/api/ssw/tdc/Member/${beforeMember.id}`) t.assert(after.email === beforeMember.email, `邮箱未被脏改(${beforeMember.email})`) t.assert(after.email !== 'should_not_apply@x.com', '非法请求未污染数据') t.assert(after.email !== 'fake_token_should_not_apply@x.com', '伪造请求未污染数据') }) }