From 7ef0a0239450a6d3e1fd6c2d071d4fad64b2dfe5 Mon Sep 17 00:00:00 2001 From: Arnon Yaari Date: Tue, 9 Sep 2014 16:36:13 +0300 Subject: [PATCH 1/2] fix httplib NameError --- pyVmomi/SoapAdapter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyVmomi/SoapAdapter.py b/pyVmomi/SoapAdapter.py index cbe67f0..49daa03 100644 --- a/pyVmomi/SoapAdapter.py +++ b/pyVmomi/SoapAdapter.py @@ -1036,7 +1036,7 @@ class SSLTunnelConnection(object): tunnel.request('CONNECT', self.proxyPath) resp = tunnel.getresponse() if resp.status != 200: - raise httplib.HTTPException("{0} {1}".format(resp.status, resp.reason)) + raise http_client.HTTPException("{0} {1}".format(resp.status, resp.reason)) retval = http_client.HTTPSConnection(path) retval.sock = _SocketWrapper(tunnel.sock, keyfile=key_file, certfile=cert_file) From a13262b352041ebf8ec2f6517cc968eb9e4f82e4 Mon Sep 17 00:00:00 2001 From: Arnon Yaari Date: Thu, 11 Sep 2014 11:23:38 +0300 Subject: [PATCH 2/2] add test --- tests/fixtures/ssl_tunnel_http_failure.yaml | 15 +++++++++++++++ tests/test_connect.py | 9 +++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/fixtures/ssl_tunnel_http_failure.yaml diff --git a/tests/fixtures/ssl_tunnel_http_failure.yaml b/tests/fixtures/ssl_tunnel_http_failure.yaml new file mode 100644 index 0000000..ed7d739 --- /dev/null +++ b/tests/fixtures/ssl_tunnel_http_failure.yaml @@ -0,0 +1,15 @@ +interactions: +- request: + body: null + headers: {} + method: CONNECT + uri: http://vcsavcsa:80 + response: + body: {string: !!python/unicode '

404 Not Found

'} + headers: + connection: [close] + content-length: ['48'] + content-type: [text/html] + date: ['Thu, 11 Sep 2014 07:57:56 GMT'] + status: {code: 404, message: Not Found} +version: 1 diff --git a/tests/test_connect.py b/tests/test_connect.py index 9f937ff..66c84ea 100644 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -74,5 +74,14 @@ class ConnectionTests(tests.VCRTestBase): def test_ssl_tunnel(self): connect.SoapStubAdapter('sdkTunnel', 8089, httpProxyHost='vcsa').GetConnection() + @vcr.use_cassette('ssl_tunnel_http_failure.yaml', + cassette_library_dir=tests.fixtures_path, + record_mode='none') + def test_ssl_tunnel_http_failure(self): + from six.moves import http_client + def should_fail(): + connect.SoapStubAdapter('vcsa', 80, httpProxyHost='vcsa').GetConnection() + self.assertRaises(http_client.HTTPException, should_fail) + if __name__ == '__main__': unittest.main() \ No newline at end of file