31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
"""权限配置 P1:数据范围与变更审计回归检查。"""
|
||
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 PermissionP1StaticTest(unittest.TestCase):
|
||
def test_p1_tables_and_scope_api_exist(self):
|
||
self.assertIn('permission_data_scopes', AUTH)
|
||
self.assertIn('permission_change_audits', AUTH)
|
||
self.assertIn("@auth_bp.route('/api/permissions/data-scopes')", AUTH)
|
||
self.assertIn("@auth_bp.route('/api/permissions/data-scopes/save', methods=['POST'])", AUTH)
|
||
|
||
def test_audit_api_and_write_hooks_exist(self):
|
||
self.assertIn("@auth_bp.route('/api/permissions/audits')", AUTH)
|
||
self.assertIn("_record_permission_change('role'", AUTH)
|
||
self.assertIn("_record_permission_change('user'", AUTH)
|
||
|
||
def test_scope_and_audit_controls_are_visible(self):
|
||
self.assertIn('openRoleScopeModal', APP)
|
||
self.assertIn('openPermissionAuditModal', APP)
|
||
self.assertIn('数据范围', APP)
|
||
self.assertIn('权限变更审计', APP)
|
||
|
||
|
||
if __name__ == '__main__':
|
||
unittest.main()
|