refactor(agent, shipping): 简化代理模型并完善订单抽取业务
- 移除 Agent 的 exposure_mode 与 internal_executor 相关逻辑,清理关联的过滤、序列化代码 - 删除废弃的 AgentRuntimeBinding 模型及其依赖 - 新增订单抽取上传批次、请求快照等数据库迁移与业务逻辑 - 修复附件完整性检测、订单抽取状态映射问题 - 更新多语言错误文案与前端单元测试配置 - 清理平台配置中不再使用的暴露模式配置
This commit is contained in:
1 parent
1f3ecb87b7
commit
61ac6403c4
159 files changed
+12883
-5099
No files matched your search
@@ -50,31 +50,6 @@ def test_batch_update_permissions_no_users(app):
|
||||
permission_service.batch_update_permissions({'user_ids': [], 'agent_ids': [1]})
|
||||
|
||||
|
||||
@pytest.mark.parametrize('operation', ['single', 'batch'])
|
||||
def test_internal_executor_cannot_be_assigned_to_user(app, operation):
|
||||
"""授权服务必须在所有写入口拒绝 internal 执行器。"""
|
||||
with app.app_context():
|
||||
executor = Agent(
|
||||
name='internal-executor', type='api', dify_app_id='wf-internal', dify_api_key='key',
|
||||
dify_app_type='workflow', runtime_provider='dify', exposure_mode='internal',
|
||||
)
|
||||
user = User(username=f'internal-{operation}', email=f'internal-{operation}@example.com', role='user')
|
||||
db.session.add_all([executor, user])
|
||||
db.session.commit()
|
||||
|
||||
with pytest.raises(ValidationError) as caught:
|
||||
if operation == 'single':
|
||||
permission_service.update_user_permissions(user.id, {'agent_ids': [executor.id]})
|
||||
else:
|
||||
permission_service.batch_update_permissions({
|
||||
'user_ids': [user.id], 'agent_ids': [executor.id], 'action': 'add',
|
||||
})
|
||||
|
||||
assert caught.value.code == 'AGENT.INTERNAL_EXECUTOR_USER_ACCESS_FORBIDDEN'
|
||||
db.session.refresh(user)
|
||||
assert executor not in user.agents
|
||||
|
||||
|
||||
def test_permission_request_approve(app, monkeypatch):
|
||||
with app.app_context():
|
||||
agent = Agent(name='req-agent', type='api', dify_app_id='app-r', dify_api_key='key-r')
|
||||
@@ -100,27 +75,3 @@ def test_permission_request_approve(app, monkeypatch):
|
||||
|
||||
def test_permission_request_not_found(app):
|
||||
with app.app_context():
|
||||
with pytest.raises(NotFoundError):
|
||||
permission_service.approve_permission_request(99999)
|
||||
|
||||
|
||||
def test_internal_executor_permission_request_cannot_be_approved(app):
|
||||
"""历史或伪造的内部执行器权限申请不得转化为用户授权。"""
|
||||
with app.app_context():
|
||||
executor = Agent(
|
||||
name='request-executor', type='api', dify_app_id='wf-request', dify_api_key='key',
|
||||
dify_app_type='workflow', runtime_provider='dify', exposure_mode='internal',
|
||||
)
|
||||
user = User(username='request-internal', email='request-internal@example.com', role='user')
|
||||
db.session.add_all([executor, user])
|
||||
db.session.flush()
|
||||
req = PermissionRequest(user_id=user.id, agent_id=executor.id, reason='invalid', status='pending')
|
||||
db.session.add(req)
|
||||
db.session.commit()
|
||||
|
||||
with pytest.raises(ForbiddenError) as caught:
|
||||
permission_service.approve_permission_request(req.id)
|
||||
|
||||
assert getattr(caught.value, 'code', None) == 'AGENT.INTERNAL_EXECUTOR_USER_ACCESS_FORBIDDEN'
|
||||
db.session.refresh(user)
|
||||
assert executor not in user.agents
|
||||
Reference in new issue
Block a user