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)
| 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. |
| 61 | func 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 | |
| 74 | func TestGetValidToken_PreservesIdentityWhenRefreshOmitsUser(t *testing.T) { |
| 75 | keyring.MockInit() |
no test coverage detected