diff options
author | Jesse Shapiro <haikuginger@users.noreply.github.com> | 2017-05-01 23:32:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-01 23:32:29 -0400 |
commit | c77ab0c37c0aeab64760a4ea85a0e691da69d62f (patch) | |
tree | ade94b010bfab1554f01cf062843ee934201e8c5 | |
parent | 1f53dcaafa0adae65e0902b5a419dd244e853a91 (diff) | |
parent | 5b7f32cf17b9ff282bd102dec96531cb341fab69 (diff) | |
download | urllib3-c77ab0c37c0aeab64760a4ea85a0e691da69d62f.tar.gz |
Merge pull request #1157 from dims/add-assert-hostname-to-poolmanager
Add assert_hostname to list of valid keys for PoolManager
-rw-r--r-- | CHANGES.rst | 3 | ||||
-rw-r--r-- | test/test_poolmanager.py | 10 | ||||
-rw-r--r-- | urllib3/poolmanager.py | 2 |
3 files changed, 15 insertions, 0 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 5b077135..a0facb4e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,6 +10,9 @@ dev (master) * Fixed regression in 1.21 that threw exceptions when users passed the ``socket_options`` flag to the ``PoolManager``. (Issue #1165) +* Fixed regression in 1.21 that threw exceptions when users passed the + ``assert_hostname`` or ```assert_fingerprint`flag to the ``PoolManager``. + * ... [Short description of non-trivial change.] (Issue #) diff --git a/test/test_poolmanager.py b/test/test_poolmanager.py index aeb39e34..366fd9f0 100644 --- a/test/test_poolmanager.py +++ b/test/test_poolmanager.py @@ -277,6 +277,16 @@ class TestPoolManager(unittest.TestCase): self.assertTrue(pool is other_pool) self.assertTrue(all(isinstance(key, PoolKey) for key in p.pools.keys())) + def test_assert_hostname_and_fingerprint_flag(self): + """Assert that pool manager can accept hostname and fingerprint flags.""" + fingerprint = '92:81:FE:85:F7:0C:26:60:EC:D6:B3:BF:93:CF:F9:71:CC:07:7D:0A' + p = PoolManager(assert_hostname=True, assert_fingerprint=fingerprint) + self.addCleanup(p.clear) + pool = p.connection_from_url('https://example.com/') + self.assertEqual(1, len(p.pools)) + self.assertTrue(pool.assert_hostname) + self.assertEqual(fingerprint, pool.assert_fingerprint) + def test_http_connection_from_context_case_insensitive(self): """Assert scheme case is ignored when getting the https key class.""" p = PoolManager() diff --git a/urllib3/poolmanager.py b/urllib3/poolmanager.py index 39879d88..4ae91744 100644 --- a/urllib3/poolmanager.py +++ b/urllib3/poolmanager.py @@ -45,6 +45,8 @@ _key_fields = ( 'key__proxy_headers', # dict 'key_socket_options', # list of (level (int), optname (int), value (int or str)) tuples 'key__socks_options', # dict + 'key_assert_hostname', # bool or string + 'key_assert_fingerprint', # str ) #: The namedtuple class used to construct keys for the connection pool. |