Skip to content

chore: drop github per user rate limit tracking #12286

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 4 commits into from
Feb 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix github rate limit test
  • Loading branch information
Emyrk committed Feb 23, 2024
commit 873baf22fba6e1a8f29c83c2e19da21789e09d7c
15 changes: 12 additions & 3 deletions coderd/promoauth/oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ func TestGithubRateLimits(t *testing.T) {
}
}

// Ignore the well known, required for setup
if !strings.Contains(r.URL.String(), ".well-known") {
// GitHub rate limits only are instrumented for unauthenticated calls. So emulate
// that here. We cannot actually use invalid credentials because the fake IDP
// will throw a test error, as it only expects things to work. And we want to use
// a real idp to emulate the right http calls to be instrumented.
rw.WriteHeader(http.StatusUnauthorized)
return
}
next.ServeHTTP(rw, r)
})
}))
Expand All @@ -195,13 +204,13 @@ func TestGithubRateLimits(t *testing.T) {
// Do a single oauth2 call
ctx := testutil.Context(t, testutil.WaitShort)
ctx = context.WithValue(ctx, oauth2.HTTPClient, idp.HTTPClient(nil))
_, err := cfg.Exchange(ctx, idp.CreateAuthCode(t, "foo"))
require.NoError(t, err)
_, err := cfg.Exchange(ctx, "invalid")
require.Error(t, err, "expected unauthorized exchange")

// Verify
labels := prometheus.Labels{
"name": "test",
"resource": "core",
"resource": "core-unauthorized",
}
pass := true
if !c.ExpectNoMetrics {
Expand Down