test: prohibit legacy safe and audit aliases

This commit is contained in:
2026-07-27 14:16:39 +08:00
parent 7a35bfe58c
commit 068b4e0ed9
4 changed files with 42 additions and 1 deletions

View File

@@ -6,8 +6,18 @@ import { auditPlatform, scanInternalIdLeaks } from './audit-check.mjs';
const resourcesSource = readFileSync('src/api/resources.ts', 'utf8');
test('资源定义使用 safe 和 audit 前缀', () => {
assert.match(resourcesSource, /define\('safe_rule', '\/safety\/safe_rule'/);
assert.match(resourcesSource, /define\('safe_event', '\/safety\/safe_event'/);
assert.match(resourcesSource, /define\('safe_inspection', '\/safety\/safe_inspection'/);
assert.match(resourcesSource, /define\('safe_event_disposal', '\/safety\/safe_event\/:identity\/disposals'/);
assert.match(resourcesSource, /define\('audit_operation_log', '\/audit\/audit_operation_log'/);
assert.match(resourcesSource, /define\('audit_export_log', '\/audit\/audit_export_log'/);
assert.match(resourcesSource, /define\('audit_approval', '\/audit\/audit_approval'/);
assert.doesNotMatch(resourcesSource, /define\('saf_(?:rule|event|inspection|event_disposal)',/);
assert.doesNotMatch(resourcesSource, /action\('saf_event_disposal',/);
assert.doesNotMatch(resourcesSource, /define\('aud_(?:operation_log|export_log|approval)',/);
assert.doesNotMatch(resourcesSource, /\/audit\/aud_approval\/:identity\/approve/);
});
test('只读页面将状态变更视为违规写操作', () => {