Skip to content

Commit 67c1e1f

Browse files
committed
Respect trust_env on AsyncHttpConnection
Signed-off-by: Ron Smeral <[email protected]>
1 parent 7336f51 commit 67c1e1f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

opensearchpy/connection/http_async.py

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(
5454
http_compress: Optional[bool] = None,
5555
opaque_id: Optional[str] = None,
5656
loop: Any = None,
57+
trust_env: Optional[bool] = False,
5758
**kwargs: Any,
5859
) -> None:
5960
self.headers = {}
@@ -65,6 +66,7 @@ def __init__(
6566
headers=headers,
6667
http_compress=http_compress,
6768
opaque_id=opaque_id,
69+
trust_env=trust_env,
6870
**kwargs,
6971
)
7072

@@ -290,6 +292,7 @@ async def _create_aiohttp_session(self) -> Any:
290292
connector=aiohttp.TCPConnector(
291293
limit=self._limit, use_dns_cache=True, ssl=self._ssl_context
292294
),
295+
trust_env=self._trust_env,
293296
)
294297

295298

test_opensearchpy/test_async/test_http_connection.py

+12
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,15 @@ def auth_fn(*args: Any, **kwargs: Any) -> Any:
135135
),
136136
fingerprint=None,
137137
)
138+
139+
@pytest.mark.asyncio # type: ignore
140+
async def test_trust_env_default_off(self) -> None:
141+
conn = AsyncHttpConnection(loop=get_running_loop())
142+
await conn._create_aiohttp_session()
143+
assert not conn.session.trust_env
144+
145+
@pytest.mark.asyncio # type: ignore
146+
async def test_trust_env_on(self) -> None:
147+
conn = AsyncHttpConnection(loop=get_running_loop(), trust_env=True)
148+
await conn._create_aiohttp_session()
149+
assert conn.session.trust_env

0 commit comments

Comments
 (0)