1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-08 16:53:23 +00:00

Add full support for Boto

Before this change, vcrpy would not work with modules of Boto (e.g., boto.iam)
that use Boto's CertValidatingHTTPSConnection to connect to AWS (unless you
went through the extra effort of disabling certificate validation during the
tests).  This change adds support for those modules.
This commit is contained in:
Chris Marusich
2014-04-03 11:04:24 -07:00
parent 20ff2e9d9a
commit 955e532162
3 changed files with 54 additions and 0 deletions

View File

@@ -33,6 +33,13 @@ try:
except ImportError: # pragma: no cover
pass
try:
# Try to save the original types for boto
import boto.https_connection
_CertValidatingHTTPSConnection = boto.https_connection.CertValidatingHTTPSConnection
except ImportError: # pragma: no cover
pass
def install(cassette):
"""
@@ -86,6 +93,15 @@ def install(cassette):
except ImportError: # pragma: no cover
pass
# patch boto
try:
import boto.https_connection as cpool
from .stubs.boto_stubs import VCRCertValidatingHTTPSConnection
cpool.CertValidatingHTTPSConnection = VCRCertValidatingHTTPSConnection
cpool.CertValidatingHTTPSConnection.cassette = cassette
except ImportError: # pragma: no cover
pass
def reset():
'''Undo all the patching'''
@@ -120,3 +136,9 @@ def reset():
cpool.SCHEME_TO_CONNECTION = _SCHEME_TO_CONNECTION
except ImportError: # pragma: no cover
pass
try:
import boto.https_connection as cpool
cpool.CertValidatingHTTPSConnection = _CertValidatingHTTPSConnection
except ImportError: # pragma: no cover
pass