add test fingerprint
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user