Skip to content

refactor(api): remove unused authenticate and checkUserAPIKey helpers - #599

Merged
cristim merged 1 commit into
mainfrom
refactor/remove-unused-authenticate
Oct 6, 2026
Merged

cristim merged 1 commit into
mainfrom
refactor/remove-unused-authenticate

Conversation

@cristim

@cristim cristim commented Oct 6, 2026

Copy link
Copy Markdown
Member

Removes the helpers listed in the last open item of #528.

Handler.authenticate, checkUserAPIKey and checkBearerToken had no callers outside tests (grepped every package, cmd/, scripts and the integration/e2e build tags). requireAuth resolves credentials through authenticatePrincipal.

Coverage mapping:

  • middleware_test.go admin-key table and the two bearer-token tests now call authenticatePrincipal (same cases, plus a Principal kind check for sessions); renamed accordingly.
  • TestHandler_checkUserAPIKey_ValidKey -> TestRequireAuth_UserAPIKey (router_authuser_test.go:303).
  • _EmptyKey and _NilAuth -> TestRequireAuth_NilAuth_Rejects (router_authuser_test.go:355) and the empty-key branch of principalFromUserAPIKey.
  • _InvalidKey -> new TestRequireAuth_UserAPIKey_InvalidKey (validation error gives 401).

#528 acceptance on main: spec session and token modes with 401/403/409 for approve, cancel, RI-approve and email revoke (openapi.yaml, merged #563/#584/#589/#594); out-of-scope approve tests (execution_scope_test.go:366, handler_purchases_test.go:2978); stale comment corrected (handler_purchases_test.go:3259); dead helpers removed here. Nothing remains.

Gates: go build, go vet ./..., go vet -tags integration ./internal/..., go vet -tags e2e ./..., go test -race -short ./... all pass; misspell -locale US clean on changed files.

Closes #528

Handler.authenticate, checkUserAPIKey and checkBearerToken had no production callers; requireAuth uses authenticatePrincipal. The tests that exercised them now call authenticatePrincipal, and the user API key validation failure case is covered through requireAuth.
@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/few Limited audience effort/s Hours type/docs Documentation labels Oct 6, 2026
@coderabbitai

coderabbitai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 14 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 64 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 39337a88-5499-46ab-b79b-973aac759a95
📥 Commits

Reviewing files that changed from the base of the PR and between ab0f12a and ed5aa53.

📒 Files selected for processing (3)
  • internal/api/coverage_gaps_test.go
  • internal/api/middleware.go
  • internal/api/middleware_test.go
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/few Limited audience priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/docs Documentation urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(api): approve/cancel/RI-approve openapi describes token-only and omits responses; test gaps from #507

1 participant