add test fingerprint

This commit is contained in:
IluaAir
2025-09-27 11:52:55 +03:00
parent 4e47ce80fd
commit b87c37b149
2 changed files with 23 additions and 7 deletions

View File

@@ -27,7 +27,7 @@ async def login(
session: sessionDep,
credential: Annotated[OAuth2PasswordRequestForm, Depends()],
response: Response,
fingerprint: str = Form(),
fingerprint: str = Form(min_length=5),
):
result = await AuthService(session).login(
credential.username, credential.password, fingerprint=fingerprint

View File

@@ -1,5 +1,5 @@
from httpx import AsyncClient
import pytest
from src.core.settings import settings
from src.schemas.users import User
@@ -15,14 +15,30 @@ async def test_registration(ac):
assert result.json()["is_active"]
async def test_login(ac: AsyncClient):
@pytest.mark.parametrize(
"fingerprint, username,password,expected_status",
[("string", "kot", "P@ssw0rd", 200), ("", "kot", "P@ssw0rd", 422)],
)
async def test_login(
ac: AsyncClient,
fingerprint: str,
username: str,
password: str,
expected_status: int,
):
result = await ac.post(
f"{settings.api.v1_login_url}/login",
data={
"fingerprint": fingerprint,
"grant_type": "password",
"username": "kot",
"password": "P@ssw0rd",
"username": username,
"password": password,
},
)
assert result.status_code == 200
assert result.json().get("access_token")
assert result.status_code == expected_status
if expected_status == 200:
assert result.json().get("access_token") is not None
else:
json_response = result.json()
if expected_status == 422:
assert "detail" in json_response