diff --git a/src/urllib3/contrib/pyopenssl.py b/src/urllib3/contrib/pyopenssl.py index d6bc5c85..deb0314d 100644 --- a/src/urllib3/contrib/pyopenssl.py +++ b/src/urllib3/contrib/pyopenssl.py @@ -18,14 +18,14 @@ pip install pyopenssl cryptography idna To activate certificate checking, call -:func:`~urllib3.contrib.pyopenssl.inject_into_urllib3` from your Python code +:func:`~urllib3.contrib.pyopenssl.inject_into_hip` from your Python code before you begin making HTTP requests. This can be done in a ``sitecustomize`` module, or at any other time before your application begins using ``urllib3``, like this:: try: import urllib3.contrib.pyopenssl - urllib3.contrib.pyopenssl.inject_into_urllib3() + urllib3.contrib.pyopenssl.inject_into_hip() except ImportError: pass @@ -73,7 +73,7 @@ class UnsupportedExtension(Exception): from .. import util -__all__ = ["inject_into_urllib3", "extract_from_urllib3"] +__all__ = ["inject_into_hip", "extract_from_hip"] # SNI always works. HAS_SNI = True @@ -114,7 +114,7 @@ class UnsupportedExtension(Exception): log = logging.getLogger(__name__) -def inject_into_urllib3(): +def inject_into_hip(): "Monkey-patch urllib3 with PyOpenSSL-backed SSL-support." _validate_dependencies_met() @@ -131,8 +131,8 @@ def inject_into_urllib3(): util.ssl_.SSLWantWriteError = OpenSSL.SSL.WantWriteError -def extract_from_urllib3(): - "Undo monkey-patching by :func:`inject_into_urllib3`." +def extract_from_hip(): + "Undo monkey-patching by :func:`inject_into_hip`." util.SSLContext = orig_util_SSLContext util.ssl_.SSLContext = orig_util_SSLContext diff --git a/src/urllib3/contrib/securetransport.py b/src/urllib3/contrib/securetransport.py index 87d844af..c38bb923 100644 --- a/src/urllib3/contrib/securetransport.py +++ b/src/urllib3/contrib/securetransport.py @@ -20,7 +20,7 @@ To use this module, simply import and inject it:: import urllib3.contrib.securetransport - urllib3.contrib.securetransport.inject_into_urllib3() + urllib3.contrib.securetransport.inject_into_hip() Happy TLSing! @@ -76,7 +76,7 @@ _fileobject = None from ..packages.backports.makefile import backport_makefile -__all__ = ["inject_into_urllib3", "extract_from_urllib3"] +__all__ = ["inject_into_hip", "extract_from_hip"] # SNI always works HAS_SNI = True @@ -177,7 +177,7 @@ ) -def inject_into_urllib3(): +def inject_into_hip(): """ Monkey-patch urllib3 with SecureTransport-backed SSL-support. """ @@ -189,9 +189,9 @@ def inject_into_urllib3(): util.ssl_.IS_SECURETRANSPORT = True -def extract_from_urllib3(): +def extract_from_hip(): """ - Undo monkey-patching by :func:`inject_into_urllib3`. + Undo monkey-patching by :func:`inject_into_hip`. """ util.SSLContext = orig_util_SSLContext util.ssl_.SSLContext = orig_util_SSLContext diff --git a/test/contrib/test_pyopenssl.py b/test/contrib/test_pyopenssl.py index abbf387d..2e4b3dcf 100644 --- a/test/contrib/test_pyopenssl.py +++ b/test/contrib/test_pyopenssl.py @@ -5,8 +5,7 @@ import pytest pytestmark = pytest.mark.skip( - "inject_into_urllib3/extract_from_urllib3 appear to break the standard " - "library SSL tests" + "inject_into_hip/extract_from_hip appear to break the standard library SSL tests" ) try: @@ -19,18 +18,18 @@ def setup_module(): try: - from urllib3.contrib.pyopenssl import inject_into_urllib3 + from urllib3.contrib.pyopenssl import inject_into_hip - inject_into_urllib3() + inject_into_hip() except ImportError as e: pytest.skip("Could not import PyOpenSSL: %r" % e) def teardown_module(): try: - from urllib3.contrib.pyopenssl import extract_from_urllib3 + from urllib3.contrib.pyopenssl import extract_from_hip - extract_from_urllib3() + extract_from_hip() except ImportError: pass diff --git a/test/contrib/test_pyopenssl_dependencies.py b/test/contrib/test_pyopenssl_dependencies.py index bbb5833d..95cb7085 100644 --- a/test/contrib/test_pyopenssl_dependencies.py +++ b/test/contrib/test_pyopenssl_dependencies.py @@ -4,32 +4,32 @@ from mock import patch, Mock try: - from urllib3.contrib.pyopenssl import inject_into_urllib3, extract_from_urllib3 + from urllib3.contrib.pyopenssl import inject_into_hip, extract_from_hip except ImportError: pass def setup_module(): try: - from urllib3.contrib.pyopenssl import inject_into_urllib3 + from urllib3.contrib.pyopenssl import inject_into_hip - inject_into_urllib3() + inject_into_hip() except ImportError as e: pytest.skip("Could not import PyOpenSSL: %r" % e) def teardown_module(): try: - from urllib3.contrib.pyopenssl import extract_from_urllib3 + from urllib3.contrib.pyopenssl import extract_from_hip - extract_from_urllib3() + extract_from_hip() except ImportError: pass class TestPyOpenSSLInjection(object): """ - Tests for error handling in pyopenssl's 'inject_into urllib3' + Tests for error handling in pyopenssl's 'inject_into_hip' """ def test_inject_validate_fail_cryptography(self): @@ -40,12 +40,12 @@ def test_inject_validate_fail_cryptography(self): with patch("cryptography.x509.extensions.Extensions") as mock: del mock.get_extension_for_class with pytest.raises(ImportError): - inject_into_urllib3() + inject_into_hip() finally: - # `inject_into_urllib3` is not supposed to succeed. + # `inject_into_hip` is not supposed to succeed. # If it does, this test should fail, but we need to # clean up so that subsequent tests are unaffected. - extract_from_urllib3() + extract_from_hip() def test_inject_validate_fail_pyopenssl(self): """ @@ -56,9 +56,9 @@ def test_inject_validate_fail_pyopenssl(self): del return_val._x509 with patch("OpenSSL.crypto.X509", return_value=return_val): with pytest.raises(ImportError): - inject_into_urllib3() + inject_into_hip() finally: - # `inject_into_urllib3` is not supposed to succeed. + # `inject_into_hip` is not supposed to succeed. # If it does, this test should fail, but we need to # clean up so that subsequent tests are unaffected. - extract_from_urllib3() + extract_from_hip() diff --git a/test/contrib/test_securetransport.py b/test/contrib/test_securetransport.py index 979bd6bb..009d4d74 100644 --- a/test/contrib/test_securetransport.py +++ b/test/contrib/test_securetransport.py @@ -15,18 +15,18 @@ def setup_module(): try: - from urllib3.contrib.securetransport import inject_into_urllib3 + from urllib3.contrib.securetransport import inject_into_hip - inject_into_urllib3() + inject_into_hip() except ImportError as e: pytest.skip("Could not import SecureTransport: %r" % e) def teardown_module(): try: - from urllib3.contrib.securetransport import extract_from_urllib3 + from urllib3.contrib.securetransport import extract_from_hip - extract_from_urllib3() + extract_from_hip() except ImportError: pass