aboutsummaryrefslogtreecommitdiff
path: root/tests/test_http.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_http.py')
-rw-r--r--tests/test_http.py49
1 files changed, 5 insertions, 44 deletions
diff --git a/tests/test_http.py b/tests/test_http.py
index 9bd9ee0..97b52dc 100644
--- a/tests/test_http.py
+++ b/tests/test_http.py
@@ -10,12 +10,8 @@ import os
import pytest
from six.moves import http_client, urllib
import socket
-import ssl
import tests
-DUMMY_URL = "http://127.0.0.1:1"
-DUMMY_HTTPS_URL = "https://127.0.0.1:2"
-
def _raise_connection_refused_exception(*args, **kwargs):
raise socket.error(errno.ECONNREFUSED, "Connection refused.")
@@ -25,9 +21,9 @@ def test_connection_type():
http = httplib2.Http()
http.force_exception_to_status_code = False
response, content = http.request(
- DUMMY_URL, connection_type=tests.MockHTTPConnection
+ tests.DUMMY_URL, connection_type=tests.MockHTTPConnection
)
- assert response["content-location"] == DUMMY_URL
+ assert response["content-location"] == tests.DUMMY_URL
assert content == b"the body"
@@ -38,7 +34,7 @@ def test_bad_status_line_retry():
http.force_exception_to_status_code = False
try:
response, content = http.request(
- DUMMY_URL, connection_type=tests.MockHTTPBadStatusConnection
+ tests.DUMMY_URL, connection_type=tests.MockHTTPBadStatusConnection
)
except http_client.BadStatusLine:
assert tests.MockHTTPBadStatusConnection.num_calls == 2
@@ -71,7 +67,7 @@ def test_connection_refused_raises_exception(mock_socket_connect):
http = httplib2.Http()
http.force_exception_to_status_code = False
with tests.assert_raises(socket.error):
- http.request(DUMMY_URL)
+ http.request(tests.DUMMY_URL)
@pytest.mark.skipif(
@@ -84,7 +80,7 @@ def test_connection_refused_returns_response(mock_socket_connect):
mock_socket_connect.side_effect = _raise_connection_refused_exception
http = httplib2.Http()
http.force_exception_to_status_code = True
- response, content = http.request(DUMMY_URL)
+ response, content = http.request(tests.DUMMY_URL)
content = content.lower()
assert response["content-type"] == "text/plain"
assert (
@@ -647,38 +643,3 @@ content"""
assert response.status == 200
assert content == b"content"
assert response["link"], "link1, link2"
-
-
-@pytest.mark.skipif(
- os.environ.get("TRAVIS_PYTHON_VERSION") in ("2.7", "pypy"),
- reason="Python 2.7 doesn't support TLS min/max"
-)
-def test_set_min_tls_version():
- # Test setting minimum TLS version
- # We expect failure on Python < 3.7 or OpenSSL < 1.1
- expect_success = hasattr(ssl.SSLContext(), 'minimum_version')
- try:
- http = httplib2.Http(tls_minimum_version="TLSv1_2")
- http.request(DUMMY_HTTPS_URL)
- except RuntimeError:
- assert not expect_success
- except socket.error:
- assert expect_success
-
-
-@pytest.mark.skipif(
- os.environ.get("TRAVIS_PYTHON_VERSION") in ("2.7", "pypy"),
- reason="Python 2.7 doesn't support TLS min/max"
-)
-def test_set_max_tls_version():
- # Test setting maximum TLS version
- # We expect RuntimeError on Python < 3.7 or OpenSSL < 1.1
- # We expect socket error otherwise
- expect_success = hasattr(ssl.SSLContext(), 'maximum_version')
- try:
- http = httplib2.Http(tls_maximum_version="TLSv1_2")
- http.request(DUMMY_HTTPS_URL)
- except RuntimeError:
- assert not expect_success
- except socket.error:
- assert expect_success