(t *testing.T)
| 380 | } |
| 381 | |
| 382 | func 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. |
nothing calls this directly
no test coverage detected