2023-09-03 15:43:24 +02:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2024-05-20 12:10:17 +02:00
|
|
|
@pytest.mark.anyio
|
|
|
|
async def test_user_creation(unauthorized_client, user_payload_factory):
|
|
|
|
response = await unauthorized_client.post("user", json=user_payload_factory())
|
2023-09-03 15:43:24 +02:00
|
|
|
assert response.status_code == 200, response.json()
|
|
|
|
|
|
|
|
|
2024-05-20 12:10:17 +02:00
|
|
|
@pytest.mark.anyio
|
|
|
|
async def test_user_login(client, user_payload):
|
|
|
|
response = await client.post("token", data=user_payload)
|
2023-09-03 15:43:24 +02:00
|
|
|
assert response.status_code == 200, response.json()
|
|
|
|
|
|
|
|
data = response.json()
|
|
|
|
assert data["access_token"] is not None
|
|
|
|
assert data["refresh_token"] is not None
|
|
|
|
|
|
|
|
|
2024-05-20 12:10:17 +02:00
|
|
|
@pytest.mark.anyio
|
|
|
|
async def test_user_refresh_token(client, user_payload):
|
|
|
|
response = await client.post("token", data=user_payload)
|
2023-09-03 15:43:24 +02:00
|
|
|
assert response.status_code == 200, response.json()
|
|
|
|
|
|
|
|
token = response.json()["refresh_token"]
|
|
|
|
payload = {"refresh_token": token}
|
|
|
|
|
2024-05-20 12:10:17 +02:00
|
|
|
response = await client.post("token/refresh", json=payload)
|
2023-09-03 15:43:24 +02:00
|
|
|
assert response.status_code == 200, response.json()
|