feat(weibo): 增加客服默认操作权限
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -159,6 +159,15 @@ ROLE_PERMISSIONS = {
|
||||
"douyu:collab:edit",
|
||||
"yyb:session",
|
||||
"yyb:history",
|
||||
"weibo:view",
|
||||
"weibo:import",
|
||||
"weibo:manage",
|
||||
"weibo:account:ck_export",
|
||||
"weibo:bind",
|
||||
"weibo:recharge",
|
||||
"weibo:exchange",
|
||||
"weibo:collab:view",
|
||||
"weibo:collab:edit",
|
||||
"huya:view_assigned",
|
||||
"huya:tag",
|
||||
"huya:task",
|
||||
|
||||
Reference in New Issue
Block a user