MCPcopy Index your code
hub / github.com/github/github-mcp-server / TestAuthenticateDeviceFlow

Function TestAuthenticateDeviceFlow

internal/oauth/manager_test.go:187–206  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

185}
186
187func TestAuthenticateDeviceFlow(t *testing.T) {
188 f := newFakeGitHub(t)
189 f.deviceToken = "gho_device_token"
190 m := newManager(t, f)
191 // Inside Docker with a random port, PKCE is impossible, so the device flow
192 // is selected.
193 m.inDocker = func() bool { return true }
194 m.openURL = func(string) error { return errors.New("no browser") }
195
196 prompter := &fakePrompter{urlCapable: true} // shows the code, no action needed
197
198 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
199 defer cancel()
200
201 out, err := m.Authenticate(ctx, prompter)
202 require.NoError(t, err)
203 assert.Nil(t, out)
204 assert.Equal(t, "gho_device_token", m.AccessToken())
205 assert.Contains(t, f.recordedGrants(), "urn:ietf:params:oauth:grant-type:device_code")
206}
207
208func TestAuthenticateDevicePollingPending(t *testing.T) {
209 f := newFakeGitHub(t)

Callers

nothing calls this directly

Calls 5

newFakeGitHubFunction · 0.85
newManagerFunction · 0.85
AccessTokenMethod · 0.80
recordedGrantsMethod · 0.80
AuthenticateMethod · 0.65

Tested by

no test coverage detected