datasette/actor_auth_cookie.py coverae to 100%, refs #841

pull/844/head
Simon Willison 2020-06-13 11:29:14 -07:00
rodzic d60bd6ad13
commit 0e49842e22
1 zmienionych plików z 11 dodań i 0 usunięć

Wyświetl plik

@ -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),]
)