Created At: 2026-11-18T05:19:22Z Completed At: 2026-11-18T05:19:24Z Command exited with code 1. Command output: /root/telegram-saas/.venv/lib/python3.12/site-packages/pytest_asyncio/plugin.py:306: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. The event loop scope for asynchronous fixtures will default to the fixture scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to "function" scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session". Set it to "fixture-scope" to keep the current behavior. warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) ============================= test session starts ============================== platform linux -- Python 3.12.3, pytest-9.2.0, pluggy-1.7.0 -- /root/telegram-saas/.venv/bin/python3 cachedir: .pytest_cache rootdir: /root/telegram-saas configfile: pyproject.toml testpaths: tests plugins: anyio-4.16.0, asyncio-1.5.0 asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function collecting ... collected 8 items tests/integration/test_auth.py::test_auth_workflow FAILED [ 12%] tests/integration/test_health.py::test_health_liveness PASSED [ 25%] tests/integration/test_health.py::test_health_readiness PASSED [ 37%] tests/tenant_isolation/test_tenant_isolation.py::test_strict_tenant_isolation PASSED [ 50%] tests/unit/test_security.py::test_password_hashing PASSED [ 62%] tests/unit/test_security.py::test_aes_256_gcm_encryption PASSED [ 75%] tests/unit/test_security.py::test_jwt_tokens PASSED [ 87%] tests/unit/test_security.py::test_token_hashing PASSED [100%] =================================== FAILURES =================================== ______________________________ test_auth_workflow ______________________________ async_client = @pytest.mark.asyncio async def test_auth_workflow(async_client: AsyncClient): unique_email = f"user_{uuid.uuid4().hex[:8]}@example.com" password = "StrongPassword2026!" # 1. Register reg_payload = { "email": unique_email, "password": password, "full_name": "Test Engineer", } reg_resp = await async_client.post("/api/v1/auth/register", json=reg_payload) assert reg_resp.status_code == 201, reg_resp.text reg_data = reg_resp.json() assert reg_data["success"] is True assert "access_token" in reg_data["data"] access_token = reg_data["data"]["access_token"] refresh_token = reg_data["data"]["refresh_token"] # 2. Duplicate registration failure dup_resp = await async_client.post("/api/v1/auth/register", json=reg_payload) assert dup_resp.status_code == 409 # 3. Login login_resp = await async_client.post( "/api/v1/auth/login", json={"email": unique_email, "password": password}, ) assert login_resp.status_code == 200 login_data = login_resp.json() new_access_token = login_data["data"]["access_token"] new_refresh_token = login_data["data"]["refresh_token"] # 4. Get Current User Profile headers = {"Authorization": f"Bearer {new_access_token}"} me_resp = await async_client.get("/api/v1/auth/me", headers=headers) assert me_resp.status_code == 200 me_data = me_resp.json() assert me_data["data"]["email"] == unique_email assert me_data["data"]["full_name"] == "Test Engineer" # 5. Refresh token rotation > ref_resp = await async_client.post( "/api/v1/auth/refresh", json={"refresh_token": new_refresh_token}, ) tests/integration/test_auth.py:48: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .venv/lib/python3.12/site-packages/httpx/_client.py:1859: in post return await self.request( .venv/lib/python3.12/site-packages/httpx/_client.py:1540: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .venv/lib/python3.12/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( .venv/lib/python3.12/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( .venv/lib/python3.12/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .venv/lib/python3.12/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .venv/lib/python3.12/site-packages/httpx/_transports/asgi.py:170: in handle_async_request await self.app(scope, receive, send) .venv/lib/python3.12/site-packages/fastapi/applications.py:1194: in __call__ await super().__call__(scope, receive, send) .venv/lib/python3.12/site-packages/starlette/applications.py:96: in __call__ await self.middleware_stack(scope, receive, send) .venv/lib/python3.12/site-packages/starlette/middleware/errors.py:186: in __call__ raise exc .venv/lib/python3.12/site-packages/starlette/middleware/errors.py:164: in __call__ await self.app(scope, receive, _send) .venv/lib/python3.12/site-packages/fastapi/telemetry/_asgi.py:151: in __call__ await self.app(scope, receive, send) .venv/lib/python3.12/site-packages/starlette/middleware/base.py:203: in __call__ response = await self.dispatch_func(request, call_next) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ apps/api/main.py:49: in request_context_middleware response = await call_next(request) ^^^^^^^^^^^^^^^^^^^^^^^^ .venv/lib/python3.12/site-packages/starlette/middleware/base.py:179: in call_next raise app_exc from app_exc.__cause__ or app_exc.__context__ .venv/lib/python3.12/site-packages/starlette/middleware/base.py:149: in coro await self.app(scope, receive_or_disconnect, send_no_error) .venv/lib/python3.12/site-packages/starlette/middleware/cors.py:91: in __call__ await self.simple_response(scope, receive, send, request_headers=headers) .venv/lib/python3.12/site-packages/starlette/middleware/cors.py:149: in simple_response await self.app(scope, receive, send) .venv/lib/python3.12/site-packages/starlette/middleware/exceptions.py:63: in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) .venv/lib/python3.12/site-packages/starlette/_exception_handler.py:53: in wrapped_app raise exc .venv/lib/python3.12/site-packages/starlette/_exception_handler.py:42: in wrapped_app await app(scope, receive, sender) .venv/lib/python3.12/site-packages/fastapi/middleware/asyncexitstack.py:18: in __call__ await self.app(scope, receive, send) .venv/lib/python3.12/site-packages/starlette/routing.py:683: in __call__ await self.middleware_stack(scope, receive, send) .venv/lib/python3.12/site-packages/fastapi/routing.py:2811: in app await route.handle(scope, receive, send) .venv/lib/python3.12/site-packages/fastapi/routing.py:1839: in handle await self.original_router.handle(scope, receive, send) .venv/lib/python3.12/site-packages/fastapi/routing.py:2894: in handle await included_router._handle_selected(scope, receive, send) .venv/lib/python3.12/site-packages/fastapi/routing.py:1850: in _handle_selected await route.handle(scope, receive, send) .venv/lib/python3.12/site-packages/fastapi/routing.py:1839: in handle await self.original_router.handle(scope, receive, send) .venv/lib/python3.12/site-packages/fastapi/routing.py:2894: in handle await included_router._handle_selected(scope, receive, send) .venv/lib/python3.12/site-packages/fastapi/routing.py:1865: in _handle_selected await original_route.handle(scope, receive, send) .venv/lib/python3.12/site-packages/fastapi/routing.py:1328: in handle await effective_context.app(scope, receive, send) .venv/lib/python3.12/site-packages/fastapi/routing.py:166: in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) .venv/lib/python3.12/site-packages/starlette/_exception_handler.py:53: in wrapped_app raise exc .venv/lib/python3.12/site-packages/starlette/_exception_handler.py:42: in wrapped_app await app(scope, receive, sender) .venv/lib/python3.12/site-packages/fastapi/routing.py:152: in app response = await f(request) ^^^^^^^^^^^^^^^^ .venv/lib/python3.12/site-packages/fastapi/routing.py:745: in app raw_response = await run_endpoint_function( .venv/lib/python3.12/site-packages/fastapi/routing.py:372: in run_endpoint_function return await dependant.call(**values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ apps/api/routes/auth.py:58: in refresh_token tokens = await service.refresh_token(req.refresh_token, user_agent=user_agent, ip_address=ip_address) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ modules/identity/service.py:94: in refresh_token session = await self.session_repo.get_active_by_hash(token_hash) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ modules/identity/repository.py:45: in get_active_by_hash return result.scalar_one_or_none() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ .venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py:1083: in scalar_one_or_none return self._only_one_row( _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > ??? E sqlalchemy.exc.MultipleResultsFound: Multiple rows were found when one or none was required lib/sqlalchemy/engine/_result_cy.py:598: MultipleResultsFound ----------------------------- Captured stdout call ----------------------------- 2026-11-18 05:19:23 [info ] dispatching_domain_event event_id=7234fed8-cfa3-4348-abf5-ea969547fc3f event_type=UserRegisteredEvent handlers_count=0 2026-11-18 05:19:23 [warning ] app_exception_handled error_code=CONFLICT message='A user with this email address already exists' method=POST path=/api/v1/auth/register 2026-11-18 05:19:23 [error ] unhandled_server_error error='Multiple rows were found when one or none was required' method=POST path=/api/v1/auth/refresh Traceback (most recent call last): File "/root/telegram-saas/.venv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 164, in __call__ await self.app(scope, receive, _send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/telemetry/_asgi.py", line 151, in __call__ await self.app(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 203, in __call__ response = await self.dispatch_func(request, call_next) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/telegram-saas/apps/api/main.py", line 49, in request_context_middleware response = await call_next(request) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/telegram-saas/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 179, in call_next raise app_exc from app_exc.__cause__ or app_exc.__context__ File "/root/telegram-saas/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 149, in coro await self.app(scope, receive_or_disconnect, send_no_error) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/starlette/middleware/cors.py", line 91, in __call__ await self.simple_response(scope, receive, send, request_headers=headers) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/starlette/middleware/cors.py", line 149, in simple_response await self.app(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 63, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/root/telegram-saas/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__ await self.app(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/starlette/routing.py", line 683, in __call__ await self.middleware_stack(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 2811, in app await route.handle(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 1839, in handle await self.original_router.handle(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 2894, in handle await included_router._handle_selected(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 1850, in _handle_selected await route.handle(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 1839, in handle await self.original_router.handle(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 2894, in handle await included_router._handle_selected(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 1865, in _handle_selected await original_route.handle(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 1328, in handle await effective_context.app(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 166, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/root/telegram-saas/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 152, in app response = await f(request) ^^^^^^^^^^^^^^^^ File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 745, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/telegram-saas/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 372, in run_endpoint_function return await dependant.call(**values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/telegram-saas/apps/api/routes/auth.py", line 58, in refresh_token tokens = await service.refresh_token(req.refresh_token, user_agent=user_agent, ip_address=ip_address) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/telegram-saas/modules/identity/service.py", line 94, in refresh_token session = await self.session_repo.get_active_by_hash(token_hash) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/telegram-saas/modules/identity/repository.py", line 45, in get_active_by_hash return result.scalar_one_or_none() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/telegram-saas/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 1083, in scalar_one_or_none return self._only_one_row( ^^^^^^^^^^^^^^^^^^^ File "lib/sqlalchemy/engine/_result_cy.py", line 598, in sqlalchemy.engine._result_cy.BaseResultInternal._only_one_row sqlalchemy.exc.MultipleResultsFound: Multiple rows were found when one or none was required =========================== short test summary info ============================ FAILED tests/integration/test_auth.py::test_auth_workflow - sqlalchemy.exc.Mu... ========================= 1 failed, 7 passed in 1.31s ==========================