Skip to content

chore: instrument external oauth2 requests #11519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jan 10, 2024
Merged
Prev Previous commit
Next Next commit
use ctx
  • Loading branch information
Emyrk committed Jan 10, 2024
commit 005883a439cc9d9ab85185bc0c1a6208775d4ed2
1 change: 1 addition & 0 deletions coderd/promoauth/oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestMaintainDefault(t *testing.T) {
req, err := http.NewRequest(http.MethodGet,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestion: Could use httptest.NewRequest to avoid checking error. Alternatively http.NewRequestWithContext to skip that step.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

httptest just uses panics instead of an error 🤷
https://github.com/golang/go/blob/master/src/net/http/httptest/httptest.go#L46

I can use NewRequestWithContext though

must(idp.IssuerURL().Parse("/.well-known/openid-configuration")).String(), nil)
require.NoError(t, err)
req = req.WithContext(ctx)

resp, err := http.DefaultClient.Do(req)
require.NoError(t, err)
Expand Down