Skip to content
Open
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
3 changes: 3 additions & 0 deletions openfga_sdk/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ def __init__(
self.proxy = None
"""Proxy URL
"""
self.trust_env = True
"""Whether the async HTTP client trusts environment proxy and netrc configuration.
"""
self.proxy_headers = None
"""Proxy headers
"""
Expand Down
4 changes: 3 additions & 1 deletion openfga_sdk/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ def __init__(
self.proxy = configuration.proxy
self.proxy_headers = configuration.proxy_headers
self._timeout_millisec = configuration.timeout_millisec
self.pool_manager = aiohttp.ClientSession(connector=connector, trust_env=True)
self.pool_manager = aiohttp.ClientSession(
connector=connector, trust_env=getattr(configuration, "trust_env", True)
)
# aiohttp 3.10+ resends GET, HEAD, PUT and DELETE once by itself when a
# kept-alive connection drops. Turn that off, as aiohttp.test_utils does,
# so retry_params and the resend count are exact; such a request then
Expand Down
16 changes: 16 additions & 0 deletions test/rest_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ def test_restresponse_getheader():
assert missing == "fallback"


@pytest.mark.asyncio
async def test_rest_client_passes_trust_env_to_aiohttp(monkeypatch):
from openfga_sdk.configuration import Configuration

session = MagicMock()
client_session = MagicMock(return_value=session)
monkeypatch.setattr(aiohttp, "ClientSession", client_session)

configuration = Configuration(api_url="http://example.com")
configuration.trust_env = False

RESTClientObject(configuration=configuration)

assert client_session.call_args.kwargs["trust_env"] is False


@pytest.mark.asyncio
async def test_build_request_json_body():
mock_config = MagicMock()
Expand Down