feat(shipping-notice): 增强订单抽取功能,添加进度事件和诊断运行管理,优化数据模型和访问控制
This commit is contained in:
1 parent
ce26d6d0c4
commit
c4095b08da
175 files changed
+13064
-1814
No files matched your search
@@ -3,8 +3,11 @@ tests/services/admin/test_user_service.py
|
||||
|
||||
用途:user_service 管理端用户 CRUD 单元测试。
|
||||
"""
|
||||
import pytest
|
||||
|
||||
from app import db
|
||||
from app.models import User
|
||||
from app.core.errors import ValidationError
|
||||
from app.models import Agent, User
|
||||
from app.services.admin import user_service
|
||||
|
||||
|
||||
@@ -52,3 +55,22 @@ def test_list_users_sort_by_username_and_department(app):
|
||||
|
||||
fallback = user_service.resolve_users_order_by({'sort_by': 'role', 'sort_dir': 'asc'})
|
||||
assert len(fallback) == 1
|
||||
|
||||
|
||||
def test_update_user_rejects_internal_executor_permission(app):
|
||||
"""用户 CRUD 的 agent_ids 写入口不得绕过统一授权策略。"""
|
||||
with app.app_context():
|
||||
user = User(username='crud-internal', email='crud-internal@example.com', role='user')
|
||||
executor = Agent(
|
||||
name='CRUD Executor', exposure_mode='internal', runtime_provider='dify',
|
||||
dify_app_type='workflow', dify_app_id='crud-workflow', dify_api_key='key',
|
||||
)
|
||||
db.session.add_all([user, executor])
|
||||
db.session.commit()
|
||||
|
||||
with pytest.raises(ValidationError) as caught:
|
||||
user_service.update_user(user.id, {'agent_ids': [executor.id]})
|
||||
|
||||
assert caught.value.code == 'AGENT.INTERNAL_EXECUTOR_USER_ACCESS_FORBIDDEN'
|
||||
db.session.refresh(user)
|
||||
assert executor not in user.agents
|
||||
Reference in new issue
Block a user