feat(users): add user administration and password management
This commit is contained in:
parent
47f54d3461
commit
b584e60273
16 changed files with 720 additions and 22 deletions
|
|
@ -11,9 +11,11 @@ from app.db.base import Base
|
|||
from app.models.customer import Customer, CustomerType
|
||||
from app.models.contact import Contact
|
||||
from app.models.device import Device
|
||||
from app.models.user import User, UserRole
|
||||
from app.models.location import Location
|
||||
from app.models.validation import Validation, ValidationStatus
|
||||
from app.services.validation_workflow import ValidationWorkflowService
|
||||
from app.services.auth_service import AuthService
|
||||
from app.schemas.domain import ValidationCreate
|
||||
from app.modules.orion.service import OrionReportService
|
||||
from app.modules.orion.assets import SCHUBAMED_LOGO_PATH, schubamed_logo_uri
|
||||
|
|
@ -187,6 +189,46 @@ def test_invalid_uuid_returns_validation_error():
|
|||
raise AssertionError("Invalid UUID was accepted")
|
||||
|
||||
|
||||
def test_user_model_supports_password_management_fields():
|
||||
db = session()
|
||||
user = User(
|
||||
email="user@schubamed.de",
|
||||
first_name="Max",
|
||||
last_name="Mustermann",
|
||||
role=UserRole.PRUEFER.value,
|
||||
password_hash="hash",
|
||||
is_active=True,
|
||||
must_change_password=True,
|
||||
)
|
||||
db.add(user)
|
||||
db.flush()
|
||||
|
||||
assert user.full_name == "Max Mustermann"
|
||||
assert user.must_change_password is True
|
||||
assert user.role == UserRole.PRUEFER
|
||||
|
||||
|
||||
def test_login_updates_last_login_at():
|
||||
from app.core.security import hash_password
|
||||
|
||||
db = session()
|
||||
user = User(
|
||||
email="login@schubamed.de",
|
||||
first_name="Login",
|
||||
last_name="Test",
|
||||
role=UserRole.MITARBEITER.value,
|
||||
password_hash=hash_password("VerySecretPass123"),
|
||||
is_active=True,
|
||||
must_change_password=False,
|
||||
)
|
||||
db.add(user)
|
||||
db.flush()
|
||||
|
||||
AuthService(db).login("login@schubamed.de", "VerySecretPass123")
|
||||
|
||||
assert user.last_login_at is not None
|
||||
|
||||
|
||||
def test_revalidation_date_uses_calendar_months():
|
||||
db = session()
|
||||
customer, location, device = seed(db)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue