mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2026-03-13 07:49:55 +08:00
32 lines
937 B
Python
32 lines
937 B
Python
import pytest
|
|
|
|
from fastapi_users.models import UserLogin
|
|
|
|
|
|
class TestAuthenticate:
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_unknown_user(self, mock_db_interface):
|
|
user = await mock_db_interface.authenticate(UserLogin(
|
|
email='lancelot@camelot.bt',
|
|
password='guinevere',
|
|
))
|
|
assert user is None
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_wrong_password(self, mock_db_interface):
|
|
user = await mock_db_interface.authenticate(UserLogin(
|
|
email='king.arthur@camelot.bt',
|
|
password='percival',
|
|
))
|
|
assert user is None
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_valid_credentials(self, mock_db_interface):
|
|
user = await mock_db_interface.authenticate(UserLogin(
|
|
email='king.arthur@camelot.bt',
|
|
password='guinevere',
|
|
))
|
|
assert user is not None
|
|
assert user.email == 'king.arthur@camelot.bt'
|