🔥(backend) remove unused OnlyOffice conversion JWT options

ConvertJwtSecret, ConvertJwtRequired and the jwt_required constructor
guard were never configured in any environment.
This commit is contained in:
Nicolas Clerc
2026-06-08 11:59:32 +02:00
parent cbec3ba077
commit 3e89881cca
4 changed files with 4 additions and 25 deletions
@@ -8,28 +8,19 @@ from django.core.files.base import ContentFile
import jwt
import requests
from wopi.conversion.exceptions import (
ConversionMisconfigured,
ConversionProviderError,
)
from wopi.conversion.exceptions import ConversionProviderError
class OnlyOfficeConversionBackend:
"""Run a synchronous OnlyOffice conversion through the /converter endpoint."""
# pylint: disable-next=too-many-arguments,too-many-positional-arguments
def __init__(
self,
convert_service_url,
jwt_secret=None,
jwt_required=False,
http_timeout=None,
download_timeout=None,
):
if jwt_required and not jwt_secret:
raise ConversionMisconfigured(
"OnlyOffice JWT is required but no ConvertJwtSecret is configured."
)
self.convert_service_url = convert_service_url
self.jwt_secret = jwt_secret
self.http_timeout = http_timeout or (
-2
View File
@@ -56,8 +56,6 @@ def resolve_backend(client_options):
return OnlyOfficeConversionBackend(
convert_service_url=convert_service_url,
jwt_secret=client_options.get("ConvertJwtSecret"),
jwt_required=bool(client_options.get("ConvertJwtRequired", False)),
)
@@ -89,12 +89,6 @@ def test_convert_does_not_sign_when_no_secret():
assert "token" not in payload
def test_constructor_raises_when_jwt_required_but_secret_missing():
"""Fail fast at construction time when JWT is required but the secret is missing."""
with pytest.raises(exceptions.ConversionMisconfigured, match="OnlyOffice JWT is required"):
OnlyOfficeConversionBackend(convert_service_url=CONVERT_URL, jwt_required=True)
@responses.activate
def test_convert_returns_content_file_with_downloaded_bytes():
"""Wrap the downloaded bytes in a ContentFile named after the target."""
@@ -289,18 +289,14 @@ def test_perform_conversion_removes_saved_file_when_database_save_fails(settings
assert deleted_keys == saved_keys
def test_resolve_backend_builds_onlyoffice_backend_from_options():
"""Build the OnlyOffice backend from the WOPI client options."""
def test_resolve_backend_builds_onlyoffice_backend():
"""Build the OnlyOffice backend from WOPI client options."""
backend = services.resolve_backend(
{
"ConvertServiceUrl": "https://office.example/converter",
"ConvertJwtSecret": "test-secret",
},
{"ConvertServiceUrl": "https://office.example/converter"},
)
assert isinstance(backend, OnlyOfficeConversionBackend)
assert backend.convert_service_url == "https://office.example/converter"
assert backend.jwt_secret == "test-secret"
def test_resolve_backend_raises_when_onlyoffice_url_is_missing():