Repository navigation
Keep basecamp connect running, and starting, through a rate-limited or failing token endpoint #811
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
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b0c8514
A rate-limited or failing token endpoint is a wait for the connector,…
jeremy 937d46e
Read a token endpoint's Retry-After in its date form too
jeremy af071d0
Bound a parsed Retry-After where the conversion happens
jeremy a2cd22f
Fail the unreachable-endpoint test from its handler safely
jeremy 67348a6
A starting connector waits for its token instead of exiting
jeremy d9d9702
A stop signal ends the start even with a token renewal in flight
jeremy e5976ff
Retry only what a wait can change, and keep the start's error framing
jeremy 945f2c6
Never log a start's wait as none
jeremy d28ac0e
A second signal ends a start whose renewal will not stop
jeremy 29f685c
The feed and the start retry exactly the same token failures
jeremy 720db6e
A held rate limit carries its wait, read from the hold's deadline
jeremy 6a8f6d8
Pin the held rate limit's wait in the hold's own test
jeremy c85d2eb
Classify an unreadable or oversized error response by its status
jeremy fb43aea
Tell the session a connector waiting for its token is not stopped
jeremy 767c8a9
A second connector is refused before it waits for a token
jeremy 0a035cf
Wait what the server named or the backoff, and hold no lock while wai…
jeremy cc2f30e
Every wait a server names is waited, never longer than one cap
jeremy a443820
One cap for every server-named wait, the one a hold is written under
jeremy 0921b56
Read every Retry-After with one parser
jeremy ecc90a7
Say a capped refresh wait as the server named it
jeremy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package auth | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| // A Retry-After is read in both of its forms, a date rounded up to the | ||
| // second, and a count too large to hold is held at the bound, never read as | ||
| // no wait at all. | ||
| func TestRetryAfterReadsBothForms(t *testing.T) { | ||
| now := time.Date(2026, 10, 1, 0, 0, 0, 0, time.UTC) | ||
| for value, want := range map[string]int{ | ||
| "42": 42, | ||
| " 42 ": 42, | ||
| "0": 0, | ||
| "99999999999999999999999": maxRetryAfterSeconds, | ||
| now.Add(90 * time.Second).Format(http.TimeFormat): 90, | ||
| now.Add(-time.Minute).Format(http.TimeFormat): 0, | ||
| "": 0, | ||
| "-5": 0, | ||
| "soon": 0, | ||
| } { | ||
| assert.Equal(t, want, retryAfterSeconds(value, now), "%q", value) | ||
| } | ||
| } | ||
|
|
||
| // The wait a rate limit named travels with it, whichever form it came in. | ||
| func TestARateLimitCarriesItsWait(t *testing.T) { | ||
| for _, value := range []string{"90", time.Now().Add(90 * time.Second).UTC().Format(http.TimeFormat)} { | ||
| err := statusFailure("minting an agent token", &http.Response{StatusCode: http.StatusTooManyRequests, Header: http.Header{"Retry-After": {value}}}) | ||
| assert.InDelta(t, 90, RetryAfter(err), 1, value) | ||
| } | ||
| err := statusFailure("minting an agent token", &http.Response{StatusCode: http.StatusTooManyRequests, Header: http.Header{}}) | ||
| assert.Zero(t, RetryAfter(err)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.