- 分公司类型模板:超管配置隐藏路由/菜单 + 中文文案覆盖,仅对挂类型的分公司生效(后端 service/routes、前端 Provider/守卫/配置页) - 超管模板 iframe 真还原预览:28 个业务页注册、白名单点选编辑、空/示例数据 fixture、白名单漂移检测工具 - 商品/SKU 下拉远程搜索:服务端关键词搜索 + 前端 useRemoteOptionSearch/SearchableSelect 接入(订单/采购/商品等页) - 主系统联调:子系统主动解绑主系统授权(幂等重试/本地兜底)、追加修改 price_amend 视图代理与 amend-price 转发 - 修复:仓内加工重复建单幂等(已完成需求单 guard、order 任务一商品一单 guard) - 修复:出入库记录只取前 100 条 → 服务端分页 + 真实总数 - 其它:库存/订单若干修复、分公司管理响应式布局、i18n 文案、设计文档与回归测试
62 lines
2.9 KiB
TypeScript
62 lines
2.9 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
||
import {
|
||
isExactBusinessAuditedPath,
|
||
normalizeAuditPath,
|
||
} from '../src/middleware/operationAuditMiddleware';
|
||
|
||
/**
|
||
* F5:审计精确白名单的路径归一化(大小写/尾斜杠/重复斜杠/编码)。
|
||
*
|
||
* 背景:`/API/Workflow/platform/branch-ui/types/` 与规范路径等价,若不归一化会落回通用审计,
|
||
* 而通用审计在 branchCode 为空时有 500+ 租户扇出风险(auditService.ts:116-130)。
|
||
*/
|
||
describe('normalizeAuditPath', () => {
|
||
it('去 query / 解码 / 小写 / 折叠斜杠 / 去尾斜杠', () => {
|
||
expect(normalizeAuditPath('/API//Workflow/platform/branch-ui/types/?x=1')).toBe(
|
||
'/api/workflow/platform/branch-ui/types'
|
||
);
|
||
expect(normalizeAuditPath('/api/%77orkflow/platform/branch-ui/types/')).toBe(
|
||
'/api/workflow/platform/branch-ui/types'
|
||
);
|
||
expect(normalizeAuditPath('/')).toBe('/');
|
||
expect(normalizeAuditPath('')).toBe('/');
|
||
});
|
||
});
|
||
|
||
describe('isExactBusinessAuditedPath 归一化后仍精确(F5)', () => {
|
||
it('分隔公司类型模板 5 条写接口:大小写/尾斜杠/重复斜杠/编码形态都命中', () => {
|
||
const forms: Array<[string, string]> = [
|
||
['PUT', '/api/workflow/platform/branch-ui/types'],
|
||
['PUT', '/API/Workflow/platform/branch-ui/types/'],
|
||
['PUT', '//api//workflow//platform//branch-ui//types'],
|
||
['PUT', '/api/workflow/platform/branch-ui/templates/retail/'],
|
||
['PUT', '/API/WORKFLOW/PLATFORM/BRANCH-UI/TEMPLATES/retail'],
|
||
['PUT', '/api/workflow/platform/branch-ui/branches/SUP0001/'],
|
||
['DELETE', '/api/workflow/platform/branch-ui/types/retail/'],
|
||
['PUT', '/api/workflow/platform/branch-ui/reopen/'],
|
||
['put', '/api/workflow/platform/branch-ui/types'],
|
||
];
|
||
for (const [method, path] of forms) {
|
||
expect(isExactBusinessAuditedPath(method, path), `${method} ${path}`).toBe(true);
|
||
}
|
||
});
|
||
|
||
it('归一化不放宽匹配面:子路径/其它方法/其它路径仍为 false', () => {
|
||
expect(isExactBusinessAuditedPath('PUT', '/api/workflow/platform/branch-ui/types/extra')).toBe(false);
|
||
expect(isExactBusinessAuditedPath('POST', '/api/workflow/platform/branch-ui/types/')).toBe(false);
|
||
expect(isExactBusinessAuditedPath('PUT', '/api/workflow/platform/branch-ui/unknown/')).toBe(false);
|
||
expect(isExactBusinessAuditedPath('PUT', '/api/workflow/platform/branch-ui/templates/retail/extra')).toBe(
|
||
false
|
||
);
|
||
});
|
||
|
||
it('原有精确白名单不受影响(抽样)', () => {
|
||
expect(isExactBusinessAuditedPath('DELETE', '/api/mobile/inspection/photo/')).toBe(true);
|
||
expect(isExactBusinessAuditedPath('POST', '/api/workflow/cost/free-cost')).toBe(true);
|
||
expect(
|
||
isExactBusinessAuditedPath('POST', '/api/workflow/cost/free-cost/entries/abc/approve/')
|
||
).toBe(true);
|
||
expect(isExactBusinessAuditedPath('POST', '/api/workflow/cost/free-cost/entries/abc')).toBe(false);
|
||
});
|
||
});
|