fix(contract-payment): fix comments of contract payment plan

This commit is contained in:
sophie committed 2026-09-10 13:20:13 +08:00
1 parent 60d4f06018
commit 1c0654c6f8
25 files changed
+956 -76

No files matched your search

@@ -3,7 +3,7 @@ backend/tests/test_contract_payment_permissions.py
用途:验收合同付款预警专项权限 `contract_payment.access` 的角色默认值、显式覆盖与 API 拦截。
依赖:User 功能权限、Flask test client、contract_payment 蓝图。
逻辑:admin 默认可访问;普通用户默认 403;显式授予后可查询台账;关闭 admin 覆盖后同样 403。
逻辑:admin 默认可访问;普通用户默认 403;显式授予后可查询台账,但不能触发同步/扫描/发送;关闭 admin 覆盖后同样 403。
"""
from __future__ import annotations
@@ -128,3 +128,23 @@ def test_contract_payment_api_allows_granted_user(client, app):
body = list_res.get_json()
assert body.get('success') is True
assert 'items' in (body.get('data') or {})
def test_contract_payment_jobs_require_admin(client, app):
"""已授权的普通用户可查台账,但不能触发同步、扫描或周汇总发送。"""
with app.app_context():
granted = _create_user(
username='cp_api_jobs_denied',
feature_permissions={'contract_payment.access': True},
)
headers = _auth_headers(granted)
# 关键断言:访问权不等于操作权,手动任务仅管理员。
for path in (
'/api/contract-payment/sync',
'/api/contract-payment/alerts/run',
'/api/contract-payment/alerts/weekly-run',
):
res = client.post(path, headers=headers, json={})
assert res.status_code == 403, path
assert _json_error(res)['code'] == 'CONTRACT_PAYMENT.ADMIN_REQUIRED'