fix: require match live menu parent
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
INSERT INTO `la_system_menu` (`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_cache`, `is_show`, `is_disable`, `create_time`, `update_time`)
|
||||
SELECT COALESCE((SELECT `id` FROM `la_system_menu` WHERE `perms` = 'match.match/lists' LIMIT 1), 0), 'C', '直播线路管理', '', 0, 'match.matchLive/lists', 'match_live', 'match/lists/index', 'match/lists', '', 0, 0, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
|
||||
SELECT parent.`id`, 'C', '直播线路管理', '', 0, 'match.matchLive/lists', 'match_live', 'match/lists/index', 'match/lists', '', 0, 0, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
|
||||
FROM `la_system_menu` parent
|
||||
WHERE parent.`perms` = 'match.match/lists'
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM `la_system_menu`
|
||||
WHERE `perms` = 'match.matchLive/lists'
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user