Commit 9ce8f4dc authored by Julien Puydt's avatar Julien Puydt

New upstream version 6.5.6+ds

parent 28b91396
......@@ -30,7 +30,7 @@ test_script:
version: '{build}'
after_test:
on_finish:
- ps: |
$wc = New-Object 'System.Net.WebClient'
$wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\junit-test-results.xml))
......
ref-names: tag: v6.5.5
ref-names: HEAD -> master, tag: v6.5.6
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html
# for details
# Required
version: 2
# Build documentation in the docs/ directory with Sphinx
sphinx:
builder: html
configuration: docs/conf.py
fail_on_warning: false # true
# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml
# fail_on_warning: true
# Optionally build your docs in additional formats
# such as PDF and ePub
formats: []
submodules:
include: all # []
exclude: []
recursive: true
build:
image: latest
# Optionally set the version of Python and requirements required
# to build docs
python:
version: 3.6
version: 3.7
install:
- method: pip
path: .
extra_requirements:
- docs
pip_install: true
system_packages: false
......@@ -8,8 +8,7 @@ python:
- 3.4
- 3.5
- 3.6
- &pypy2 pypy2.7-6.0
- &pypy3 pypy3.5-6.0
- &pypy3 pypy3
_base_envs:
- &stage_lint
......@@ -27,9 +26,9 @@ _base_envs:
- &pyenv_base
<<: *stage_test
language: generic
python: *pypy2
python: &pypy2 pypy
env:
- &env_pypy2 PYTHON_VERSION=pypy2.7-5.10.0
- &env_pypy2 PYTHON_VERSION=pypy2.7-7.1.0
- &env_pyenv PYENV_ROOT="$HOME/.pyenv"
- &env_path PATH="$PYENV_ROOT/bin:$PATH"
before_install:
......@@ -86,6 +85,10 @@ jobs:
allow_failures:
- env: TOXENV=pre-commit-failing
include:
- python: *pypy2
env:
PYTEST_ADDOPTS: >-
'-p no:warnings'
- <<: *lint_python_base
name: pre-commit.com tool linters
env: TOXENV=pre-commit
......@@ -143,9 +146,9 @@ jobs:
- <<: *osx_python_base
<<: *manual_run_or_cron
osx_image: xcode9.4
python: pypy3.5-5.10.1
python: pypy3.6-7.1.0
env:
- PYTHON_VERSION=pypy3.5-5.10.1
- PYTHON_VERSION=pypy3.6-7.1.0
- *env_pyenv
- *env_path
# pypy2.7-5.10.0 fails under OS X because it's unsupported
......
v6.5.6
======
- :issue:`218` via :pr:`219`: Fix HTTP parser to return 400 on
invalid major-only HTTP version in Request-Line.
v6.5.5
======
- :issue:`99` via :pr:`186': Sockets now collect statistics (bytes
- :issue:`99` via :pr:`186`: Sockets now collect statistics (bytes
read and written) on Python 3 same as Python 2.
- :cp-issue:`1618` via :pr:`180`: Ignore OpenSSL's 1.1+ Error 0
......
......@@ -788,6 +788,11 @@ class HTTPRequest:
)
return False
rp = req_protocol[5:].split(b'.', 1)
if len(rp) != 2:
self.simple_response(
'400 Bad Request', 'Malformed Request-Line: bad version',
)
return False
rp = tuple(map(int, rp)) # Minor.Major must be threat as integers
if rp > (1, 1):
self.simple_response(
......@@ -1226,7 +1231,7 @@ class HTTPConnection:
Args:
server (HTTPServer): web server object receiving this request
socket (socket._socketobject): the raw socket object (usually
sock (socket._socketobject): the raw socket object (usually
TCP) for this connection
makefile (file): a fileobject class for reading from the socket
"""
......
......@@ -19,14 +19,14 @@ from ..testing import ( # noqa: F401
from ..testing import get_server_client
@pytest.fixture # noqa: F811
def wsgi_server_client(wsgi_server):
@pytest.fixture
def wsgi_server_client(wsgi_server): # noqa: F811
"""Create a test client out of given WSGI server."""
return get_server_client(wsgi_server)
@pytest.fixture # noqa: F811
def native_server_client(native_server):
@pytest.fixture
def native_server_client(native_server): # noqa: F811
"""Create a test client out of given HTTP server."""
return get_server_client(native_server)
......
......@@ -160,7 +160,7 @@ def test_parse_uri_unsafe_uri(test_client):
response = _get_http_response(c, method='GET')
response.begin()
assert response.status == HTTP_OK
assert response.fp.read(12) == b'Hello world!'
assert response.read(12) == b'Hello world!'
c.close()
......@@ -175,7 +175,7 @@ def test_parse_uri_invalid_uri(test_client):
response = _get_http_response(c, method='GET')
response.begin()
assert response.status == HTTP_BAD_REQUEST
assert response.fp.read(21) == b'Malformed Request-URI'
assert response.read(21) == b'Malformed Request-URI'
c.close()
......@@ -241,7 +241,7 @@ def test_no_content_length(test_client):
c = test_client.get_connection()
c.request('POST', '/no_body')
response = c.getresponse()
actual_resp_body = response.fp.read()
actual_resp_body = response.read()
actual_status = response.status
assert actual_status == HTTP_OK
assert actual_resp_body == b'Hello world!'
......@@ -256,7 +256,7 @@ def test_content_length_required(test_client):
c = test_client.get_connection()
c.request('POST', '/body_required')
response = c.getresponse()
response.fp.read()
response.read()
actual_status = response.status
assert actual_status == HTTP_LENGTH_REQUIRED
......@@ -273,6 +273,10 @@ def test_content_length_required(test_client):
b'GET / HTTPS/1.1', # invalid proto
HTTP_BAD_REQUEST, b'Malformed Request-Line: bad protocol',
),
(
b'GET / HTTP/1', # invalid version
HTTP_BAD_REQUEST, b'Malformed Request-Line: bad version',
),
(
b'GET / HTTP/2.15', # invalid ver
HTTP_VERSION_NOT_SUPPORTED, b'Cannot fulfill request',
......@@ -290,7 +294,7 @@ def test_malformed_request_line(
response = _get_http_response(c, method='GET')
response.begin()
assert response.status == status_code
assert response.fp.read(len(expected_body)) == expected_body
assert response.read(len(expected_body)) == expected_body
c.close()
......@@ -304,7 +308,7 @@ def test_malformed_http_method(test_client):
response = c.getresponse()
actual_status = response.status
assert actual_status == HTTP_BAD_REQUEST
actual_resp_body = response.fp.read(21)
actual_resp_body = response.read(21)
assert actual_resp_body == b'Malformed method name'
......@@ -320,7 +324,7 @@ def test_malformed_header(test_client):
response = c.getresponse()
actual_status = response.status
assert actual_status == HTTP_BAD_REQUEST
actual_resp_body = response.fp.read(20)
actual_resp_body = response.read(20)
assert actual_resp_body == b'Illegal header line.'
......@@ -353,7 +357,7 @@ def test_garbage_in(test_client):
response.begin()
actual_status = response.status
assert actual_status == HTTP_BAD_REQUEST
actual_resp_body = response.fp.read(22)
actual_resp_body = response.read(22)
assert actual_resp_body == b'Malformed Request-Line'
c.close()
except socket.error as ex:
......
......@@ -37,6 +37,7 @@ IS_PYOPENSSL_SSL_VERSION_1_0 = (
startswith(b'OpenSSL 1.0.')
)
PY27 = sys.version_info[:2] == (2, 7)
PY34 = sys.version_info[:2] == (3, 4)
_stdlib_to_openssl_verify = {
......@@ -304,7 +305,7 @@ def test_tls_client_auth(
and tls_verify_mode == ssl.CERT_REQUIRED
and tls_client_identity == 'localhost'
and is_trusted_cert
):
) or PY34:
pytest.xfail(
'OpenSSL 1.0 has problems with verifying client certs',
)
......@@ -312,18 +313,56 @@ def test_tls_client_auth(
assert resp.text == 'Hello world!'
return
with pytest.raises(requests.exceptions.SSLError) as ssl_err:
expected_ssl_errors = (
requests.exceptions.SSLError,
OpenSSL.SSL.Error,
) if PY34 else (
requests.exceptions.SSLError,
)
if IS_WINDOWS:
expected_ssl_errors += requests.exceptions.ConnectionError,
with pytest.raises(expected_ssl_errors) as ssl_err:
make_https_request()
if PY34 and isinstance(ssl_err, OpenSSL.SSL.Error):
pytest.xfail(
'OpenSSL behaves wierdly under Python 3.4 '
'because of an outdated urllib3',
)
try:
err_text = ssl_err.value.args[0].reason.args[0].args[0]
except AttributeError:
if PY34:
pytest.xfail('OpenSSL behaves wierdly under Python 3.4')
elif six.PY3 and IS_WINDOWS:
err_text = str(ssl_err.value)
else:
raise
expected_substring = (
expected_substrings = (
'sslv3 alert bad certificate' if IS_LIBRESSL_BACKEND
else 'tlsv1 alert unknown ca'
else 'tlsv1 alert unknown ca',
)
if six.PY3:
if IS_MACOS and IS_PYPY and adapter_type == 'pyopenssl':
expected_substrings = ('tlsv1 alert unknown ca', )
if (
IS_WINDOWS
and tls_verify_mode in (
ssl.CERT_REQUIRED,
ssl.CERT_OPTIONAL,
)
and not is_trusted_cert
and tls_client_identity == 'localhost'
):
expected_substrings += (
'bad handshake: '
"SysCallError(10054, 'WSAECONNRESET')",
"('Connection aborted.', "
'OSError("(10054, \'WSAECONNRESET\')"))',
)
if IS_PYPY and six.PY3 and IS_MACOS and adapter_type == 'pyopenssl':
expected_substring = 'tlsv1 alert unknown ca'
assert expected_substring in err_text
assert any(e in err_text for e in expected_substrings)
@pytest.mark.parametrize(
......
......@@ -50,6 +50,8 @@ def cheroot_server(server_factory):
else:
break
httpserver.shutdown_timeout = 0 # Speed-up tests teardown
threading.Thread(target=httpserver.safe_start).start() # spawn it
while not httpserver.ready: # wait until fully initialized and bound
time.sleep(0.1)
......
......@@ -209,7 +209,7 @@ class ThreadPool:
# Grow/shrink the pool if necessary.
# Remove any dead threads from our list
for t in self._threads:
if not t.isAlive():
if not t.is_alive():
self._threads.remove(t)
amount -= 1
......@@ -242,7 +242,7 @@ class ThreadPool:
endtime = time.time() + timeout
while self._threads:
worker = self._threads.pop()
if worker is not current and worker.isAlive():
if worker is not current and worker.is_alive():
try:
if timeout is None or timeout < 0:
worker.join()
......@@ -250,7 +250,7 @@ class ThreadPool:
remaining_time = endtime - time.time()
if remaining_time > 0:
worker.join(remaining_time)
if worker.isAlive():
if worker.is_alive():
# We exhausted the timeout.
# Forcibly shut down the socket.
c = worker.conn
......
[pytest]
norecursedirs = dist docs build .tox .eggs
addopts = -v -rxXs --testmon --doctest-modules --ignore cheroot/ssl/pyopenssl.py --junitxml=junit-test-results.xml --cov=cheroot --cov-report term-missing:skip-covered --cov-report xml
addopts = --durations=10 -v -rxXs -l -n auto --testmon --doctest-modules --ignore cheroot/ssl/pyopenssl.py --junitxml=junit-test-results.xml --cov=cheroot --cov-report term-missing:skip-covered --cov-report xml
filterwarnings =
error
doctest_optionflags = ALLOW_UNICODE ELLIPSIS
junit_duration_report = call
junit_suite_name = cheroot_test_suite
testpaths = cheroot/test/
......@@ -86,14 +86,14 @@ testing =
pytest-sugar>=0.9.1
pytest-testmon>=0.9.7
pytest-watch==4.2.0
pytest-xdist==1.28.0
pytest-xdist>=1.28.0
# measure test coverage
coverage==4.5.3
# send test coverage to codecov.io
codecov==2.0.15
pytest-cov==2.6.1
pytest-cov==2.7.1
# TLS
trustme>=0.4.0
......@@ -103,8 +103,13 @@ testing =
requests-unixsocket
# This addresses https://github.com/cherrypy/cheroot/issues/173.
# It's a transitive dependency of requests library:
urllib3>=1.25
# It's a transitive dependency of requests library.
# Also: requests>=2.22.0 doesn't support Python 3.4
# yet requests==2.21.0 doesn't support urllib3>=1.25
# Allowing requests with a lower urllib3 version
# so that tests'd pass
urllib3>=1.25; python_version != "3.4"
urllib3<1.25; python_version == "3.4" # pyup: < 1.25
[options.entry_points]
console_scripts =
......
[tox]
envlist = python
minversion = 3.5.3
minversion = 3.11.1
requires =
pip >= 9
[testenv]
deps =
pip >= 9
setuptools>=31.0.1
whitelist_externals =
rm
......@@ -27,17 +30,29 @@ passenv =
CIRCLECI
CIRCLE_*
PYTHONDONTWRITEBYTECODE
PYTEST_*
setenv =
PYTHONDONTWRITEBYTECODE=x
WEBTEST_INTERACTIVE=false
[testenv:build-docs]
basepython = python3.7
description = Build The Docs
changedir = docs
#-a -n -W \
commands =
python -m sphinx \
-b html --color \
-d "{toxworkdir}/docs_doctree" \
. "{toxworkdir}/docs_out"
# Print out the output docs dir and a way to serve html:
python -c \
'import pathlib; '\
'docs_dir = pathlib.Path(r"{toxworkdir}") / "docs_out"; index_file = docs_dir / "index.html"; print(f"\nDocumentation available under `file://\{index_file\}`\n\nTo serve docs, use `python3 -m http.server --directory \{docs_dir\} 0`\n")'
extras =
docs
testing
changedir = docs
commands =
python -m sphinx . {toxinidir}/build/html
[testenv:watch]
commands = ptw --runner=pytest
......@@ -55,10 +70,12 @@ commands = pre-commit run --config .pre-commit-config.yaml.failing --all-files {
[testenv:setup-check]
deps =
setuptools-scm
twine
extras =
docs
usedevelop = False
commands =
python -m setup checkdocs check --metadata --restructuredtext --strict --verbose
twine check .tox/dist/*
python -m twine check .tox/dist/*
python -m setuptools_scm ls
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment