From 5aad292d930d4b37222c4a3502dbd549ab95347bd6d63bca289035ae89f5326e Mon Sep 17 00:00:00 2001 From: Jan Matejek Date: Fri, 13 Nov 2015 14:47:50 +0000 Subject: [PATCH 1/2] Accepting request 344244 from home:matejcik:branches:devel:languages:python - removed python-certifi dependency, we don't want to use it - drop 0001-Don-t-pin-dependency-to-exact-version.patch because it's not needed anymore - re-enable tests, re-add dependencies * don't exclude test_util.py * exclude proxy timeout tests that fail for spurious reasons - urllib3-ssl-default-context.patch - use set_default_verify_paths() if no certificate path specified and verification not explicitly disabled - urllib3-test-ssl-drop-sslv3.patch - don't use "SSLv3" constants as they are not supported in openssl (and conversely python) anymore - ready-event.patch - fix race conditions in timeout tests OBS-URL: https://build.opensuse.org/request/show/344244 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-urllib3?expand=0&rev=12 --- ...on-t-pin-dependency-to-exact-version.patch | 37 ------ python-urllib3.changes | 16 +++ python-urllib3.spec | 26 ++++- ready-event.patch | 106 ++++++++++++++++++ urllib3-ssl-default-context.patch | 13 +++ urllib3-test-ssl-drop-sslv3.patch | 31 +++++ 6 files changed, 188 insertions(+), 41 deletions(-) delete mode 100644 0001-Don-t-pin-dependency-to-exact-version.patch create mode 100644 ready-event.patch create mode 100644 urllib3-ssl-default-context.patch create mode 100644 urllib3-test-ssl-drop-sslv3.patch diff --git a/0001-Don-t-pin-dependency-to-exact-version.patch b/0001-Don-t-pin-dependency-to-exact-version.patch deleted file mode 100644 index d7b2d8f..0000000 --- a/0001-Don-t-pin-dependency-to-exact-version.patch +++ /dev/null @@ -1,37 +0,0 @@ -From c8ce46178f97cc765a569864302b75aaa730d590 Mon Sep 17 00:00:00 2001 -From: Sascha Peilicke -Date: Thu, 20 Mar 2014 15:35:51 +0100 -Subject: [PATCH] Don't pin dependency to exact version - -While this expresses with which versions urllib3 is tested to work with, -almost all distros ship different package versions. To accomodate that -(and to avoid having them to patch away these hard requirements) only -use '>='. ---- - test-requirements.txt | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/dev-requirements.txt b/dev-requirements.txt -index 02d70f4..98de1cc 100644 ---- a/dev-requirements.txt -+++ b/dev-requirements.txt -@@ -1,8 +1,8 @@ --nose==1.3.7 --nose-exclude==0.4.1 --mock==1.3.0 --coverage==3.7.1 --tox==2.1.1 --twine==1.5.0 --wheel==0.24.0 --tornado==4.2.1 -+nose>=1.3.7 -+nose-exclude>=0.4.1 -+mock>=1.3.0 -+coverage>=3.7.1 -+tox>=2.1.1 -+twine>=1.5.0 -+wheel>=0.24.0 -+tornado>=4.2.1 --- -1.9.0 - diff --git a/python-urllib3.changes b/python-urllib3.changes index fdd0d6b..6cd1456 100644 --- a/python-urllib3.changes +++ b/python-urllib3.changes @@ -1,3 +1,19 @@ +------------------------------------------------------------------- +Wed Oct 27 16:33:44 UTC 2015 - jmatejek@suse.com + +- removed python-certifi dependency, we don't want to use it +- drop 0001-Don-t-pin-dependency-to-exact-version.patch because it's + not needed anymore +- re-enable tests, re-add dependencies + * don't exclude test_util.py + * exclude proxy timeout tests that fail for spurious reasons +- urllib3-ssl-default-context.patch - use set_default_verify_paths() + if no certificate path specified and verification not explicitly + disabled +- urllib3-test-ssl-drop-sslv3.patch - don't use "SSLv3" constants + as they are not supported in openssl (and conversely python) anymore +- ready-event.patch - fix race conditions in timeout tests + ------------------------------------------------------------------- Wed Oct 14 09:35:30 UTC 2015 - toddrme2178@gmail.com diff --git a/python-urllib3.spec b/python-urllib3.spec index 81ce000..8286513 100644 --- a/python-urllib3.spec +++ b/python-urllib3.spec @@ -24,12 +24,22 @@ License: MIT Group: Development/Languages/Python Url: http://urllib3.readthedocs.org/ Source: https://pypi.python.org/packages/source/u/urllib3/urllib3-%{version}.tar.gz -# PATCH-FIX-UPSTREAM speilicke@suse.com -- https://github.com/shazow/urllib3/pull/361 -Patch0: 0001-Don-t-pin-dependency-to-exact-version.patch # PATCH-FIX-OPENSUSE speilicke@suse.com -- We need no coverage report Patch1: urllib3-test-no-coverage.patch +# PATCH-FEATURE-UPSTREAM -- use set_default_verify_paths() if no certificate path is supplied +Patch2: urllib3-ssl-default-context.patch +# PATCH-FIX-OPENSUSE -- do not use unsupported SSLv3 in tests +Patch3: urllib3-test-ssl-drop-sslv3.patch +# PATCH-FIX-UPSTREAM -- fix race conditions with ready_event state variable in timeout tests +Patch4: ready-event.patch BuildRequires: python-devel -Requires: python-certifi +BuildRequires: python-mock >= 1.3.0 +BuildRequires: python-nose >= 1.3.7 +BuildRequires: python-nose-exclude >= 0.4.1 +BuildRequires: python-tornado >= 4.2.1 +BuildRequires: python-tox >= 2.1.1 +BuildRequires: python-twine >= 1.5.0 +BuildRequires: python-wheel >= 0.24.0 Requires: python-pyOpenSSL Requires: python-pyasn1 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -57,8 +67,10 @@ Highlights %prep %setup -q -n urllib3-%{version} -%patch0 -p1 %patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 %build python setup.py build @@ -66,6 +78,12 @@ python setup.py build %install python setup.py install --prefix=%{_prefix} --root=%{buildroot} +%check +rm -rf build +PYTHONPATH="%{buildroot}%{python_sitelib}" nosetests \ + --exclude-test=test.with_dummyserver.test_proxy_poolmanager.TestHTTPProxyManager.test_https_proxy_timeout \ + --exclude-test=test.with_dummyserver.test_proxy_poolmanager.TestHTTPProxyManager.test_https_proxy_pool_timeout + %pre # previous versions of the package installed .egg-info as a directory, # the new update now installs it as a file. Clean out the directory, should it exist. diff --git a/ready-event.patch b/ready-event.patch new file mode 100644 index 0000000..474523a --- /dev/null +++ b/ready-event.patch @@ -0,0 +1,106 @@ +Index: urllib3-1.12/dummyserver/testcase.py +=================================================================== +--- urllib3-1.12.orig/dummyserver/testcase.py ++++ urllib3-1.12/dummyserver/testcase.py +@@ -45,7 +45,7 @@ class SocketDummyServerTestCase(unittest + def socket_handler(listener): + for _ in range(num): + ready_event.set() +- ready_event.clear() ++ #ready_event.clear() + + sock = listener.accept()[0] + consume_socket(sock) +@@ -59,6 +59,11 @@ class SocketDummyServerTestCase(unittest + return ready_event + + @classmethod ++ def wait_for_socket(cls, ready_event): ++ ready_event.wait() ++ ready_event.clear() ++ ++ @classmethod + def start_basic_handler(cls, **kw): + return cls.start_response_handler( + b'HTTP/1.1 200 OK\r\n' +Index: urllib3-1.12/test/with_dummyserver/test_connectionpool.py +=================================================================== +--- urllib3-1.12.orig/test/with_dummyserver/test_connectionpool.py ++++ urllib3-1.12/test/with_dummyserver/test_connectionpool.py +@@ -57,11 +57,12 @@ class TestConnectionPoolTimeouts(SocketD + + # Pool-global timeout + pool = HTTPConnectionPool(self.host, self.port, timeout=SHORT_TIMEOUT, retries=False) ++ self.wait_for_socket(ready_event) + self.assertRaises(ReadTimeoutError, pool.request, 'GET', '/') + block_event.set() # Release block + + # Shouldn't raise this time +- ready_event.wait() ++ self.wait_for_socket(ready_event) + block_event.set() # Pre-release block + pool.request('GET', '/') + +@@ -92,12 +93,13 @@ class TestConnectionPoolTimeouts(SocketD + timeout = Timeout(read=SHORT_TIMEOUT) + pool = HTTPConnectionPool(self.host, self.port, timeout=timeout, retries=False) + ++ self.wait_for_socket(ready_event) + conn = pool._get_conn() + self.assertRaises(ReadTimeoutError, pool._make_request, conn, 'GET', '/') + pool._put_conn(conn) + block_event.set() # Release request + +- ready_event.wait() ++ self.wait_for_socket(ready_event) + block_event.clear() + self.assertRaises(ReadTimeoutError, pool.request, 'GET', '/') + block_event.set() # Release request +@@ -106,7 +108,7 @@ class TestConnectionPoolTimeouts(SocketD + pool = HTTPConnectionPool(self.host, self.port, timeout=LONG_TIMEOUT, retries=False) + + conn = pool._get_conn() +- ready_event.wait() ++ self.wait_for_socket(ready_event) + now = time.time() + self.assertRaises(ReadTimeoutError, pool._make_request, conn, 'GET', '/', timeout=timeout) + delta = time.time() - now +@@ -115,7 +117,7 @@ class TestConnectionPoolTimeouts(SocketD + self.assertTrue(delta < LONG_TIMEOUT, "timeout was pool-level LONG_TIMEOUT rather than request-level SHORT_TIMEOUT") + pool._put_conn(conn) + +- ready_event.wait() ++ self.wait_for_socket(ready_event) + now = time.time() + self.assertRaises(ReadTimeoutError, pool.request, 'GET', '/', timeout=timeout) + delta = time.time() - now +@@ -125,11 +127,11 @@ class TestConnectionPoolTimeouts(SocketD + + # Timeout int/float passed directly to request and _make_request should + # raise a request timeout +- ready_event.wait() ++ self.wait_for_socket(ready_event) + self.assertRaises(ReadTimeoutError, pool.request, 'GET', '/', timeout=SHORT_TIMEOUT) + block_event.set() # Release request + +- ready_event.wait() ++ self.wait_for_socket(ready_event) + conn = pool._new_conn() + # FIXME: This assert flakes sometimes. Not sure why. + self.assertRaises(ReadTimeoutError, pool._make_request, conn, 'GET', '/', timeout=SHORT_TIMEOUT) +@@ -183,13 +185,14 @@ class TestConnectionPoolTimeouts(SocketD + block_event = Event() + ready_event = self.start_basic_handler(block_send=block_event, num=2) + ++ self.wait_for_socket(ready_event) + # This will get the socket to raise an EAGAIN on the read + timeout = Timeout(connect=3, read=SHORT_TIMEOUT) + pool = HTTPConnectionPool(self.host, self.port, timeout=timeout, retries=False) + self.assertRaises(ReadTimeoutError, pool.request, 'GET', '/') + + block_event.set() +- ready_event.wait() ++ self.wait_for_socket(ready_event) + block_event.clear() + + # The connect should succeed and this should hit the read timeout diff --git a/urllib3-ssl-default-context.patch b/urllib3-ssl-default-context.patch new file mode 100644 index 0000000..2fe6718 --- /dev/null +++ b/urllib3-ssl-default-context.patch @@ -0,0 +1,13 @@ +Index: urllib3-1.12/urllib3/util/ssl_.py +=================================================================== +--- urllib3-1.12.orig/urllib3/util/ssl_.py ++++ urllib3-1.12/urllib3/util/ssl_.py +@@ -278,6 +278,8 @@ def ssl_wrap_socket(sock, keyfile=None, + if e.errno == errno.ENOENT: + raise SSLError(e) + raise ++ elif cert_reqs != ssl.CERT_NONE: ++ context.set_default_verify_paths() + + if certfile: + context.load_cert_chain(certfile, keyfile) diff --git a/urllib3-test-ssl-drop-sslv3.patch b/urllib3-test-ssl-drop-sslv3.patch new file mode 100644 index 0000000..cb08018 --- /dev/null +++ b/urllib3-test-ssl-drop-sslv3.patch @@ -0,0 +1,31 @@ +Index: urllib3-1.12/test/with_dummyserver/test_https.py +=================================================================== +--- urllib3-1.12.orig/test/with_dummyserver/test_https.py ++++ urllib3-1.12/test/with_dummyserver/test_https.py +@@ -416,21 +416,21 @@ class TestHTTPS(HTTPSDummyServerTestCase + + class TestHTTPS_TLSv1(HTTPSDummyServerTestCase): + certs = DEFAULT_CERTS.copy() +- certs['ssl_version'] = ssl.PROTOCOL_TLSv1 ++ certs['ssl_version'] = ssl.PROTOCOL_TLSv1_2 + + def setUp(self): + self._pool = HTTPSConnectionPool(self.host, self.port) + +- def test_set_ssl_version_to_sslv3(self): +- self._pool.ssl_version = ssl.PROTOCOL_SSLv3 ++ def test_set_ssl_version_to_tlsv1(self): ++ self._pool.ssl_version = ssl.PROTOCOL_TLSv1 + self.assertRaises(SSLError, self._pool.request, 'GET', '/') + + def test_ssl_version_as_string(self): +- self._pool.ssl_version = 'PROTOCOL_SSLv3' ++ self._pool.ssl_version = 'PROTOCOL_TLSv1' + self.assertRaises(SSLError, self._pool.request, 'GET', '/') + + def test_ssl_version_as_short_string(self): +- self._pool.ssl_version = 'SSLv3' ++ self._pool.ssl_version = 'TLSv1' + self.assertRaises(SSLError, self._pool.request, 'GET', '/') + + def test_discards_connection_on_sslerror(self): From d12858beaae5e515455ec2aaa825e1125cf02ab99485e365eace7a3c47c4eb46 Mon Sep 17 00:00:00 2001 From: Jan Matejek Date: Wed, 18 Nov 2015 17:46:02 +0000 Subject: [PATCH 2/2] Accepting request 345090 from home:matejcik:urllib3tmp - re-enable tests, re-add relevant dependencies in python 2.7.9 and up - drop %pre section because apparently "egg-info as file" is no longer true and this breaks builds OBS-URL: https://build.opensuse.org/request/show/345090 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-urllib3?expand=0&rev=13 --- python-urllib3.changes | 7 +++++-- python-urllib3.spec | 14 +++++++------- urllib3-ssl-default-context.patch | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/python-urllib3.changes b/python-urllib3.changes index 6cd1456..5951c38 100644 --- a/python-urllib3.changes +++ b/python-urllib3.changes @@ -4,15 +4,18 @@ Wed Oct 27 16:33:44 UTC 2015 - jmatejek@suse.com - removed python-certifi dependency, we don't want to use it - drop 0001-Don-t-pin-dependency-to-exact-version.patch because it's not needed anymore -- re-enable tests, re-add dependencies +- re-enable tests, re-add relevant dependencies * don't exclude test_util.py * exclude proxy timeout tests that fail for spurious reasons - urllib3-ssl-default-context.patch - use set_default_verify_paths() if no certificate path specified and verification not explicitly disabled - urllib3-test-ssl-drop-sslv3.patch - don't use "SSLv3" constants - as they are not supported in openssl (and conversely python) anymore + in python 2.7.9 and up - ready-event.patch - fix race conditions in timeout tests +- drop %pre section because apparently "egg-info as file" is no longer + true and this breaks builds + ------------------------------------------------------------------- Wed Oct 14 09:35:30 UTC 2015 - toddrme2178@gmail.com diff --git a/python-urllib3.spec b/python-urllib3.spec index 8286513..dbfa34f 100644 --- a/python-urllib3.spec +++ b/python-urllib3.spec @@ -32,14 +32,12 @@ Patch2: urllib3-ssl-default-context.patch Patch3: urllib3-test-ssl-drop-sslv3.patch # PATCH-FIX-UPSTREAM -- fix race conditions with ready_event state variable in timeout tests Patch4: ready-event.patch +#!BuildIgnore: python-requests BuildRequires: python-devel BuildRequires: python-mock >= 1.3.0 BuildRequires: python-nose >= 1.3.7 BuildRequires: python-nose-exclude >= 0.4.1 BuildRequires: python-tornado >= 4.2.1 -BuildRequires: python-tox >= 2.1.1 -BuildRequires: python-twine >= 1.5.0 -BuildRequires: python-wheel >= 0.24.0 Requires: python-pyOpenSSL Requires: python-pyasn1 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -69,7 +67,9 @@ Highlights %setup -q -n urllib3-%{version} %patch1 -p1 %patch2 -p1 +%if %(python -c "import ssl; print(hasattr(ssl,'PROTOCOL_TLSv1_2'))") == "True" %patch3 -p1 +%endif %patch4 -p1 %build @@ -84,12 +84,12 @@ PYTHONPATH="%{buildroot}%{python_sitelib}" nosetests \ --exclude-test=test.with_dummyserver.test_proxy_poolmanager.TestHTTPProxyManager.test_https_proxy_timeout \ --exclude-test=test.with_dummyserver.test_proxy_poolmanager.TestHTTPProxyManager.test_https_proxy_pool_timeout -%pre +#%pre # previous versions of the package installed .egg-info as a directory, # the new update now installs it as a file. Clean out the directory, should it exist. -if [ -d %{python_sitelib}/urllib3-%{version}-py*.egg-info ]; then - rm -rf %{python_sitelib}/urllib3-%{version}-py*.egg-info -fi +#if [ -d %{python_sitelib}/urllib3-%{version}-py*.egg-info ]; then +# rm -rf %{python_sitelib}/urllib3-%{version}-py*.egg-info +#fi %files %defattr(-,root,root,-) diff --git a/urllib3-ssl-default-context.patch b/urllib3-ssl-default-context.patch index 2fe6718..0d4c63e 100644 --- a/urllib3-ssl-default-context.patch +++ b/urllib3-ssl-default-context.patch @@ -6,7 +6,7 @@ Index: urllib3-1.12/urllib3/util/ssl_.py if e.errno == errno.ENOENT: raise SSLError(e) raise -+ elif cert_reqs != ssl.CERT_NONE: ++ elif cert_reqs != ssl.CERT_NONE and hasattr(context, 'set_default_verify_paths'): + context.set_default_verify_paths() if certfile: