MCPcopy Create free account
hub / github.com/cli/cli / TestTokenRefresherRefreshRejected

Function TestTokenRefresherRefreshRejected

internal/authflow/refresh_test.go:115–127  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

113}
114
115func TestTokenRefresherRefreshRejected(t *testing.T) {
116 stub := &stubRoundTripper{
117 body: "error=bad_refresh_token&error_description=The+refresh+token+passed+is+incorrect+or+expired.",
118 }
119 refresher := NewTokenRefresher(&http.Client{Transport: stub})
120
121 _, err := refresher.Refresh("ghr_OLD", "github.com")
122 require.Error(t, err)
123 // The gh sentinel lets a caller classify an unusable refresh token without importing the OAuth library, while the
124 // original library error is preserved in the chain.
125 require.ErrorIs(t, err, gh.ErrRefreshTokenInvalid)
126 require.ErrorIs(t, err, oauth.ErrRefreshTokenInvalid)
127}
128
129func TestAuthResultFromToken(t *testing.T) {
130 // Production anchors the lifetime at timeNow().UTC(), so mirror that with a UTC anchor here.

Callers

nothing calls this directly

Calls 3

RefreshMethod · 0.95
NewTokenRefresherFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected