38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
"""权限配置 P0 功能静态回归检查。"""
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
AUTH = (ROOT / 'routes' / 'auth.py').read_text(encoding='utf-8')
|
|
APP = (ROOT / 'static' / 'js' / 'app.js').read_text(encoding='utf-8')
|
|
|
|
|
|
class PermissionP0StaticTest(unittest.TestCase):
|
|
def test_effective_permission_api_exists(self):
|
|
self.assertIn("@auth_bp.route('/api/permissions/user/effective')", AUTH)
|
|
self.assertIn("用户级覆盖", AUTH)
|
|
self.assertIn("角色默认", AUTH)
|
|
self.assertIn("继承页面权限", AUTH)
|
|
|
|
def test_system_roles_are_visible_in_role_registry(self):
|
|
self.assertIn("'super_admin', 'name': '超级管理员'", AUTH)
|
|
self.assertIn("'viewer', 'name': '查看者'", AUTH)
|
|
|
|
def test_permission_page_has_role_overview_and_effective_preview(self):
|
|
self.assertIn('renderPermRoleOverview()', APP)
|
|
self.assertIn('openEffectivePermPreview', APP)
|
|
self.assertIn('/api/permissions/user/effective?user_id=', APP)
|
|
|
|
def test_role_matrix_has_bulk_display_controls(self):
|
|
self.assertIn('toggleRolePermGroups(true)', APP)
|
|
self.assertIn('toggleRolePermGroups(false)', APP)
|
|
|
|
def test_user_field_permission_is_three_state(self):
|
|
self.assertIn('继承(', APP)
|
|
self.assertIn('>允许</option>', APP)
|
|
self.assertIn('>拒绝</option>', APP)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|