后端: 身份与归属鉴权收口; 资金安全(结算闸门/支付防篡改/报名费真实扣款/赠金/结算唯一入账/提现打款); 数据泄露与隐私; 登录与密钥安全(默认密钥闸门/登录限流); 可观测性; 启动自检. 微信: 商家转账到零钱提现打款闭环(含回调/查单/失败退回佣金); 订阅消息真实下发闭环与后台模板字段对齐. 后台: 财务/微信支付配置读取失败锁定; 看板/待办/走势去假数据; 打款与测试推送文案修正. 小程序: 请求层错误透传与登录过期提示; 多页失败反馈与乐观回滚; 帮助中心FAQ页面化. 测试: 新增 40+ 回归护栏与真实 MySQL 冒烟(75 套件/599 用例全绿).
66 行
2.7 KiB
TypeScript
66 行
2.7 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 apiCode = fs.readFileSync(path.join(rootDir, 'pwuniapp/common/api.js'), 'utf-8');
|
|
|
|
const routeBlock = (marker: string, len = 1200) => {
|
|
const start = indexCode.indexOf(marker);
|
|
expect(start).toBeGreaterThan(-1);
|
|
return indexCode.slice(start, start + len);
|
|
};
|
|
|
|
describe('1. 举报工单列表', () => {
|
|
it('管理端全量 / 普通用户仅本人提交', () => {
|
|
const block = routeBlock("app.get('/api/reports',");
|
|
expect(block).toContain('isVerifiedAdminRequest(req)');
|
|
expect(block).toContain("'查看我的举报'");
|
|
});
|
|
});
|
|
|
|
describe('2. 全量评价列表仅管理员', () => {
|
|
it('GET /api/reviews 必须挂 requireAdmin', () => {
|
|
expect(indexCode).toContain("app.get('/api/reviews', requireAdmin");
|
|
expect(indexCode).toContain("app.get('/api/post-applies', requireAdmin");
|
|
});
|
|
});
|
|
|
|
describe('3. 动态上车申请名单归属', () => {
|
|
it('仅发布者本人或管理员可查看某动态的上车申请', () => {
|
|
const block = routeBlock("app.get('/api/posts/:id/applies'");
|
|
expect(block).toContain("'查看上车申请'");
|
|
expect(block).toContain('仅动态发布者本人可查看该动态的上车申请');
|
|
});
|
|
});
|
|
|
|
describe('4. 收藏列表/状态归属', () => {
|
|
it('必须经 resolveSecureUserId', () => {
|
|
expect(routeBlock("app.get('/api/favorites',")).toContain("'查看收藏列表'");
|
|
expect(routeBlock("app.get('/api/favorites/check'")).toContain("'查询收藏状态'");
|
|
});
|
|
});
|
|
|
|
describe('5. 大神收益数据归属', () => {
|
|
it('收益汇总与走势必须经 assertCompanionActor', () => {
|
|
const stats = routeBlock("app.get('/api/expert/stats/:id',");
|
|
const trends = routeBlock("app.get('/api/expert/stats/:id/trends'");
|
|
expect(stats).toContain('assertCompanionActor(req, own');
|
|
expect(trends).toContain('assertCompanionActor(req, own');
|
|
});
|
|
});
|
|
|
|
describe('6. 小程序端携带当前用户身份', () => {
|
|
it('getPostApplies 必须带当前用户 id', () => {
|
|
const start = apiCode.indexOf('export async function getPostApplies(');
|
|
const block = apiCode.slice(start, start + 320);
|
|
expect(block).toContain('/posts/${postId}/applies?userId=${normalizeUserId()}');
|
|
});
|
|
});
|
|
});
|