Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ async def exchange_token(user_token: str, url: str) -> str:
provider = settings.backend_auth_config[url].token_provider
token_prefix = settings.backend_auth_config[url].token_prefix

if not provider or not token_prefix:
if not provider:
raise ValueError(
f"Backend '{url}' must define 'token_provider' and 'token_prefix'"
f"Backend '{url}' must define 'token_provider'"
)

platform_token = await _exchange_token_for_provider(
Expand Down
21 changes: 0 additions & 21 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,6 @@ async def test_exchange_token_missing_provider():
settings.backend_auth_config[url] = original_config


@pytest.mark.asyncio
async def test_exchange_token_missing_token_prefix():
url = "https://openeo.vito.be"
original_config = settings.backend_auth_config.get(url)

try:
# Create a config without token_prefix
settings.backend_auth_config[url] = BackendAuthConfig(
auth_method=AuthMethod.USER_CREDENTIALS,
token_provider="openeo",
token_prefix=None,
)

with pytest.raises(ValueError, match="must define"):
await exchange_token("user-token", url)
finally:
# Restore original config
if original_config:
settings.backend_auth_config[url] = original_config


@pytest.mark.asyncio
@patch(
"app.auth._exchange_token_for_provider",
Expand Down
Loading