(t *testing.T)
| 549 | } |
| 550 | |
| 551 | func TestRequestAccessTokenRejectsMissingRefreshToken(t *testing.T) { |
| 552 | mockOAuthAppCredentials(t) |
| 553 | |
| 554 | origReadAuthorizationCode := readAuthorizationCode |
| 555 | origExchangeAuthorizationCode := exchangeAuthorizationCode |
| 556 | t.Cleanup(func() { |
| 557 | readAuthorizationCode = origReadAuthorizationCode |
| 558 | exchangeAuthorizationCode = origExchangeAuthorizationCode |
| 559 | }) |
| 560 | |
| 561 | readAuthorizationCode = func() (string, error) { |
| 562 | return "auth-code", nil |
| 563 | } |
| 564 | exchangeAuthorizationCode = func(ctx context.Context, conf *oauth2.Config, code string, verifier string) (*oauth2.Token, error) { |
| 565 | return &oauth2.Token{AccessToken: "access-token"}, nil |
| 566 | } |
| 567 | |
| 568 | if _, err := requestAccessToken(tokenPersonal, ""); err == nil { |
| 569 | t.Fatal("expected missing refresh token to return an error") |
| 570 | } else if got, want := jsonErrorCode(err), jsonErrorCodeAuthExchangeFailed; got != want { |
| 571 | t.Fatalf("jsonErrorCode = %q, want %q", got, want) |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | func TestRequestAccessTokenReturnsReadError(t *testing.T) { |
| 576 | mockOAuthAppCredentials(t) |
nothing calls this directly
no test coverage detected