From 570d5ceffa19958403d3bb4c8e38070e93ef8fab Mon Sep 17 00:00:00 2001 From: Yong Zhang Date: Mon, 3 Aug 2020 10:16:13 +0800 Subject: [PATCH] Fix the keyfile unmarshal error (#339) --- *Motivation* Fix the keyfile unmarshal error: ``` open test_credential.json: unsupported format ``` --- oauth2/client_credentials_provider.go | 8 -------- pulsar/client_impl_test.go | 2 +- pulsar/internal/auth/oauth2_test.go | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/oauth2/client_credentials_provider.go b/oauth2/client_credentials_provider.go index 271637653..731b39955 100644 --- a/oauth2/client_credentials_provider.go +++ b/oauth2/client_credentials_provider.go @@ -19,14 +19,9 @@ package oauth2 import ( "encoding/json" - "fmt" "io/ioutil" ) -const ( - KeyFileTypeServiceAccount = "sn_service_account" -) - type KeyFileProvider struct { KeyFile string } @@ -58,9 +53,6 @@ func (k *KeyFileProvider) GetClientCredentials() (*KeyFile, error) { if err != nil { return nil, err } - if v.Type != KeyFileTypeServiceAccount { - return nil, fmt.Errorf("open %s: unsupported format", k.KeyFile) - } return &v, nil } diff --git a/pulsar/client_impl_test.go b/pulsar/client_impl_test.go index 276e4fb31..ba17219e9 100644 --- a/pulsar/client_impl_test.go +++ b/pulsar/client_impl_test.go @@ -266,7 +266,7 @@ func mockKeyFile(server string) (string, error) { return "", err } _, err = kf.WriteString(fmt.Sprintf(`{ - "type":"sn_service_account", + "type":"resource", "client_id":"client-id", "client_secret":"client-secret", "client_email":"oauth@test.org", diff --git a/pulsar/internal/auth/oauth2_test.go b/pulsar/internal/auth/oauth2_test.go index c8a483048..f1f9e07e1 100644 --- a/pulsar/internal/auth/oauth2_test.go +++ b/pulsar/internal/auth/oauth2_test.go @@ -69,7 +69,7 @@ func mockKeyFile(server string) (string, error) { return "", err } _, err = kf.WriteString(fmt.Sprintf(`{ - "type":"sn_service_account", + "type":"resource", "client_id":"client-id", "client_secret":"client-secret", "client_email":"oauth@test.org",