Skip to content

Commit

Permalink
fix: allow requests to respect the environment
Browse files Browse the repository at this point in the history
Used for certs, for now.
  • Loading branch information
gadomski committed Apr 17, 2024
1 parent 4cd8f06 commit eb041d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pystac_client/stac_api_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ def request(
if self.timeout is not None:
msg += f" Timeout: {self.timeout}"
logger.debug(msg)
resp = self.session.send(prepped, timeout=self.timeout)
send_kwargs = self.session.merge_environment_settings(
prepped.url, proxies={}, stream=None, verify=True, cert=None
)
resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
except Exception as err:
logger.debug(err)
raise APIError(str(err))
Expand Down
8 changes: 8 additions & 0 deletions tests/test_stac_api_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from urllib.parse import parse_qs, urlsplit

import pytest
from pytest import MonkeyPatch
from requests_mock.mocker import Mocker

from pystac_client.exceptions import APIError
Expand Down Expand Up @@ -266,3 +267,10 @@ def test_timeout_smoke_test(self) -> None:
stac_api_io = StacApiIO(timeout=42)
response = stac_api_io.read_text(STAC_URLS["PLANETARY-COMPUTER"])
assert isinstance(response, str)

@pytest.mark.parametrize("name", ("REQUESTS_CA_BUNDLE", "CURL_CA_BUNDLE"))
def test_respect_env_for_certs(self, monkeypatch: MonkeyPatch, name: str) -> None:
monkeypatch.setenv(name, "/not/a/real/file")
stac_api_io = StacApiIO()
with pytest.raises(APIError):
stac_api_io.request("https://earth-search.aws.element84.com/v1/")

0 comments on commit eb041d9

Please sign in to comment.