mateclaw/mateclaw-server/src/test/java/vip/mate/wiki/controller
倪程伟 b23cc32f33
fix(wiki): make global starter-pack templates read-only
Global transformation templates (workspace_id IS NULL, e.g. the 7 built-in
starter packs made global by V165) were shared across every workspace but
not actually read-only: any workspace member could edit or delete them,
mutating/affecting all workspaces, with deletes unrecoverable (Flyway
seed runs once).

- Controller: reject update/delete of null-workspace templates with 403
  (err.wiki.global_template_readonly); read/apply paths unchanged.
- Service: defense-in-depth — update/delete also reject global templates,
  guarding non-HTTP callers (WikiTool LLM entry points). delete() now
  checks the entity before deleting instead of deleting blindly.
- findByName: add deterministic ORDER BY (workspace_id IS NULL) ASC so a
  workspace-local template wins over a same-named global one (was LIMIT 1
  with no ordering). Consistent across H2/MySQL/Kingbase.
- i18n: new err.wiki.global_template_readonly (zh + en).
- Tests: +2 controller mock tests (403 on update/delete, no service write),
  +2 E2E tests (global template stays intact; findByName prefers local).

Tests: 10/10 green (4 controller + 6 E2E).
2026-07-15 14:57:18 +08:00
..
WikiEntityControllerIdorTest.java fix(wiki): close IDOR in WikiRelationController & WikiEntityController (cross-KB id binding) 2026-06-28 14:41:19 +08:00
WikiHotCacheControllerTest.java chore(test): backfill mateclaw-server/src/test/ that earlier PRIVATE_ITEMS pattern accidentally excluded 2026-05-12 17:38:08 +08:00
WikiRelationControllerIdorTest.java fix(wiki): close IDOR in WikiRelationController & WikiEntityController (cross-KB id binding) 2026-06-28 14:41:19 +08:00
WikiTransformationControllerTest.java fix(wiki): make global starter-pack templates read-only 2026-07-15 14:57:18 +08:00