Skip to content

Commit

Permalink
fix(queryables): missing search plugin auth (#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
alambare authored Jun 11, 2024
1 parent 5f1b707 commit 72ca3d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions eodag/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,10 @@ def list_queryables(
providers_queryables: Dict[str, Dict[str, Annotated[Any, FieldInfo]]] = {}

for plugin in self._plugins_manager.get_search_plugins(product_type, provider):
if getattr(plugin.config, "need_auth", False) and (
auth := self._plugins_manager.get_auth_plugin(plugin.provider)
):
plugin.auth = auth.authenticate()
providers_queryables[plugin.provider] = plugin.list_queryables(
filters=kwargs, product_type=product_type
)
Expand Down
5 changes: 5 additions & 0 deletions tests/units/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,10 @@ def test_update_providers_config(self):
# run a 2nd time: check that it does not raise an error
self.dag.update_providers_config(new_config)

@mock.patch(
"eodag.plugins.manager.PluginManager.get_auth_plugin",
autospec=True,
)
@mock.patch(
"eodag.api.core.EODataAccessGateway.fetch_product_types_list", autospec=True
)
Expand All @@ -1304,6 +1308,7 @@ def test_list_queryables(
mock_stacsearch_discover_queryables: Mock,
mock_qssearch_discover_queryables: Mock,
mock_fetch_product_types_list: Mock,
mock_auth_plugin: Mock,
) -> None:
"""list_queryables must return queryables list adapted to provider and product-type"""
mock_stacsearch_discover_queryables.return_value = {}
Expand Down
4 changes: 1 addition & 3 deletions tests/units/test_http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,9 +1392,7 @@ def test_queryables_with_provider_error(self):

self.assertEqual(400, response.status_code)

@mock.patch(
"eodag.plugins.authentication.token.requests.Session.post", autospec=True
)
@mock.patch("eodag.plugins.manager.PluginManager.get_auth_plugin", autospec=True)
def test_product_type_queryables(self, mock_requests_session_post):
"""Request to /collections/{collection_id}/queryables should return a valid response."""

Expand Down

0 comments on commit 72ca3d7

Please sign in to comment.