Skip to content

Commit

Permalink
Respect trust_env on AsyncHttpConnection
Browse files Browse the repository at this point in the history
Signed-off-by: Ron Smeral <[email protected]>
  • Loading branch information
rsmeral committed Jan 22, 2025
1 parent 7336f51 commit 67c1e1f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions opensearchpy/connection/http_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(
http_compress: Optional[bool] = None,
opaque_id: Optional[str] = None,
loop: Any = None,
trust_env: Optional[bool] = False,
**kwargs: Any,
) -> None:
self.headers = {}
Expand All @@ -65,6 +66,7 @@ def __init__(
headers=headers,
http_compress=http_compress,
opaque_id=opaque_id,
trust_env=trust_env,
**kwargs,
)

Expand Down Expand Up @@ -290,6 +292,7 @@ async def _create_aiohttp_session(self) -> Any:
connector=aiohttp.TCPConnector(
limit=self._limit, use_dns_cache=True, ssl=self._ssl_context
),
trust_env=self._trust_env,
)


Expand Down
12 changes: 12 additions & 0 deletions test_opensearchpy/test_async/test_http_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,15 @@ def auth_fn(*args: Any, **kwargs: Any) -> Any:
),
fingerprint=None,
)

@pytest.mark.asyncio # type: ignore
async def test_trust_env_default_off(self) -> None:
conn = AsyncHttpConnection(loop=get_running_loop())
await conn._create_aiohttp_session()
assert not conn.session.trust_env

@pytest.mark.asyncio # type: ignore
async def test_trust_env_on(self) -> None:
conn = AsyncHttpConnection(loop=get_running_loop(), trust_env=True)
await conn._create_aiohttp_session()
assert conn.session.trust_env

0 comments on commit 67c1e1f

Please sign in to comment.