♻️(backend) pass API token to Yprovider with scheme Bearer

Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
This commit is contained in:
Stephan Meijer
2025-07-04 14:18:30 +02:00
parent 0be366b7b6
commit 65b6701708
2 changed files with 3 additions and 3 deletions

View File

@@ -26,7 +26,7 @@ class YdocConverter:
def auth_header(self):
"""Build microservice authentication header."""
# Note: Yprovider microservice accepts only raw token, which is not recommended
return settings.Y_PROVIDER_API_KEY
return f"Bearer {settings.Y_PROVIDER_API_KEY}"
def convert(self, text):
"""Convert a Markdown text into our internal format using an external microservice."""

View File

@@ -17,7 +17,7 @@ def test_auth_header(settings):
"""Test authentication header generation."""
settings.Y_PROVIDER_API_KEY = "test-key"
converter = YdocConverter()
assert converter.auth_header == "test-key"
assert converter.auth_header == "Bearer test-key"
def test_convert_empty_text():
@@ -82,7 +82,7 @@ def test_convert_full_integration(mock_post, settings):
"http://test.com/conversion-endpoint/",
data="test markdown",
headers={
"Authorization": "test-key",
"Authorization": "Bearer test-key",
"Content-Type": "text/markdown",
},
timeout=5,