Repository navigation
test(backend): route auth matrix over the app's route table - #305
Merged
Merged
Conversation
Sort every handler the app registers into public or signed-in, call each signed-in route signed out and expect 401, and check that another user gets 404 on every game and invite route that takes an id.
arrzdev
force-pushed
the
test/route-auth-matrix
branch
from
November 9, 2026 10:34
192c6a1 to
52f8307
Compare
arrzdev
commented
Nov 9, 2026
arrzdev
left a comment
Owner
Author
There was a problem hiding this comment.
Approve. The route table comes from hono's inspector, so an unlisted route fails, and so does a stale entry. Signed-out 401s are checked on every signed-in route, and the meta-check makes every id route carry a cross-user case. The wrong-role invite cases (sender declining, recipient deleting, sender accepting) are a good addition. Main has moved 2 commits since this branch, but neither touches a route, so the matrix still holds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Each route test checked its own auth by hand, so a new route without
requireAuthwould have passed CI.apps/backend/src/http/route-auth.test.tsnow checks the whole API against the app's own route table (inspectRoutesfromhono/dev, middleware left out), using real local D1:PUBLIC_ROUTES(with a reason) orSIGNED_IN_ROUTES. A route in neither list fails, and the failure shows its method and path. A listed route that no longer exists fails too.401 unauthorized. A bogus bearer token gets 401 as well.404 not_foundon every game and invite route that takes an id: read game, read moves, play move, resign, decline, delete, and accept-invite throughPOST /games. Wrong-role calls are covered too: the sender declining their own invite, the recipient deleting it, the sender accepting it. Afterwards the game and invites are unchanged, the outsider's lists are empty, and/profile/mereturns the caller's own profile. A meta-check fails if a signed-in route with a path parameter has no cross-user entry.Gaps found: none. Every game and invite read and write already goes through a query scoped to the caller. To prove the test catches regressions, I made two temporary changes and reverted both: removing
requireAuthfrom/realtime/ticketmade it fail withexpected 500 to be 401, and adding an unlistedGET /api/v1/secretmade it fail with[ 'GET /api/v1/secret' ].Out of the cross-user matrix, on purpose:
POST /invite-links/:id/accept: anyone holding the link can use it, by design./meand take no user id.POST /events/game: anonymous counts, and nothing in it belongs to a user.How to verify