49 lines
2.2 KiB
Python
49 lines
2.2 KiB
Python
"""首页入口可见性测试。"""
|
|
|
|
from fastapi_modules.fastapi_leaudit.services.impl.entryModuleAdminServiceImpl import EntryModuleAdminServiceImpl
|
|
from fastapi_modules.fastapi_leaudit.services.impl.homeServiceImpl import HomeServiceImpl
|
|
from fastapi_modules.fastapi_leaudit.services.impl.rbacServiceImpl import RbacServiceImpl
|
|
|
|
|
|
def test_document_entry_targets_are_visible_without_file_management_routes():
|
|
"""文档类首页入口只受租户配置控制,不因缺少文件管理路由消失。"""
|
|
service = HomeServiceImpl()
|
|
|
|
assert service._isAllowedTargetPath("/documents", set()) is True
|
|
assert service._isAllowedTargetPath("/documents/list", set()) is True
|
|
assert service._isAllowedTargetPath("/files/upload", set()) is True
|
|
|
|
|
|
def test_non_document_entry_targets_still_require_route_grant():
|
|
"""非文档入口仍需要当前用户路由树覆盖。"""
|
|
service = HomeServiceImpl()
|
|
|
|
assert service._isAllowedTargetPath("/tenants", set()) is False
|
|
assert service._isAllowedTargetPath("/cross-checking", set()) is False
|
|
assert service._isAllowedTargetPath("/cross-checking", {"/cross-checking"}) is True
|
|
|
|
|
|
def test_govdoc_home_features_use_rule_config_for_legacy_rule_groups():
|
|
"""内部公文旧规则分组功能编码应兼容到规则配置。"""
|
|
service = HomeServiceImpl()
|
|
|
|
assert service._parseFeatures(["home", "rule_groups"], "govdoc") == ["home", "rules"]
|
|
assert service._parseFeatures([], "govdoc") == ["home", "govdoc_audits", "govdoc_upload", "rules"]
|
|
|
|
|
|
def test_govdoc_admin_features_use_rule_config_for_legacy_rule_groups():
|
|
"""入口模块管理读写内部公文功能时兼容旧规则分组编码。"""
|
|
service = EntryModuleAdminServiceImpl()
|
|
|
|
assert service._parseFeatures(["home", "rule_groups"], "govdoc") == ["home", "rules"]
|
|
assert service._normalizeFeatures(["rule_groups"], "govdoc") == ["rules"]
|
|
|
|
|
|
def test_rbac_compat_routes_use_rule_config_title():
|
|
"""RBAC 兼容菜单里的 /rules 标题统一为规则配置。"""
|
|
service = RbacServiceImpl()
|
|
routes = service._buildCompatibilityRoutes(["admin"], {"rules:list:read"})
|
|
rules_route = next(route for route in routes if route.route_path == "/rules")
|
|
|
|
assert rules_route.route_title == "规则配置"
|