fix: require match live menu parent

This commit is contained in:
hajimi
2026-06-21 13:47:07 +08:00
parent 75a529be35
commit 229b70c1be
2 changed files with 26 additions and 1 deletions
@@ -19,6 +19,7 @@ def main() -> None:
match_live_table = MATCH_LIVE_TABLE.read_text(encoding="utf-8")
assert MENU_SQL.is_file(), f"missing menu seed file: {MENU_SQL}"
menu_sql = MENU_SQL.read_text(encoding="utf-8")
normalized_menu_sql = " ".join(menu_sql.split())
assert_contains(MATCH_INDEX, 'type="expand"')
assert_contains(MATCH_INDEX, "MatchLiveTable")
@@ -97,10 +98,32 @@ def main() -> None:
"match.matchLive/detail",
"match.matchLive/add",
"match.matchLive/edit",
"match.match/lists",
"match.matchLive/delete",
):
assert needle in menu_sql, f"{MENU_SQL} missing permission token: {needle}"
forbidden_menu_fallbacks = (
"COALESCE(",
", 0), 'C', '直播线路管理'",
"SELECT 0, 'C', '直播线路管理'",
"VALUES (0, 'C', '直播线路管理'",
)
for needle in forbidden_menu_fallbacks:
assert needle not in menu_sql, f"{MENU_SQL} must not contain top-level fallback: {needle}"
assert (
"FROM `la_system_menu` parent" in menu_sql
and "parent.`perms` = 'match.match/lists'" in menu_sql
), f"{MENU_SQL} must bind the match live menu to parent match.match/lists explicitly"
assert (
"SELECT parent.`id`, 'C', '直播线路管理'" in menu_sql
and "WHERE NOT EXISTS (" in menu_sql
), f"{MENU_SQL} must insert the list menu only when the parent match.match/lists record exists"
assert (
"SELECT (SELECT `id` FROM `la_system_menu` WHERE `perms` = 'match.matchLive/lists' LIMIT 1)" in normalized_menu_sql
), f"{MENU_SQL} child permissions must bind to the inserted match.matchLive/lists menu"
print("match live admin static checks passed")