From 97b5fcf0da646e5e948162fe849d0acad41278d2 Mon Sep 17 00:00:00 2001 From: Arnon Yaari Date: Thu, 11 Sep 2014 13:05:07 +0300 Subject: [PATCH] add test for SSLTunnelConnection --- tests/__init__.py | 3 ++- tests/fixtures/ssl_tunnel.yaml | 14 ++++++++++++++ tests/test_connect.py | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/ssl_tunnel.yaml diff --git a/tests/__init__.py b/tests/__init__.py index 8b1c9b7..f7cef1e 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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): diff --git a/tests/fixtures/ssl_tunnel.yaml b/tests/fixtures/ssl_tunnel.yaml new file mode 100644 index 0000000..4a0f260 --- /dev/null +++ b/tests/fixtures/ssl_tunnel.yaml @@ -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 diff --git a/tests/test_connect.py b/tests/test_connect.py index 9ad982f..9f937ff 100644 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -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() \ No newline at end of file