Skip to content

feat(auth,transport): configurable user-agent, updated origins, operationName - #20

Merged
eshaffer321 merged 3 commits into
eshaffer321:mainfrom
brewgator:pr/auth-transport
May 21, 2026
Merged

eshaffer321 merged 3 commits into
eshaffer321:mainfrom
brewgator:pr/auth-transport

Conversation

@brewgator

Copy link
Copy Markdown
Contributor

Summary

  • Make auth user-agent configurable via ClientOptions.UserAgent (defaults to monarchmoney-go/1.0.0)
  • Update Origin/Referer headers to app.monarch.com (matching Monarch's current domain)
  • Extract and send operationName in GraphQL requests (some servers require it)
  • Simplify LoginWithEmailOTP — the initial login attempt triggers the OTP email, so this method now just re-submits with the email_otp field
  • Expose LoginWithEmailOTP on the AuthService interface
  • Include raw response body in BAD_REQUEST errors when no structured error is found

Split from #19 per review feedback.

Test plan

  • Existing tests pass (go test ./...)
  • Auth flow works with default user-agent
  • Auth flow works with custom UserAgent in ClientOptions
  • GraphQL requests include operationName field

brewgator added 2 commits May 20, 2026 10:30
…tionName

- Make auth user-agent configurable via ClientOptions.UserAgent
  (defaults to monarchmoney-go/1.0.0)
- Update Origin/Referer to app.monarch.com (matching current domain)
- Extract and send operationName in GraphQL requests
- Simplify LoginWithEmailOTP to re-submit with email_otp field
  (initial login attempt triggers the OTP email separately)
- Expose LoginWithEmailOTP on AuthService interface
- Include raw body in BAD_REQUEST errors for better debugging
…llback

- Test operationName extraction from mutation/query/subscription
- Test BAD_REQUEST error with raw body fallback
- Test default and custom header configuration
- Test auth guard (not authenticated, session expired)
- Test truncateQuery, SetAuth, SetSession
@codecov

codecov Bot commented May 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.57143% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.44%. Comparing base (56cb2fd) to head (627cc1e).

Files with missing lines Patch % Lines
pkg/monarch/auth.go 8.33% 11 Missing ⚠️
internal/transport/graphql.go 87.50% 1 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (53.57%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.
❌ Your project check has failed because the head coverage (46.44%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #20      +/-   ##
==========================================
+ Coverage   42.77%   46.44%   +3.67%     
==========================================
  Files          16       16              
  Lines        1833     1858      +25     
==========================================
+ Hits          784      863      +79     
+ Misses        974      904      -70     
- Partials       75       91      +16     
Flag Coverage Δ
unittests 46.44% <53.57%> (+3.67%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/monarch/client.go 36.94% <ø> (ø)
internal/transport/graphql.go 63.58% <87.50%> (+40.77%) ⬆️
pkg/monarch/auth.go 10.11% <8.33%> (-0.28%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 56cb2fd...627cc1e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eshaffer321

Copy link
Copy Markdown
Owner

Thanks for splitting this up @brewgator. I tested this manually and it looks good. Just fix up the CI errors and this will be good to merge

@eshaffer321
eshaffer321 merged commit db2a824 into eshaffer321:main May 21, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants