MCPcopy Create free account
hub / github.com/algolia/cli / newRefreshServer

Function newRefreshServer

pkg/auth/token_store_test.go:61–72  ·  view source on GitHub ↗

newRefreshServer returns a dashboard client whose token endpoint replies with the given response, mimicking POST /2/oauth/token for grant_type=refresh_token.

(t *testing.T, resp dashboard.OAuthTokenResponse)

Source from the content-addressed store, hash-verified

59// newRefreshServer returns a dashboard client whose token endpoint replies with
60// the given response, mimicking POST /2/oauth/token for grant_type=refresh_token.
61func newRefreshServer(t *testing.T, resp dashboard.OAuthTokenResponse) *dashboard.Client {
62 t.Helper()
63
64 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
65 require.NoError(t, json.NewEncoder(w).Encode(resp))
66 }))
67 t.Cleanup(srv.Close)
68
69 client := dashboard.NewClientWithHTTPClient("test-client-id", srv.Client())
70 client.DashboardURL = srv.URL
71 return client
72}
73
74func TestGetValidToken_PreservesIdentityWhenRefreshOmitsUser(t *testing.T) {
75 keyring.MockInit()

Calls 2

NewClientWithHTTPClientFunction · 0.92
HelperMethod · 0.80

Tested by

no test coverage detected