You've already forked RekomenciBackend
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from datetime import UTC
|
|
from uuid import UUID, uuid4
|
|
|
|
from template_project.application.auth_identity.entity import AuthIdentity, AuthMethod
|
|
from template_project.application.user.entity import UserId
|
|
|
|
|
|
def test_auth_identity_factory_creates_valid_identity() -> None:
|
|
user_id = UserId(uuid4())
|
|
|
|
identity = AuthIdentity.factory(
|
|
user_id=user_id,
|
|
method=AuthMethod.EMAIL,
|
|
identifier="test@example.com",
|
|
secret_key="hashed_password",
|
|
)
|
|
|
|
assert isinstance(identity.id, UUID)
|
|
assert identity.user_id == user_id
|
|
assert identity.method == AuthMethod.EMAIL
|
|
assert identity.identifier == "test@example.com"
|
|
assert identity.secret_key == "hashed_password" # noqa: S105
|
|
assert identity.deleted_at is None
|
|
assert identity.created_at.tzinfo == UTC
|
|
|
|
|
|
def test_auth_identity_factory_without_secret_key() -> None:
|
|
user_id = UserId(uuid4())
|
|
|
|
identity = AuthIdentity.factory(
|
|
user_id=user_id,
|
|
method=AuthMethod.YANDEX,
|
|
identifier="yandex_id_123",
|
|
)
|
|
|
|
assert identity.secret_key is None
|