MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestRequestAccessTokenRejectsMissingRefreshToken

Function TestRequestAccessTokenRejectsMissingRefreshToken

cmd/auth_test.go:551–573  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

549}
550
551func 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
575func TestRequestAccessTokenReturnsReadError(t *testing.T) {
576 mockOAuthAppCredentials(t)

Callers

nothing calls this directly

Calls 3

mockOAuthAppCredentialsFunction · 0.85
requestAccessTokenFunction · 0.85
jsonErrorCodeFunction · 0.85

Tested by

no test coverage detected