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

Function TestAuthenticateURLElicitation

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

Source from the content-addressed store, hash-verified

72}
73
74func TestAuthenticateURLElicitation(t *testing.T) {
75 f := newFakeGitHub(t)
76 m := newManager(t, f)
77 m.openURL = func(string) error { return errors.New("no browser") }
78
79 prompter := &fakePrompter{
80 urlCapable: true,
81 onURL: func(_ context.Context, p Prompt) error {
82 return browserGet(p.URL) // user opens the URL and authorizes
83 },
84 }
85
86 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
87 defer cancel()
88
89 out, err := m.Authenticate(ctx, prompter)
90 require.NoError(t, err)
91 assert.Nil(t, out)
92 assert.Equal(t, "gho_access", m.AccessToken())
93
94 prompter.mu.Lock()
95 defer prompter.mu.Unlock()
96 require.Len(t, prompter.urlCalls, 1)
97 assert.NotEmpty(t, prompter.urlCalls[0].URL)
98}
99
100func TestAuthenticateDeclinedPromptFails(t *testing.T) {
101 f := newFakeGitHub(t)

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected