fix(agent-assets): allow admin access to platform rules
This commit is contained in:
@@ -693,6 +693,9 @@ def test_platform_spreadsheet_onlyoffice_requires_platform_admin_to_edit(monkeyp
|
||||
admin_callback_token = parse_qs(
|
||||
urlsplit(admin_config.config["editorConfig"]["callbackUrl"]).query
|
||||
)["access_token"][0]
|
||||
admin_content_token = parse_qs(
|
||||
urlsplit(admin_config.config["document"]["url"]).query
|
||||
)["access_token"][0]
|
||||
finance_session = service.validate_rule_spreadsheet_access_token(
|
||||
rule.id,
|
||||
finance_callback_token,
|
||||
@@ -708,6 +711,33 @@ def test_platform_spreadsheet_onlyoffice_requires_platform_admin_to_edit(monkeyp
|
||||
assert admin_session.tenant_id == "platform"
|
||||
assert admin_session.resource_scope == "platform"
|
||||
assert admin_session.actor == "username:platform_admin"
|
||||
|
||||
content_session = service.validate_rule_spreadsheet_access_token(
|
||||
rule.id,
|
||||
admin_content_token,
|
||||
)
|
||||
onlyoffice_service = AgentAssetService(
|
||||
db,
|
||||
current_user=CurrentUserContext(
|
||||
username=content_session.actor,
|
||||
name="ONLYOFFICE",
|
||||
role_codes=["manager"],
|
||||
is_admin=True,
|
||||
tenant_id=content_session.tenant_id,
|
||||
),
|
||||
)
|
||||
content_path, content_type, content_name = (
|
||||
onlyoffice_service.get_rule_spreadsheet_content(
|
||||
rule.id,
|
||||
validated_session=content_session,
|
||||
)
|
||||
)
|
||||
assert content_path.exists()
|
||||
assert content_type == (
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
)
|
||||
assert content_name.endswith(".xlsx")
|
||||
|
||||
with pytest.raises(AgentAssetOnlyOfficeSecurityError, match="不匹配"):
|
||||
service.validate_rule_spreadsheet_access_token(
|
||||
"different-asset",
|
||||
|
||||
Reference in New Issue
Block a user