|
1 | 1 | import logging
|
2 | 2 | import os
|
3 | 3 | import random
|
| 4 | +import re |
| 5 | +import urllib.parse |
4 | 6 | from typing import Callable
|
5 | 7 |
|
6 | 8 | import openeo
|
@@ -37,6 +39,7 @@ def pytest_addoption(parser):
|
37 | 39 | help="When provided this url will be used instead of the backend listed in the benchmark json files.",
|
38 | 40 | )
|
39 | 41 |
|
| 42 | + |
40 | 43 | def pytest_ignore_collect(collection_path, config):
|
41 | 44 | """
|
42 | 45 | Pytest hook to ignore certain directories/files during test collection.
|
@@ -80,13 +83,25 @@ def _get_client_credentials_env_var(url: str) -> str:
|
80 | 83 | """
|
81 | 84 | Get client credentials env var name for a given backend URL.
|
82 | 85 | """
|
83 |
| - # TODO: parse url to more reliably extract hostname |
84 |
| - if url == "openeofed.dataspace.copernicus.eu": |
| 86 | + if not re.match(r"https?://", url): |
| 87 | + url = f"https://{url}" |
| 88 | + parsed = urllib.parse.urlparse(url) |
| 89 | + hostname = parsed.hostname |
| 90 | + if hostname in { |
| 91 | + "openeo.dataspace.copernicus.eu", |
| 92 | + "openeofed.dataspace.copernicus.eu", |
| 93 | + }: |
| 94 | + # TODO: env var could just be OPENEO_AUTH_CLIENT_CREDENTIALS_CDSE |
| 95 | + # (which should work on both classic CDSE and CDSEfed) |
85 | 96 | return "OPENEO_AUTH_CLIENT_CREDENTIALS_CDSEFED"
|
86 |
| - elif "openeo-staging.dataspace.copernicus.eu" in url: |
| 97 | + elif hostname == "openeo-staging.dataspace.copernicus.eu": |
87 | 98 | return "OPENEO_AUTH_CLIENT_CREDENTIALS_CDSESTAG"
|
| 99 | + elif hostname == "openeo.cloud": |
| 100 | + return "OPENEO_AUTH_CLIENT_CREDENTIALS_EGI" |
| 101 | + elif hostname in {"openeo.vito.be", "openeo.terrascope.be"}: |
| 102 | + return "OPENEO_AUTH_CLIENT_CREDENTIALS_TERRASCOPE" |
88 | 103 | else:
|
89 |
| - raise ValueError(f"Unsupported backend: {url}") |
| 104 | + raise ValueError(f"Unsupported backend: {url=} ({hostname=})") |
90 | 105 |
|
91 | 106 |
|
92 | 107 | @pytest.fixture
|
|
0 commit comments