(t *testing.T)
| 525 | } |
| 526 | |
| 527 | func TestRequestAccessTokenRejectsEmptyToken(t *testing.T) { |
| 528 | mockOAuthAppCredentials(t) |
| 529 | |
| 530 | origReadAuthorizationCode := readAuthorizationCode |
| 531 | origExchangeAuthorizationCode := exchangeAuthorizationCode |
| 532 | t.Cleanup(func() { |
| 533 | readAuthorizationCode = origReadAuthorizationCode |
| 534 | exchangeAuthorizationCode = origExchangeAuthorizationCode |
| 535 | }) |
| 536 | |
| 537 | readAuthorizationCode = func() (string, error) { |
| 538 | return "auth-code", nil |
| 539 | } |
| 540 | exchangeAuthorizationCode = func(ctx context.Context, conf *oauth2.Config, code string, verifier string) (*oauth2.Token, error) { |
| 541 | return &oauth2.Token{}, nil |
| 542 | } |
| 543 | |
| 544 | if _, err := requestAccessToken(tokenPersonal, ""); err == nil { |
| 545 | t.Fatal("expected empty access token to return an error") |
| 546 | } else if got, want := jsonErrorCode(err), jsonErrorCodeAuthExchangeFailed; got != want { |
| 547 | t.Fatalf("jsonErrorCode = %q, want %q", got, want) |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | func TestRequestAccessTokenRejectsMissingRefreshToken(t *testing.T) { |
| 552 | mockOAuthAppCredentials(t) |
nothing calls this directly
no test coverage detected