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

Function TestRequestAccessTokenRejectsEmptyToken

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

Source from the content-addressed store, hash-verified

525}
526
527func 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
551func TestRequestAccessTokenRejectsMissingRefreshToken(t *testing.T) {
552 mockOAuthAppCredentials(t)

Callers

nothing calls this directly

Calls 3

mockOAuthAppCredentialsFunction · 0.85
requestAccessTokenFunction · 0.85
jsonErrorCodeFunction · 0.85

Tested by

no test coverage detected