(t *testing.T)
| 777 | } |
| 778 | |
| 779 | func TestRequestAccessTokenRejectsEmptyAppCredentials(t *testing.T) { |
| 780 | restoreOAuthCredentials(t) |
| 781 | setOAuthCredentials(tokenTeamManage, "") |
| 782 | |
| 783 | origReadAuthorizationCode := readAuthorizationCode |
| 784 | origExchangeAuthorizationCode := exchangeAuthorizationCode |
| 785 | t.Cleanup(func() { |
| 786 | readAuthorizationCode = origReadAuthorizationCode |
| 787 | exchangeAuthorizationCode = origExchangeAuthorizationCode |
| 788 | }) |
| 789 | |
| 790 | readAppCredentials = func(tokType string) (appCredentials, error) { |
| 791 | return appCredentials{Key: " "}, nil |
| 792 | } |
| 793 | readAuthorizationCode = func() (string, error) { |
| 794 | t.Fatal("authorization code prompt should not run when app credentials are invalid") |
| 795 | return "", nil |
| 796 | } |
| 797 | exchangeAuthorizationCode = func(ctx context.Context, conf *oauth2.Config, code string, verifier string) (*oauth2.Token, error) { |
| 798 | t.Fatal("authorization exchange should not run when app credentials are invalid") |
| 799 | return nil, nil |
| 800 | } |
| 801 | |
| 802 | if _, err := requestAccessToken(tokenTeamManage, ""); err == nil { |
| 803 | t.Fatal("expected empty app credentials to fail") |
| 804 | } else if got, want := jsonErrorCode(err), jsonErrorCodeAppKeyRequired; got != want { |
| 805 | t.Fatalf("jsonErrorCode = %q, want %q", got, want) |
| 806 | } |
| 807 | } |
nothing calls this directly
no test coverage detected