Skip to content

Commit

Permalink
Add tests for parsing chunked data split before or in the final CRLF
Browse files Browse the repository at this point in the history
PR #4651 by @JustAnotherArchivist

This change adds tests that demonstrate the failures described in #4630.
They are marked as xfail so that they don't affect the CI status.
Once the issue is fixed, they'll reported as XPASS and pytest will fail,
which would be a signal that it's time to remove the xfail markers
keeping the contents of the tests to prevent regressions.

(ref: https://pganssle-talks.github.io/xfail-lightning)


Co-Authored-By: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
  • Loading branch information
2 people authored and asvetlov committed Oct 16, 2020
1 parent 11f13ff commit 3d2a7c4
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/test_http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,55 @@ async def test_parse_chunked_payload_size_error(self, stream) -> None:
assert isinstance(out.exception(),
http_exceptions.TransferEncodingError)

@pytest.mark.xfail(
reason="see https://github.com/aio-libs/aiohttp/issues/4630"
)
async def test_parse_chunked_payload_split_end(self, protocol) -> None:
out = aiohttp.StreamReader(protocol, loop=None)
p = HttpPayloadParser(out, chunked=True)
p.feed_data(b'4\r\nasdf\r\n0\r\n')
p.feed_data(b'\r\n')

assert out.is_eof()
assert b'asdf' == b''.join(out._buffer)

@pytest.mark.xfail(
reason="see https://github.com/aio-libs/aiohttp/issues/4630"
)
async def test_parse_chunked_payload_split_end2(self, protocol) -> None:
out = aiohttp.StreamReader(protocol, loop=None)
p = HttpPayloadParser(out, chunked=True)
p.feed_data(b'4\r\nasdf\r\n0\r\n\r')
p.feed_data(b'\n')

assert out.is_eof()
assert b'asdf' == b''.join(out._buffer)

async def test_parse_chunked_payload_split_end_trailers(self,
protocol) -> None:
out = aiohttp.StreamReader(protocol, loop=None)
p = HttpPayloadParser(out, chunked=True)
p.feed_data(b'4\r\nasdf\r\n0\r\n')
p.feed_data(b'Content-MD5: 912ec803b2ce49e4a541068d495ab570\r\n')
p.feed_data(b'\r\n')

assert out.is_eof()
assert b'asdf' == b''.join(out._buffer)

@pytest.mark.xfail(
reason="see https://github.com/aio-libs/aiohttp/issues/4630"
)
async def test_parse_chunked_payload_split_end_trailers2(self,
protocol) -> None:
out = aiohttp.StreamReader(protocol, loop=None)
p = HttpPayloadParser(out, chunked=True)
p.feed_data(b'4\r\nasdf\r\n0\r\n')
p.feed_data(b'Content-MD5: 912ec803b2ce49e4a541068d495ab570\r\n\r')
p.feed_data(b'\n')

assert out.is_eof()
assert b'asdf' == b''.join(out._buffer)

async def test_http_payload_parser_length(self, stream) -> None:
out = aiohttp.FlowControlDataQueue(stream,
loop=asyncio.get_event_loop())
Expand Down

0 comments on commit 3d2a7c4

Please sign in to comment.