mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
[5cab5a17] Relocate mount_telegram_miniapp_auth out of roboco/api/routes/telegram.py (#786)
* [5cab5a17] refactor(api): relocate mount_telegram_miniapp_auth from routes/telegram.py into app.py Move the bare top-level helper (a conditional router mount + LoginRateLimiter registration, not route-handler logic) out of roboco/api/routes/telegram.py into roboco/api/app.py as private _mount_telegram_miniapp_auth, next to its sole call site. This resolves pr_gate finding 276ae32f: classify_python.py flags any non-@router-decorated top-level function as 'helper', which .roboco/conventions.yml forbids under roboco/api/routes. The sibling mount_cloud_auth already lives outside routes/ in roboco/api/auth/routes.py, which is the same architectural precedent. telegram.py: removed the function, the now-unused LoginRateLimiter import, and the TYPE_CHECKING FastAPI block; updated docstring/comment references. app.py: added _mount_telegram_miniapp_auth before create_app, imported webapp_auth_router from routes.telegram and LoginRateLimiter from auth.login_limit. test_telegram_webapp_auth.py: updated import and three call sites. No route paths, schemas, or observable behavior changed. * [5cab5a17] docs(map): reflect mount_telegram_miniapp_auth relocation into app.py Update the agent-facing codebase map (docs/map/api-routes-schemas.md, regenerated into _complete_map.md) for the placement-only refactor in PR #786 / task 5cab5a17: mount_telegram_miniapp_auth moved out of roboco/api/routes/telegram.py into roboco/api/app.py as private _mount_telegram_miniapp_auth. Route-table row, Key Endpoints, Entry Points, Config Flags, and the Changes-Since-Baseline note (Batch C trailing sentence + a new task 5cab5a17 entry) now point at the new location/name. No route/schema/behavior change to document — placement only. --------- Co-authored-by: Backend Developer 1 <be-dev-1@roboco.tech> Co-authored-by: Backend Documenter <be-doc@roboco.tech>
This commit is contained in:
co-authored by
Backend Developer 1
Backend Documenter
parent
c317888aec
commit
70f059e5ff
@@ -23,9 +23,10 @@ from cryptography.fernet import Fernet
|
||||
from fastapi import FastAPI
|
||||
from fastapi_users.password import PasswordHelper
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
from roboco.api.app import _mount_telegram_miniapp_auth
|
||||
from roboco.api.auth.backend import SESSION_COOKIE_NAME
|
||||
from roboco.api.deps import get_db
|
||||
from roboco.api.routes.telegram import mount_telegram_miniapp_auth, webapp_auth_router
|
||||
from roboco.api.routes.telegram import webapp_auth_router
|
||||
from roboco.config import settings
|
||||
from roboco.db.tables import UserTable
|
||||
from roboco.services.telegram_credentials import get_telegram_credentials_service
|
||||
@@ -129,7 +130,7 @@ async def test_mount_skipped_when_miniapp_flag_off(
|
||||
) -> None:
|
||||
monkeypatch.setattr(settings, "telegram_miniapp_enabled", False)
|
||||
app = FastAPI()
|
||||
mount_telegram_miniapp_auth(app, "/api/telegram")
|
||||
_mount_telegram_miniapp_auth(app, "/api/telegram")
|
||||
assert await _post_unmounted_probe(app) == HTTPStatus.NOT_FOUND
|
||||
|
||||
|
||||
@@ -139,14 +140,14 @@ async def test_mount_skipped_when_cloud_auth_off(
|
||||
) -> None:
|
||||
monkeypatch.setattr(settings, "cloud_auth_enabled", False)
|
||||
app = FastAPI()
|
||||
mount_telegram_miniapp_auth(app, "/api/telegram")
|
||||
_mount_telegram_miniapp_auth(app, "/api/telegram")
|
||||
assert await _post_unmounted_probe(app) == HTTPStatus.NOT_FOUND
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_mount_included_when_both_armed(db_session: AsyncSession) -> None:
|
||||
app = FastAPI()
|
||||
mount_telegram_miniapp_auth(app, "/api/telegram")
|
||||
_mount_telegram_miniapp_auth(app, "/api/telegram")
|
||||
|
||||
async def _override_db() -> AsyncIterator[AsyncSession]:
|
||||
yield db_session
|
||||
|
||||
Reference in New Issue
Block a user