mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Custom error on CSRF failures, closes #2390
Uses https://github.com/simonw/asgi-csrf/issues/28
This commit is contained in:
parent
93067668fe
commit
06d4ffb92e
3 changed files with 27 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from asgi_csrf import Errors
|
||||
from bs4 import BeautifulSoup as Soup
|
||||
from datasette.app import Datasette
|
||||
from datasette.utils import allowed_pragmas
|
||||
|
|
@ -1158,3 +1159,16 @@ async def test_database_color(ds_client):
|
|||
|
||||
pdb.set_trace()
|
||||
assert any(fragment in response.text for fragment in expected_fragments)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_custom_csrf_error(ds_client):
|
||||
response = await ds_client.post(
|
||||
"/-/messages",
|
||||
data={
|
||||
"message": "A message",
|
||||
},
|
||||
cookies={"csrftoken": "x"},
|
||||
)
|
||||
assert response.status_code == 403
|
||||
assert "Error code is FORM_URLENCODED_MISMATCH." in response.text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue