- 平台治理: 租户用户权限层次、资源ACL、审批中心与审批模板、访问申请 - 存储: MinIO 存储进度迁移、对象存储安全加固与测试 - 计算: GPU 资源预留、compute 轮询与同步增强 - 权限: permission v2 迁移、权限安全验收测试 - 日志: 后端运行日志中文说明、操作日志整合 - 数据处理/评测: 数据转换与模型评测优化 Co-Authored-By: Claude <noreply@anthropic.com>
31 lines
1006 B
Python
31 lines
1006 B
Python
from __future__ import annotations
|
|
|
|
from app.api.v1.endpoints.platform import _public_model
|
|
from app.core.audit import _safe_exception_reason
|
|
from app.core.auth import RESOURCE_ACTIONS, RESOURCE_ACTION_ALIASES
|
|
|
|
|
|
def test_public_model_never_exposes_provider_credentials() -> None:
|
|
result = _public_model({
|
|
"id": "m_1",
|
|
"name": "online",
|
|
"api_url": "https://example.invalid/v1",
|
|
"api_key": "secret-value",
|
|
})
|
|
|
|
assert "api_key" not in result
|
|
assert result["api_key_configured"] is True
|
|
assert result["name"] == "online"
|
|
|
|
|
|
def test_resource_action_registry_keeps_export_separate_from_module_permissions() -> None:
|
|
assert "download" in RESOURCE_ACTIONS
|
|
assert "execute" in RESOURCE_ACTIONS
|
|
assert RESOURCE_ACTION_ALIASES["export"] == "download"
|
|
|
|
|
|
def test_audit_exception_reason_masks_credentials() -> None:
|
|
reason = _safe_exception_reason(ValueError("api_key=secret-value"))
|
|
assert "secret-value" not in reason
|
|
assert "***" in reason
|