diff --git a/eodag/api/core.py b/eodag/api/core.py index a29745086..36f312225 100644 --- a/eodag/api/core.py +++ b/eodag/api/core.py @@ -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 ) diff --git a/tests/units/test_core.py b/tests/units/test_core.py index 99b3c03c2..829572a62 100644 --- a/tests/units/test_core.py +++ b/tests/units/test_core.py @@ -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 ) @@ -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 = {} diff --git a/tests/units/test_http_server.py b/tests/units/test_http_server.py index abd85023a..229fe763f 100644 --- a/tests/units/test_http_server.py +++ b/tests/units/test_http_server.py @@ -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."""