Skip to content

Commit

Permalink
[Pyamqp] Remember Proxy Params (Azure#25564)
Browse files Browse the repository at this point in the history
* fix to keep proxy params

* async changes for proxy

* unit tests

* changes

* more changes

Co-authored-by: swathipil <[email protected]>

Co-authored-by: swathipil <[email protected]>
  • Loading branch information
kashifkhan and swathipil committed Aug 23, 2022
1 parent 5e5c67c commit 11184d5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,11 @@ def __init__(
):
self.credential = credential
ssl = ssl or True
http_proxy = kwargs.pop('http_proxy', None)
self._transport = WebSocketTransportAsync(
host,
port=port,
connect_timeout=connect_timeout,
ssl=ssl,
http_proxy=http_proxy,
**kwargs
)
super().__init__(host, port, connect_timeout, ssl, **kwargs)
Expand Down
2 changes: 0 additions & 2 deletions sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/sasl.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,11 @@ class SASLWithWebSocket(WebSocketTransport, SASLTransportMixin):
def __init__(self, host, credential, port=WEBSOCKET_PORT, connect_timeout=None, ssl=None, **kwargs):
self.credential = credential
ssl = ssl or True
http_proxy = kwargs.pop('http_proxy', None)
self._transport = WebSocketTransport(
host,
port=port,
connect_timeout=connect_timeout,
ssl=ssl,
http_proxy=http_proxy,
**kwargs
)
super().__init__(host, port, connect_timeout, ssl, **kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,16 @@ async def test_create_batch_with_too_large_size_async(connection_str):
async with client:
with pytest.raises(ValueError):
await client.create_batch(max_size_in_bytes=5 * 1024 * 1024)

@pytest.mark.liveTest
@pytest.mark.asyncio
async def test_invalid_proxy_server(connection_str):
HTTP_PROXY = {
'proxy_hostname': 'fakeproxy', # proxy hostname.
'proxy_port': 3128, # proxy port.
}

client = EventHubProducerClient.from_connection_string(connection_str, http_proxy=HTTP_PROXY)
async with client:
with pytest.raises(ConnectError):
batch = await client.create_batch()
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,16 @@ def test_create_batch_with_too_large_size_sync(connection_str, uamqp_transport):
with client:
with pytest.raises(ValueError):
client.create_batch(max_size_in_bytes=5 * 1024 * 1024)

@pytest.mark.liveTest
def test_invalid_proxy_server(connection_str):
HTTP_PROXY = {
'proxy_hostname': 'fakeproxy', # proxy hostname.
'proxy_port': 3128, # proxy port.
}

client = EventHubProducerClient.from_connection_string(connection_str, http_proxy=HTTP_PROXY)
with client:
with pytest.raises(ConnectError):
batch = client.create_batch()

0 comments on commit 11184d5

Please sign in to comment.