Skip to content

Commit

Permalink
Better test for Vary header
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jun 6, 2020
1 parent 3f83d46 commit 070838b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 0 additions & 2 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ async def post(
if csrftoken_from is True:
csrftoken_from = path
token_response = await self._request(csrftoken_from)
# Check this had a Vary: Cookie header
assert "Cookie" == token_response.headers["vary"]
csrftoken = token_response.cookies["ds_csrftoken"]
cookies["ds_csrftoken"] = csrftoken
post_data["csrftoken"] = csrftoken
Expand Down
6 changes: 6 additions & 0 deletions tests/test_canned_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ def test_custom_params(canned_write_client):
assert '<input type="text" id="qp3" name="extra" value="foo">' in response.text


def test_vary_header(canned_write_client):
# These forms embed a csrftoken so they should be served with Vary: Cookie
assert "vary" not in canned_write_client.get("/data").headers
assert "Cookie" == canned_write_client.get("/data/update_name").headers["vary"]


def test_canned_query_permissions_on_database_page(canned_write_client):
# Without auth only shows three queries
query_names = [
Expand Down

0 comments on commit 070838b

Please sign in to comment.