Coverage for routers/subs/spot.py: 63%
25 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:56 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:56 +0000
1from decouple import config
2from fastapi import Depends
3from starlette.responses import JSONResponse, Response
5import schemas
6from chalicelib.core import spot, webhook
7from or_dependencies import OR_context
8from routers.base import get_routers
10public_app, app, app_apikey = get_routers(prefix="/spot", tags=["spot"])
12if config("LOCAL_DEV", cast=bool, default=False): 12 ↛ 13line 12 didn't jump to line 13 because the condition on line 12 was never true
13 COOKIE_PATH = "/spot/refresh"
14else:
15 COOKIE_PATH = "/api/spot/refresh"
18@app.get('/logout')
19def logout_spot(response: Response, context: schemas.CurrentContext = Depends(OR_context)):
20 spot.logout(user_id=context.user_id)
21 response.delete_cookie(key="spotRefreshToken", path=COOKIE_PATH)
22 return {"data": "success"}
25@app.get('/refresh')
26def refresh_spot_login(response: JSONResponse, context: schemas.CurrentContext = Depends(OR_context)):
27 r = spot.refresh(user_id=context.user_id)
28 content = {"jwt": r.get("jwt")}
29 response.set_cookie(key="spotRefreshToken", value=r.get("refreshToken"), path=COOKIE_PATH,
30 max_age=r.pop("refreshTokenMaxAge"), secure=True, httponly=True)
31 return content
34@app.get('/integrations/slack/channels', tags=["integrations"])
35def get_slack_channels(context: schemas.CurrentContext = Depends(OR_context)):
36 return {"data": webhook.get_by_type(tenant_id=context.tenant_id, webhook_type=schemas.WebhookType.SLACK)}