feat(weibo): 增加客服默认操作权限

This commit is contained in:
yml2213
2026-11-08 15:02:03 +08:00
parent a927be36f2
commit 5d6325d74c
2 changed files with 41 additions and 1 deletions
+32 -1
View File
@@ -19,6 +19,7 @@ from core.weibo import (
WeiboRechargeOrder,
)
from web.backend.models import AuditLog, User, WeiboAccount
from web.backend.permissions import ROLE_PERMISSIONS
from web.backend.routers import weibo as weibo_router
from web.backend.routers.weibo import (
copy_account_ck,
@@ -256,8 +257,20 @@ def test_copy_account_ck_uses_export_permission_defaults(db, current_user):
db.add(support)
db.commit()
support_result = copy_account_ck(account_out.id, db=db, current=support)
assert support_result.ck_text == "SCF=a; SUB=b"
denied = User(
username="weibo-copy-denied",
password_hash="hash",
role="support",
custom_permissions=[],
is_active=True,
)
db.add(denied)
db.commit()
with pytest.raises(HTTPException) as exc_info:
copy_account_ck(account_out.id, db=db, current=support)
copy_account_ck(account_out.id, db=db, current=denied)
assert exc_info.value.status_code == 403
@@ -273,6 +286,24 @@ def test_copy_account_ck_uses_export_permission_defaults(db, current_user):
assert result.ck_text == "SCF=a; SUB=b"
def test_support_role_has_weibo_operation_permissions_without_delete():
support = set(ROLE_PERMISSIONS["support"])
assert {
"weibo:view",
"weibo:import",
"weibo:manage",
"weibo:account:ck_export",
"weibo:bind",
"weibo:recharge",
"weibo:exchange",
"weibo:collab:view",
"weibo:collab:edit",
} <= support
assert "weibo:delete" not in support
assert "weibo:collab:manage" not in support
def test_list_accounts_returns_parallel_page_shape(db, current_user):
assert (
import_cookies(