Skip to content

Commit

Permalink
Add regression test for #5621 (#5635)
Browse files Browse the repository at this point in the history
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
  • Loading branch information
thehesiod and webknjaz committed Apr 20, 2021
1 parent a726db1 commit 09ac1cb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/5635.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added regression tests for dispatching urlencoded routes.
33 changes: 33 additions & 0 deletions tests/test_web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from unittest.mock import MagicMock

import pytest
import yarl

from aiohttp import web
from aiohttp.web_urldispatcher import SystemRoute
Expand Down Expand Up @@ -458,3 +459,35 @@ async def test_static_absolute_url(aiohttp_client: Any, tmp_path: Any) -> None:
client = await aiohttp_client(app)
resp = await client.get("/static/" + str(file_path.resolve()))
assert resp.status == 403


@pytest.mark.xfail(
raises=AssertionError,
reason="Regression in v3.7: https://github.com/aio-libs/aiohttp/issues/5621",
)
@pytest.mark.parametrize(
("route_definition", "urlencoded_path", "expected_http_resp_status"),
(
("/467,802,24834/hello", "/467%2C802%2C24834/hello", 200),
("/{user_ids:([0-9]+)(,([0-9]+))*}/hello", "/467%2C802%2C24834/hello", 200),
("/1%2C3/hello", "/1%2C3/hello", 404),
),
ids=("urldecoded_route", "urldecoded_route_with_regex", "urlencoded_route"),
)
async def test_decoded_url_match(
aiohttp_client,
route_definition,
urlencoded_path,
expected_http_resp_status,
) -> None:
app = web.Application()

async def handler(_):
return web.Response()

app.router.add_get(route_definition, handler)
client = await aiohttp_client(app)

r = await client.get(yarl.URL(urlencoded_path, encoded=True))
assert r.status == expected_http_resp_status
await r.release()

0 comments on commit 09ac1cb

Please sign in to comment.