MCPcopy
hub / github.com/oauth2-proxy/oauth2-proxy / TestGitHubProvider_getEmailWithToken

Function TestGitHubProvider_getEmailWithToken

providers/github_test.go:382–400  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

380}
381
382func TestGitHubProvider_getEmailWithToken(t *testing.T) {
383 b := testGitHubBackend(map[string][]string{
384 "/user/emails": {`[ {"email": "michael.bland@gsa.gov", "verified": true, "primary": true} ]`},
385 })
386 defer b.Close()
387
388 bURL, _ := url.Parse(b.URL)
389 p := testGitHubProvider(bURL.Host,
390 options.GitHubOptions{
391 Repo: "oauth2-proxy/oauth2-proxy",
392 Token: "token",
393 },
394 )
395
396 session := CreateAuthorizedSession()
397 err := p.getEmail(context.Background(), session)
398 assert.NoError(t, err)
399 assert.Equal(t, "michael.bland@gsa.gov", session.Email)
400}
401
402// Note that trying to trigger the "failed building request" case is not
403// practical, since the only way it can fail is if the URL fails to parse.

Callers

nothing calls this directly

Calls 5

testGitHubBackendFunction · 0.85
testGitHubProviderFunction · 0.85
CreateAuthorizedSessionFunction · 0.85
getEmailMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected