From e071472d58a33af8de6a37ec0cb7ee536a8f3fb7 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Thu, 4 Aug 2022 16:56:23 -0500 Subject: [PATCH 1/5] fix to keep proxy params --- sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/sasl.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/sasl.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/sasl.py index 084a97843eeb..ac89a6985d1b 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/sasl.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/sasl.py @@ -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) From 841fa4cf910bb3449a4dfbd37438ffc757c0e7af Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Fri, 5 Aug 2022 12:49:33 -0500 Subject: [PATCH 2/5] async changes for proxy --- .../azure-eventhub/azure/eventhub/_pyamqp/aio/_sasl_async.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_sasl_async.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_sasl_async.py index 88ee25917c7c..97ca8310dcc3 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_sasl_async.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_sasl_async.py @@ -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) From 5142cbede4bb6b372586f46d0852612bdf5f19be Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Fri, 5 Aug 2022 13:06:45 -0500 Subject: [PATCH 3/5] unit tests --- .../livetest/asynctests/test_negative_async.py | 13 +++++++++++++ .../tests/livetest/synctests/test_negative.py | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py b/sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py index eb1fc0beb663..1f13c519ab84 100644 --- a/sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py +++ b/sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py @@ -163,3 +163,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) + async with client: + with pytest.raises(ConnectError): + batch = await client.create_batch() diff --git a/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py b/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py index d3b775381796..1e025dbeab54 100644 --- a/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py +++ b/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py @@ -119,3 +119,19 @@ def test_create_batch_with_too_large_size_sync(connection_str): 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) + with client: + with pytest.raises(ConnectError): + batch = client.create_batch() + + + + From e3a2baa3bc3dd58d274b222e6e68d596634bee72 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Mon, 8 Aug 2022 13:19:31 -0500 Subject: [PATCH 4/5] changes --- .../tests/livetest/asynctests/test_negative_async.py | 4 ++-- .../azure-eventhub/tests/livetest/synctests/test_negative.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py b/sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py index 1f13c519ab84..2b126bac2266 100644 --- a/sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py +++ b/sdk/eventhub/azure-eventhub/tests/livetest/asynctests/test_negative_async.py @@ -164,7 +164,7 @@ async def test_create_batch_with_too_large_size_async(connection_str): with pytest.raises(ValueError): await client.create_batch(max_size_in_bytes=5 * 1024 * 1024) -pytest.mark.liveTest +@pytest.mark.liveTest @pytest.mark.asyncio async def test_invalid_proxy_server(connection_str): HTTP_PROXY = { @@ -172,7 +172,7 @@ async def test_invalid_proxy_server(connection_str): 'proxy_port': 3128, # proxy port. } - client = EventHubProducerClient.from_connection_string(connection_str) + client = EventHubProducerClient.from_connection_string(connection_str, http_proxy=HTTP_PROXY) async with client: with pytest.raises(ConnectError): batch = await client.create_batch() diff --git a/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py b/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py index 1e025dbeab54..01a9517064fe 100644 --- a/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py +++ b/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py @@ -127,7 +127,7 @@ def test_invalid_proxy_server(connection_str): 'proxy_port': 3128, # proxy port. } - client = EventHubProducerClient.from_connection_string(connection_str) + client = EventHubProducerClient.from_connection_string(connection_str, http_proxy=HTTP_PROXY) with client: with pytest.raises(ConnectError): batch = client.create_batch() From c7dca9cfb277cac13d1dbf595b16665dbcf2b69a Mon Sep 17 00:00:00 2001 From: Kashif Khan <361477+kashifkhan@users.noreply.github.com> Date: Mon, 8 Aug 2022 13:20:14 -0500 Subject: [PATCH 5/5] more changes Co-authored-by: swathipil <76007337+swathipil@users.noreply.github.com> --- .../azure-eventhub/tests/livetest/synctests/test_negative.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py b/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py index 01a9517064fe..8949ecc031b5 100644 --- a/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py +++ b/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py @@ -132,6 +132,3 @@ def test_invalid_proxy_server(connection_str): with pytest.raises(ConnectError): batch = client.create_batch() - - -