Skip to content

Commit ad4f00e

Browse files
committed
fix: use in-memort OAuth stores for httpclient loopback tests
1 parent 57e231c commit ad4f00e

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

internal/httpclient/AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818

1919
## Tests
2020

21-
- Inject HTTP servers, OAuth options, authorization prompts, and in-memory cache backends; never require a browser, keyring, or real provider.
21+
- Inject HTTP servers, OAuth options, authorization prompts, and in-memory cache backends; never require a browser, keyring, or real provider. `httpclient.New` uses the production OS keyring by default, so delegated-auth tests, including cancellation and error paths, must call `SetTokenStore(oauthcache.NewWithBackend(...))` before invoking a mutation.
2222
- Loopback tests bind ports 8085-8089 and must not run in parallel.
2323
- Run `go test ./internal/httpclient`.

internal/httpclient/client_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ func TestAuthorizationCodeCancellationClosesLoopbackListener(t *testing.T) {
394394
defer server.Close()
395395

396396
client := httpclient.New(ctx, server.URL)
397+
client.SetTokenStore(oauthcache.NewWithBackend(&memoryTokenBackend{values: make(map[string]string)}))
397398
client.OAuth.ClientID = "public-client"
398399
client.OAuth.AuthorizationPrompt = func(string) { cancel() }
399400
err := client.Remove(context.Background(), "stable", "x86_64", "example")
@@ -760,6 +761,7 @@ func TestAuthorizationCodeFailsWhenAllLoopbackPortsOccupied(t *testing.T) {
760761
defer server.Close()
761762

762763
client := httpclient.New(context.Background(), server.URL)
764+
client.SetTokenStore(oauthcache.NewWithBackend(&memoryTokenBackend{values: make(map[string]string)}))
763765
client.OAuth.ClientID = "public-client"
764766
err := client.Remove(context.Background(), "stable", "x86_64", "example")
765767
if err == nil || !strings.Contains(err.Error(), "all loopback ports") {

0 commit comments

Comments
 (0)