23 lines
763 B
Python
23 lines
763 B
Python
"""A 模块(平台基础与企业治理)第 1 周:鉴权与权限码基础测试。
|
|
|
|
不需要数据库连接,可直接运行:
|
|
cd backend && python -m pytest tests/test_auth_service.py -q
|
|
"""
|
|
from app.db.platform_store import ALL_PERMISSIONS
|
|
from app.modules.auth.service import create_access_token, decode_access_token
|
|
|
|
|
|
def test_token_roundtrip():
|
|
token = create_access_token("u_abc")
|
|
assert decode_access_token(token) == "u_abc"
|
|
|
|
|
|
def test_decode_invalid_token_returns_none():
|
|
assert decode_access_token("not.a.valid.token") is None
|
|
|
|
|
|
def test_permission_codes_present():
|
|
for code in ("dashboard", "fine-tune", "model-manage", "user-settings", "logs"):
|
|
assert code in ALL_PERMISSIONS
|
|
assert len(ALL_PERMISSIONS) >= 12
|