Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(queryables): missing search plugin auth #1194

Merged
merged 1 commit into from
Jun 11, 2024
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: 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
Loading