Skip to content

Commit

Permalink
Non-ASCII ETag tests
Browse files Browse the repository at this point in the history
  • Loading branch information
greshilov committed Dec 9, 2020
1 parent 74158a9 commit c4b70ef
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions tests/test_web_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,10 @@ async def invalid_handler_1(request):
ETag(is_weak=False, value="also-valid-tag"),
),
),
pytest.param(
'"ascii", "это точно не ascii", "ascii again"',
(ETag(is_weak=False, value="ascii"),),
),
pytest.param(
"*",
(ETag(is_weak=False, value="*"),),
Expand Down
25 changes: 22 additions & 3 deletions tests/test_web_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,31 @@ def test_etag_any() -> None:


@pytest.mark.parametrize(
"invalid", ('"invalid"', ETag(value='"invalid"', is_weak=True))
"invalid_value",
(
'"invalid"',
"повинен бути ascii",
ETag(value='"invalid"', is_weak=True),
ETag(value="bad ©®"),
),
)
def test_etag_invalid_value(invalid) -> None:
def test_etag_invalid_value_set(invalid_value) -> None:
resp = StreamResponse()
with pytest.raises(ValueError):
resp.etag = invalid
resp.etag = invalid_value


@pytest.mark.parametrize(
"header",
(
"forgotten quotes",
'"∀ x ∉ ascii"',
),
)
def test_etag_invalid_value_get(header) -> None:
resp = StreamResponse()
resp.headers["ETag"] = header
assert resp.etag is None


@pytest.mark.parametrize("invalid", (123, ETag(value=123, is_weak=True)))
Expand Down

0 comments on commit c4b70ef

Please sign in to comment.