Merge pull request #157 from Infinidat/pull_request_2
Fix SSL tunnel socket
This commit is contained in:
@@ -1035,11 +1035,10 @@ class SSLTunnelConnection(object):
|
||||
tunnel = http_client.HTTPConnection(path, **kwargs)
|
||||
tunnel.request('CONNECT', self.proxyPath)
|
||||
resp = tunnel.getresponse()
|
||||
tunnelSocket = resp.fp
|
||||
if resp.status != 200:
|
||||
raise httplib.HTTPException("{0} {1}".format(resp.status, resp.reason))
|
||||
retval = http_client.HTTPSConnection(path)
|
||||
retval.sock = _SocketWrapper(tunnelSocket,
|
||||
retval.sock = _SocketWrapper(tunnel.sock,
|
||||
keyfile=key_file, certfile=cert_file)
|
||||
return retval
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import logging
|
||||
import os
|
||||
import unittest
|
||||
import vcr
|
||||
import socket
|
||||
|
||||
|
||||
def tests_resource_path(local_path=''):
|
||||
@@ -29,7 +30,7 @@ fixtures_path = tests_resource_path('fixtures')
|
||||
def monkey_patch_vcrpy():
|
||||
# TODO (hartsock): This should be unnecessary. Remove after vcrpy updates.
|
||||
vcr.stubs.VCRHTTPSConnection.is_verified = True
|
||||
|
||||
vcr.stubs.VCRFakeSocket = socket.socket
|
||||
|
||||
class VCRTestBase(unittest.TestCase):
|
||||
|
||||
|
||||
14
tests/fixtures/ssl_tunnel.yaml
vendored
Normal file
14
tests/fixtures/ssl_tunnel.yaml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: null
|
||||
headers: {}
|
||||
method: CONNECT
|
||||
uri: http://vcsasdkTunnel:8089
|
||||
response:
|
||||
body: {string: !!python/unicode ''}
|
||||
headers:
|
||||
content-length: ['0']
|
||||
content-type: [text/html]
|
||||
date: ['Thu, 11 Sep 2014 08:23:36 GMT']
|
||||
status: {code: 200, message: OK}
|
||||
version: 1
|
||||
@@ -68,5 +68,11 @@ class ConnectionTests(tests.VCRTestBase):
|
||||
def test_disconnect_on_no_connection(self):
|
||||
connect.Disconnect(None)
|
||||
|
||||
@vcr.use_cassette('ssl_tunnel.yaml',
|
||||
cassette_library_dir=tests.fixtures_path,
|
||||
record_mode='none')
|
||||
def test_ssl_tunnel(self):
|
||||
connect.SoapStubAdapter('sdkTunnel', 8089, httpProxyHost='vcsa').GetConnection()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user