Skip to content

Commit

Permalink
Merge pull request #68 from emdgroup/feat/fix_app_service_warning
Browse files Browse the repository at this point in the history
fix: don't show warnings for empty token provider configurations
  • Loading branch information
jonas-w authored Aug 23, 2024
2 parents c362947 + ca75171 commit 2c47443
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ def parse_credentials_config(config_dict: dict | None) -> TokenProvider:
try:
tp_name, tp_config = credentials_config.popitem()
# make it possible to do jwt = "eyJ" instead of jwt = {jwt="eyJ"}
if not isinstance(tp_config, dict):
if tp_config is None or len(tp_config) == 0:
tp_config = {}
elif not isinstance(tp_config, dict):
tp_config = {tp_name: tp_config}
except KeyError:
tp_name, tp_config = None, None
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/config/test_context.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import os
import warnings
from typing import TYPE_CHECKING
from unittest import mock

Expand All @@ -15,11 +16,13 @@


def test_app_service(mock_config_location: dict[Path, None]):
with (
with ( # noqa: PT012
mock.patch.dict(os.environ, {"APP_SERVICE_TS": "1", "FDT_CREDENTIALS__DOMAIN": TEST_DOMAIN}, clear=True),
pytest.raises(
FoundryConfigError,
match="Could not get Foundry token from flask/dash/streamlit headers.",
),
warnings.catch_warnings(),
):
warnings.simplefilter("error") # raise errors on warnings
_ = FoundryContext()

0 comments on commit 2c47443

Please sign in to comment.