feat(platform): close AI expense value loop
Add tenant-safe value, telemetry, connector, commercial, and production-readiness foundations.
This commit is contained in:
@@ -29,7 +29,7 @@ def build_session() -> Session:
|
||||
|
||||
def test_employee_can_login_with_seed_default_password() -> None:
|
||||
with build_session() as db:
|
||||
employee = EmployeeService(db).list_employees()[0]
|
||||
employee = EmployeeService(db, tenant_id="default").list_employees()[0]
|
||||
result = AuthService(db).login(
|
||||
LoginRequest(username=employee.email, password="123456")
|
||||
)
|
||||
@@ -50,8 +50,11 @@ def test_employee_can_login_with_seed_default_password() -> None:
|
||||
|
||||
def test_current_user_snapshot_refreshes_employee_position() -> None:
|
||||
with build_session() as db:
|
||||
employee = EmployeeService(db).list_employees()[0]
|
||||
result = AuthService(db).get_user_snapshot(employee.email)
|
||||
employee = EmployeeService(db, tenant_id="default").list_employees()[0]
|
||||
result = AuthService(db).get_user_snapshot(
|
||||
employee.email,
|
||||
tenant_id="default",
|
||||
)
|
||||
|
||||
assert result is not None
|
||||
assert result.username == employee.email
|
||||
@@ -83,7 +86,7 @@ def test_admin_can_login_with_database_password() -> None:
|
||||
|
||||
def test_disabled_employee_cannot_login() -> None:
|
||||
with build_session() as db:
|
||||
service = EmployeeService(db)
|
||||
service = EmployeeService(db, tenant_id="default")
|
||||
employee = service.list_employees()[0]
|
||||
service.disable_employee(employee.id)
|
||||
|
||||
@@ -97,7 +100,7 @@ def test_disabled_employee_cannot_login() -> None:
|
||||
|
||||
def test_reenabled_employee_can_login_again() -> None:
|
||||
with build_session() as db:
|
||||
service = EmployeeService(db)
|
||||
service = EmployeeService(db, tenant_id="default")
|
||||
employee = service.list_employees()[0]
|
||||
service.disable_employee(employee.id)
|
||||
service.enable_employee(employee.id)
|
||||
@@ -125,7 +128,7 @@ def test_employee_login_skips_directory_bootstrap_when_employee_exists(monkeypat
|
||||
monkeypatch.setattr(
|
||||
AuthService,
|
||||
"_find_employee_by_email",
|
||||
lambda self, _: ExistingEmployee(),
|
||||
lambda self, _, requested_tenant: ExistingEmployee(),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"app.services.auth.verify_password",
|
||||
@@ -150,11 +153,16 @@ def test_employee_login_skips_directory_bootstrap_when_employee_exists(monkeypat
|
||||
role_codes=["user"],
|
||||
email=employee.email,
|
||||
avatar="D",
|
||||
tenant_id="default",
|
||||
),
|
||||
)
|
||||
monkeypatch.setattr(EmployeeService, "ensure_directory_ready", fail_if_bootstrapped)
|
||||
|
||||
user = service._authenticate_employee("demo@example.com", "123456")
|
||||
user = service._authenticate_employee(
|
||||
"demo@example.com",
|
||||
"123456",
|
||||
requested_tenant="default",
|
||||
)
|
||||
|
||||
assert user is not None
|
||||
assert user.username == "demo@example.com"
|
||||
@@ -179,6 +187,7 @@ def test_login_session_write_rolls_back_metric_when_token_issue_fails(monkeypatc
|
||||
role_codes=["user"],
|
||||
email="rollback@example.com",
|
||||
avatar="R",
|
||||
tenant_id="default",
|
||||
)
|
||||
|
||||
def fail_issue(*args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user