feat(permissions): 运营默认拥有微博强制更新权限

This commit is contained in:
yml
2026-11-14 14:55:42 +08:00
parent 17a2b5c464
commit f8a35ec224
3 changed files with 15 additions and 21 deletions
+13 -20
View File
@@ -309,7 +309,7 @@ def test_occupied_workbench_account_cannot_be_updated_by_another_user(db, curren
assert imported.cookie == original_cookie
def test_super_admin_force_updates_occupied_ck_without_changing_owner(db, current_user):
def test_operator_force_updates_occupied_ck_without_changing_owner(db, current_user):
imported_out = import_cookies(
WeiboCookieImport(text="SCF=a; SUB=owner"),
db=db,
@@ -324,6 +324,14 @@ def test_super_admin_force_updates_occupied_ck_without_changing_owner(db, curren
)
db.add(owner)
db.commit()
operator = User(
username="weibo-force-update-operator",
password_hash="hash",
role="operation",
is_active=True,
)
db.add(operator)
db.commit()
imported.assigned_to = owner.id
db.add(
WeiboWorkbenchAccount(
@@ -341,7 +349,7 @@ def test_super_admin_force_updates_occupied_ck_without_changing_owner(db, curren
force_update=True,
),
db=db,
current=current_user,
current=operator,
)
assert result.count == 1
@@ -1153,7 +1161,7 @@ def test_weibo_batch_assign_cleans_previous_workbench(db):
assert "SCF=a" not in audit.detail
def test_weibo_force_assign_requires_dedicated_permission(db):
def test_weibo_force_assign_permissions_for_operator_and_support(db):
old_support = User(
username="weibo-force-old-support",
password_hash="hash",
@@ -1183,17 +1191,7 @@ def test_weibo_force_assign_requires_dedicated_permission(db):
db.add(account)
db.commit()
assert "weibo:assign:force" not in ROLE_PERMISSIONS["operation"]
with pytest.raises(HTTPException) as exc_info:
batch_assign_accounts(
WeiboBatchAssignRequest(
account_ids=[account.id],
assigned_to=support.id,
),
db=db,
current=operator,
)
assert exc_info.value.status_code == 403
assert "weibo:assign:force" in ROLE_PERMISSIONS["operation"]
with pytest.raises(HTTPException) as exc_info:
force_assign_accounts(
@@ -1203,15 +1201,10 @@ def test_weibo_force_assign_requires_dedicated_permission(db):
expected_count=1,
),
db=db,
current=operator,
current=support,
)
assert exc_info.value.status_code == 403
operator.custom_permissions = [
*ROLE_PERMISSIONS["operation"],
"weibo:assign:force",
]
db.commit()
result = force_assign_accounts(
WeiboForceAssignRequest(
account_ids=[account.id],