Self-hosted web interface and downloader for Qobuz.

refactor(bundle,oauth): tighten bundle scraping and test oauth flow via public apis #15

Open glerp.sullen.net
targeting main from glerp.sullen.net/gobuz:hygiene/bundle-oauth-cleanup
Open opened by and assigned to glerp.sullen.net
targeting main from glerp.sullen.net/gobuz:hygiene/bundle-oauth-cleanup

Summary #

  • internal/bundle:
    • Extract FetchFrom(ctx, baseURL) and fetchBytes so /login and /bundle.js requests share HTTP transport setup and fail fast on non-200 HTTP status codes.
    • Add (*Bundle).SecretValues() using slices.Sorted(maps.Keys(secrets)) to return deterministic, non-empty signing secrets and replace the manual map-key sorting loop in cmd/gobuz/oauth_cmd.go.
    • Convert internal/bundle/bundle_test.go to black-box package bundle_test, replacing direct &Bundle{content: ...} struct literal construction, private regex assertions, and conditional test branches with linear behavioral tests against httptest.NewServer.
  • internal/oauth:
    • Simplify parseQueryParams with cmp.Or and deduplicate HTML response writing in the local OAuth callback handler.
    • Convert internal/oauth/oauth_test.go to black-box package oauth_test, exercising redirect query parameter and authorization code variants behaviorally through oauth.Login.

Verification #

  • go test -count=1 ./...
  • go vet ./...
Commits 1

refactor(bundle,oauth): tighten bundle scraping and test oauth flow via public apis