test(admin): add negative HTTP-layer tests for registered_clients full-admin gate#175
Merged
dcadenas merged 1 commit intoApr 29, 2026
Conversation
NotThatKindOfDrLiz
approved these changes
Apr 29, 2026
Member
NotThatKindOfDrLiz
left a comment
There was a problem hiding this comment.
Reviewed. I agree with the shape of this PR. This is the right regression lock for the registered_clients full-admin gate: real axum routing, real handler bodies, and the important create-path DB assertion proving the auth check fires before mutation.
I do not see a blocker here. I filed the remaining non-blocking follow-ups separately:
- #182 positive full-admin create/update/delete HTTP tests for symmetry
- #183 DB-state assertions on rejected update/delete paths to mirror the strong create-path check
Approving.
This was referenced May 5, 2026
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.
Summary
PR #168 added admin endpoints for managing registered_clients but only had repo-layer tests.
This change adds HTTP-layer tests so a future refactor cannot quietly drop the full-admin gate.
It covers all five endpoints (list, create, update, delete, pattern tester) for both support-admin and plain-user callers.
Closes #169.
What Changed
New test file
api/tests/registered_clients_admin_http_test.rsdrives each handler through axum and asserts 403.The tests reuse the closure-based Router pattern from
headless_auth_test.rs: each route is wired with a closure that constructsTenantExtractorandUcanAuthdirectly, so no globalKEYCAST_STATEsetup is needed.The HTTP path stays real — actual axum routing, JSON body parsing, and
IntoResponsemapping run during the test.ALLOWED_PUBKEYSenv var pollution.registered_clients_admin_test.rs, per the issue.Testing
The full file passes locally and a red/green check confirmed the assertions are real.
DATABASE_URL=postgres://postgres:password@localhost/keycast_test cargo test -p keycast_api --features integration-tests --test registered_clients_admin_http_test→ 12/12 pass.list_registered_clientswithif false { ... }; the two list tests failed with 200 vs 403; restored the gate; all pass again.cargo clippy --all-targets --features integration-testsclean.cargo fmt --checkclean.Risks
The risk is low because this is test-only and the production gate code is untouched.
admin_token_test.rs).ALLOWED_PUBKEYScould in theory whitelist a generated pubkey, but matching a 256-bit random hex string by accident is not a real concern.