feat(assets): 去掉企业资产范围 256 条规则上限
逐个 IP / 域名录范围的企业很容易撞上这个上限,撞上之后只能拆成多个企业, 而范围本身并不因为条数多就更慢。 - db:删掉 MaxCompanyScopeRules 常量、请求条数校验与 ensureCompanyScopeCapacityTx(每企业持久化总数的事务内校验) - 前端:去掉 MAX_COMPANY_SCOPE_RULES 与「剩余额度」计算,追加范围弹窗不再 按剩余条数报错;demo mock 的两处上限一并移除 - 单条规则仍限 1024 字符;请求正文 2 MiB(maxCompanyMutationBodyBytes)保留 作兜底,约合四五万条规则 测试:原先断言「超容量被拒」的两个用例翻转为「超过旧上限也能写入」—— db 侧批量写 300 条 + 追加 1 条,server 侧一次创建带 300 条范围的企业。 新用例先注册清理再断言,避免断言失败把企业留在共享开发库里。
This commit is contained in:
1 parent
48e14e8cf2
commit
acd1ac29d7
7 files changed
+41
-64
No files matched your search
@@ -6,7 +6,6 @@ import {
|
||||
classifyCompanyScopeLine,
|
||||
companyScopeRuleError,
|
||||
isCompanyScopeKind,
|
||||
MAX_COMPANY_SCOPE_RULES,
|
||||
normalizeCompanyScopeValue,
|
||||
} from "../company-scope";
|
||||
import type {
|
||||
@@ -599,7 +598,6 @@ function mockScopeRows(
|
||||
existing: ScopeRow[] = [],
|
||||
): { rows: ScopeRow[]; invalid: number; skipped: number } {
|
||||
if (!Array.isArray(input)) return { rows: [], invalid: 0, skipped: 0 };
|
||||
if (input.length > MAX_COMPANY_SCOPE_RULES) throw new Error(`企业范围最多支持 ${MAX_COMPANY_SCOPE_RULES} 条`);
|
||||
let nextID =
|
||||
mockCompanies.flatMap((company) => company.scope ?? []).reduce((max, row) => Math.max(max, row.id), 0) + 1;
|
||||
const rows: ScopeRow[] = [];
|
||||
@@ -636,9 +634,6 @@ function mockScopeRows(
|
||||
keys.add(key);
|
||||
rows.push(row);
|
||||
}
|
||||
if (existing.length + rows.length > MAX_COMPANY_SCOPE_RULES) {
|
||||
throw new Error(`企业范围规则过多:每个企业最多 ${MAX_COMPANY_SCOPE_RULES} 条`);
|
||||
}
|
||||
return { rows, invalid, skipped };
|
||||
}
|
||||
|
||||
@@ -1438,7 +1433,7 @@ function route(m: string, path: string, seg: string[], q: URLSearchParams, b: Re
|
||||
const numericTaskID = mockTaskAssetID(seg[1]);
|
||||
if (!task || numericTaskID === undefined) throw new Error("任务不存在");
|
||||
if (Array.isArray(b.scope)) {
|
||||
if (b.scope.length === 0 || b.scope.length > MAX_COMPANY_SCOPE_RULES) throw new Error("请填写有效测试范围");
|
||||
if (b.scope.length === 0) throw new Error("请填写有效测试范围");
|
||||
const rules: CompanyScopeRule[] = b.scope.map((candidate, index) => {
|
||||
if (typeof candidate === "string") {
|
||||
const issue = classifyCompanyScopeLine(candidate, index + 1);
|
||||
|
||||
Reference in new issue
Block a user