Summary#
- Add
handler_test.gocovering the three HTTP handlers exposed byOAuth.Router():clientMetadata,jwks, andcallback - Fix four pre-existing
errchecklint violations inhandler.goandoauth.go(uncheckedBody.Closereturn values and a discardedSaveAuthRequestInfoerror) to get a cleangolangci-lintrun - Package coverage moves from 4.4% → 10.6%
What is covered#
callback: all error paths that do not require a live PDS — missing state param, unknown state, five distinctAuthRequestCallbackErrorcodes (access_denied,server_error,login_required,consent_required), missingcode/issparams, anderrorparam taking precedence overcodeclientMetadata: JSON structure, required OAuth fields, correctjwks_uri/client_name/client_uri,identity:handlescope appended by the handlerjwks: P-256 public key fields present, no private key componentdleakedAppPasswordSession.isValid: time-window boundary conditions
What is not yet covered#
The success path of callback (post-ProcessCallback, post-SaveSession)
is unreachable without a live PDS token exchange. This includes:
the authReturn redirect, the deactivated-account redirect to
/settings/profile, the posthog capture branch, and the four
post-login goroutines.
What's next#
- Goroutine refactor — replace the four bare
gocalls with anerrgroupscoped to a timeout context; existing tests stay green as a regression guard - Inject
ClientAppvia interface — onceProcessCallbackandSaveSessionare stubbable, the success path becomes testable and coverage ofcallbackcan reach ~90%+