ticker-validate: mount router at /api/ticker/*

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Giorgio Gilestro 2026-05-27 14:48:00 +02:00
parent b7d6235fcb
commit 30e565909f
2 changed files with 36 additions and 0 deletions

View file

@ -25,6 +25,7 @@ from app.routers import polar_webhook as polar_webhook_router
from app.routers import public as public_router from app.routers import public as public_router
from app.routers import stripe_billing as stripe_router from app.routers import stripe_billing as stripe_router
from app.routers import sync as sync_router from app.routers import sync as sync_router
from app.routers import ticker_validate as ticker_validate_router
from app.routers import universe as universe_router from app.routers import universe as universe_router
from app.services.feeds_bootstrap import bootstrap_feeds from app.services.feeds_bootstrap import bootstrap_feeds
@ -89,6 +90,7 @@ app.include_router(auth_router.router, tags=["auth"])
app.include_router(email_router.router, tags=["email"]) app.include_router(email_router.router, tags=["email"])
app.include_router(api_router.router, prefix="/api", tags=["api"]) app.include_router(api_router.router, prefix="/api", tags=["api"])
app.include_router(universe_router.router, prefix="/api", tags=["universe"]) app.include_router(universe_router.router, prefix="/api", tags=["universe"])
app.include_router(ticker_validate_router.router, prefix="/api", tags=["ticker-validate"])
app.include_router(sync_router.router, tags=["portfolio-sync"]) app.include_router(sync_router.router, tags=["portfolio-sync"])
# Polar webhook (no bearer-token auth — authenticity via HMAC). Path # Polar webhook (no bearer-token auth — authenticity via HMAC). Path
# `/api/polar/webhook` is set on the route itself so the URL Polar # `/api/polar/webhook` is set on the route itself so the URL Polar

View file

@ -242,3 +242,37 @@ async def test_fetch_yahoo_historical_walks_back_to_preceding_trading_day(monkey
assert close == 185.92 assert close == 185.92
assert currency == "USD" assert currency == "USD"
assert actual == "2024-01-12" assert actual == "2024-01-12"
def test_validate_route_requires_paid():
"""Static check that the /ticker/validate route is gated by require_paid."""
from app.routers.ticker_validate import router
from app.services.access import require_paid
route = next(
r for r in router.routes
if getattr(r, "path", "") == "/ticker/validate"
)
dep_callables = [d.call for d in route.dependant.dependencies]
assert require_paid in dep_callables
def test_historical_route_requires_paid():
from app.routers.ticker_validate import router
from app.services.access import require_paid
route = next(
r for r in router.routes
if getattr(r, "path", "") == "/ticker/historical"
)
dep_callables = [d.call for d in route.dependant.dependencies]
assert require_paid in dep_callables
def test_routes_mounted_under_api_prefix():
"""Confirm the router is mounted on the FastAPI app under /api."""
from app.main import app
paths = {getattr(r, "path", "") for r in app.routes}
assert "/api/ticker/validate" in paths
assert "/api/ticker/historical" in paths