Files
DeepTutor/tests/api
Bingxi Zhao 87ccedd549 test(partners): assert the admin gate by request, not by route internals (#983)
The admin-gate test from #952 read `route.include_context`. That attribute
only exists from FastAPI 0.141, where `include_router` stopped flattening the
sub-router into the parent app; before that the routes are copied onto
`app.routes` and there is no `include_context` at all. This project pins
`fastapi>=0.100.0` with no upper bound, so the test passed on CI (which
installs the latest) and raised `StopIteration` on any older satisfying
install — `5115 passed, 1 failed` locally on 0.135.1.

No structural assertion works across that range, so assert the actual
property instead: send a valid `role=user` token and require 403. A response
code does not care how the router is represented.

An unauthenticated request would not have been enough — `require_auth` alone
answers that with 401, so downgrading the router from `_admin` to `_auth`
would still have looked gated. With a real non-admin token, both weakenings
(`_admin` → `_auth`, and dropping the dependency entirely) let the request
reach the handler and fail the test. Also patches `AUTH_SECRET`, without
which `decode_token` rejects every token in a bare test environment and the
403 could never be distinguished from a 401.

Co-authored-by: Frank <bingxizhao@novix.science>
2026-08-24 17:54:04 +08:00
..
2026-06-11 20:03:34 +08:00
2026-08-17 11:22:26 +08:00
2026-06-11 20:03:34 +08:00
2026-06-18 00:22:48 +08:00
2026-06-17 10:50:44 +08:00
2026-08-19 17:34:52 +08:00
2026-07-31 00:25:48 +08:00
2026-06-11 20:03:34 +08:00
2026-06-21 14:43:41 +08:00
2026-06-18 00:22:48 +08:00
2026-07-31 00:25:48 +08:00
2026-07-31 00:25:48 +08:00
2026-08-02 13:07:32 +08:00