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) 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) 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 4d5880d9d2dc..660fb5e81b06 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 @@ -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() 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 ba58cf2a00c7..a6fa1acf06b1 100644 --- a/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py +++ b/sdk/eventhub/azure-eventhub/tests/livetest/synctests/test_negative.py @@ -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() +