Repository: CS-SI/eodag
Pull request #793 (2023-08-24 07:49:27)

fix: missing auth in search results
Fixes download issues caused by missing authentication object in search results following #753 

github-actions[bot]: ## Test Results
       4 files  ±0         4 suites  ±0   5m 8s [:stopwatch:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "duration of all tests") -21s
   402 tests ±0     400 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "passed tests") ±0    2 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "skipped / disabled tests") ±0  0 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "failed tests") ±0 
1 608 runs  ±0  1 548 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "passed tests") ±0  60 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "skipped / disabled tests") ±0  0 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.9.0/README.md#the-symbols "failed tests") ±0 

Results for commit cc743995. ± Comparison against base commit df440aa6.

[test-results]:data:application/gzip;base64,H4sIAKAM52QC/02NSw7CIBBAr9KwdlEGxOJlDIwlIbbF8FkZ7+4URbp8b2bevJjzy5zYdZCngaXi8x/uJZrsw0YoxokEjXIdjtDolgpiVWNXD/8k1Xec8QuJvjHHGOLPxLLtTa7qi51ak59lV9+mahfHZuVjEsO6+kzAEC9SaE0ha8ECggLnQHFtrUQDxgk9S8Mn9v4AVI6mTAgBAAA=

github-actions[bot]: <strong>Code Coverage (Ubuntu)</strong>

| File | Coverage |   |
| - | :-: | :-: |
| **All files** | `81%` | :white_check_mark: |

_Minimum allowed coverage is `70%`_

<p align="right">Generated by :monkey: cobertura-action against cc74399548bb2b2c262ff2619bb4ca2af39e4a18 </p>
github-actions[bot]: <strong>Code Coverage (Windows)</strong>

| File | Coverage |   |
| - | :-: | :-: |
| **All files** | `76%` | :white_check_mark: |

_Minimum allowed coverage is `70%`_

<p align="right">Generated by :monkey: cobertura-action against cc74399548bb2b2c262ff2619bb4ca2af39e4a18 </p>

Patch:
diff --git a/eodag/api/core.py b/eodag/api/core.py
index 2038cd69..0d589122 100644
--- a/eodag/api/core.py
+++ b/eodag/api/core.py
@@ -1590,13 +1590,6 @@ class EODataAccessGateway(object):
                     download_plugin = self._plugins_manager.get_download_plugin(
                         eo_product
                     )
-                    auth_plugins = kwargs.get("auth", None)
-                    auth = None
-                    if auth_plugins is not None:
-                        if isinstance(auth_plugins, dict):
-                            auth = auth_plugins.get(search_plugin.provider, None)
-                        else:
-                            auth = auth_plugins
                     eo_product.register_downloader(download_plugin, auth)
 
             results.extend(res)
diff --git a/eodag/plugins/download/http.py b/eodag/plugins/download/http.py
index 91d241f5..f05fc160 100644
--- a/eodag/plugins/download/http.py
+++ b/eodag/plugins/download/http.py
@@ -636,7 +636,6 @@ class HTTPDownload(Download):
                 stream_size = self._check_stream_size(product)
                 product.headers = self.stream.headers
                 progress_callback.reset(total=stream_size)
-                logger.debug(f"stream_zip: {stream_size}")
                 for chunk in self.stream.iter_content(chunk_size=64 * 1024):
                     if chunk:
                         progress_callback(len(chunk))


Test patch:
diff --git a/tests/context.py b/tests/context.py
index 3cc2540c..e0317006 100644
--- a/tests/context.py
+++ b/tests/context.py
@@ -50,6 +50,7 @@ from eodag.config import (
 from eodag.plugins.apis.ecmwf import EcmwfApi
 from eodag.plugins.authentication.base import Authentication
 from eodag.plugins.authentication.header import HeaderAuth
+from eodag.plugins.base import PluginTopic
 from eodag.plugins.crunch.filter_date import FilterDate
 from eodag.plugins.crunch.filter_latest_tpl_name import FilterLatestByName
 from eodag.plugins.crunch.filter_property import FilterProperty
diff --git a/tests/integration/test_core_search_results.py b/tests/integration/test_core_search_results.py
index 6fa1369a..8d94a465 100644
--- a/tests/integration/test_core_search_results.py
+++ b/tests/integration/test_core_search_results.py
@@ -24,7 +24,7 @@ import tempfile
 from shapely import geometry
 
 from tests import TEST_RESOURCES_PATH, EODagTestCase
-from tests.context import EODataAccessGateway, EOProduct, SearchResult
+from tests.context import EODataAccessGateway, EOProduct, PluginTopic, SearchResult
 from tests.utils import mock
 
 
@@ -240,3 +240,27 @@ class TestCoreSearchResults(EODagTestCase):
         finally:
             for product_path in products_paths:
                 self._clean_product(product_path)
+
+    @mock.patch(
+        "eodag.plugins.search.qssearch.QueryStringSearch.query",
+        autospec=True,
+    )
+    def test_core_search_results_registered(self, mock_query):
+        """The core api must register search results downloaders"""
+        # QueryStringSearch provider
+        self.dag.set_preferred_provider("peps")
+
+        search_results_file = os.path.join(
+            TEST_RESOURCES_PATH, "eodag_search_result_peps.geojson"
+        )
+        with open(search_results_file, encoding="utf-8") as f:
+            search_results_geojson = json.load(f)
+        products = SearchResult.from_geojson(search_results_geojson)
+
+        mock_query.return_value = (products.data, len(products))
+
+        search_results, count = self.dag.search(productType="S2_MSI_L1C")
+
+        for search_result in search_results:
+            self.assertIsInstance(search_result.downloader, PluginTopic)
+            self.assertIsInstance(search_result.downloader_auth, PluginTopic)