后端: 身份与归属鉴权收口; 资金安全(结算闸门/支付防篡改/报名费真实扣款/赠金/结算唯一入账/提现打款); 数据泄露与隐私; 登录与密钥安全(默认密钥闸门/登录限流); 可观测性; 启动自检. 微信: 商家转账到零钱提现打款闭环(含回调/查单/失败退回佣金); 订阅消息真实下发闭环与后台模板字段对齐. 后台: 财务/微信支付配置读取失败锁定; 看板/待办/走势去假数据; 打款与测试推送文案修正. 小程序: 请求层错误透传与登录过期提示; 多页失败反馈与乐观回滚; 帮助中心FAQ页面化. 测试: 新增 40+ 回归护栏与真实 MySQL 冒烟(75 套件/599 用例全绿).
66 行
2.9 KiB
TypeScript
66 行
2.9 KiB
TypeScript
// 已读取AGENTS.md
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
/**
|
|
* 第十批回归闸门:订单评价/动态发布与删除的身份收口 + 关键路径可观测性
|
|
*/
|
|
describe('第十批身份收口与可观测性闸门 (评价 / 动态发布 / 动态删除)', () => {
|
|
const rootDir = path.resolve(__dirname, '../../');
|
|
const indexCode = fs.readFileSync(path.join(rootDir, 'server/src/index.ts'), 'utf-8');
|
|
const repoCode = fs.readFileSync(path.join(rootDir, 'server/src/db/repository.ts'), 'utf-8');
|
|
const apiCode = fs.readFileSync(path.join(rootDir, 'pwuniapp/common/api.js'), 'utf-8');
|
|
|
|
const routeBlock = (marker: string, len = 900) => {
|
|
const start = indexCode.indexOf(marker);
|
|
expect(start).toBeGreaterThan(-1);
|
|
return indexCode.slice(start, start + len);
|
|
};
|
|
|
|
describe('1. 订单评价身份以服务端会话为准', () => {
|
|
it('评价路由必须经 resolveSecureUserId 绑定买家身份', () => {
|
|
const block = routeBlock("app.post('/api/orders/:id/review'");
|
|
expect(block).toContain('resolveSecureUserId(');
|
|
expect(block).toContain("'提交订单评价'");
|
|
expect(block).toContain('userId: reviewerId');
|
|
expect(block).not.toContain('userId: userId ? Number(userId) : undefined');
|
|
});
|
|
|
|
it('仓储层仍保留服务端归属校验(仅下单买家)', () => {
|
|
expect(repoCode).toContain('仅下单买家本人可以评价该订单');
|
|
});
|
|
});
|
|
|
|
describe('2. 动态发布身份以服务端会话为准', () => {
|
|
it('发布路由必须经 resolveSecureUserId 且写库用服务端 uid', () => {
|
|
const block = routeBlock("app.post('/api/posts',");
|
|
expect(block).toContain("'发布动态'");
|
|
expect(block).toContain('repo.createPost({ ...(req.body || {}), userId: uid })');
|
|
});
|
|
});
|
|
|
|
describe('3. 动态删除身份以服务端会话为准', () => {
|
|
it('删除路由必须经 resolveSecureUserId', () => {
|
|
const block = routeBlock("app.delete('/api/posts/:id'");
|
|
expect(block).toContain("'删除动态'");
|
|
});
|
|
});
|
|
|
|
describe('4. 关键路径不得静默吞错', () => {
|
|
it('openid 持久化/预支付解析/用户设置 IO 必须记录错误', () => {
|
|
expect(indexCode).toContain("logServerError('login.updateUserOpenid'");
|
|
expect(indexCode).toContain("logServerError('prepay.resolveOpenid'");
|
|
expect(indexCode).toContain("logServerError('userSettings.write'");
|
|
expect(repoCode).toContain("logServerError('getDashboardTodos.reports'");
|
|
});
|
|
});
|
|
|
|
describe('5. 小程序端写接口携带真实身份', () => {
|
|
it('发布动态/提交评价必须注入当前用户身份', () => {
|
|
expect(apiCode).toContain('userId: normalizeUserId(payload && payload.userId)');
|
|
expect(apiCode).toContain('userId: normalizeUserId(reviewData.userId)');
|
|
expect(apiCode).toContain('const uid = normalizeUserId(userId);');
|
|
});
|
|
});
|
|
});
|