Skip to content

Commit

Permalink
datasette/actor_auth_cookie.py coverae to 100%, refs #841
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jun 13, 2020
1 parent d60bd6a commit 0e49842
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ def test_actor_cookie(app_client):
assert {"id": "test"} == app_client.ds._last_request.scope["actor"]


def test_actor_cookie_invalid(app_client):
cookie = app_client.actor_cookie({"id": "test"})
# Break the signature
response = app_client.get("/", cookies={"ds_actor": cookie[:-1] + "."})
assert None == app_client.ds._last_request.scope["actor"]
# Break the cookie format
cookie = app_client.ds.sign({"b": {"id": "test"}}, "actor")
response = app_client.get("/", cookies={"ds_actor": cookie})
assert None == app_client.ds._last_request.scope["actor"]


@pytest.mark.parametrize(
"offset,expected", [((24 * 60 * 60), {"id": "test"}), (-(24 * 60 * 60), None),]
)
Expand Down

0 comments on commit 0e49842

Please sign in to comment.