test: update all tests to include CSRF tokens
This commit is contained in:
parent
9e5773f52f
commit
f648422227
12 changed files with 105 additions and 26 deletions
|
|
@ -6,6 +6,7 @@ from urllib.parse import parse_qs, urlparse
|
|||
from argon2 import PasswordHasher
|
||||
from httpx import AsyncClient
|
||||
|
||||
from tests.conftest import get_csrf_token
|
||||
from porchlight.authn.password import PasswordService
|
||||
from porchlight.models import PasswordCredential, User
|
||||
|
||||
|
|
@ -47,10 +48,11 @@ async def _create_user_and_login(client: AsyncClient) -> str:
|
|||
svc = PasswordService(hasher=PasswordHasher(time_cost=1, memory_cost=8192))
|
||||
await cred_repo.create_password(PasswordCredential(user_id=user.userid, password_hash=svc.hash("testpass")))
|
||||
|
||||
token = await get_csrf_token(client)
|
||||
await client.post(
|
||||
"/login/password",
|
||||
data={"username": "alice", "password": "testpass"},
|
||||
headers={"HX-Request": "true"},
|
||||
headers={"HX-Request": "true", "X-CSRF-Token": token},
|
||||
)
|
||||
return user.userid
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue