From dc94fb61acfb236e2d72ddf73dd5d658be1f34d3 Mon Sep 17 00:00:00 2001 From: wei liu Date: Tue, 3 Jan 2023 10:13:34 +0800 Subject: [PATCH] fix auth config unmarshal (#21474) Signed-off-by: Wei Liu --- internal/util/paramtable/service_param.go | 8 ++------ internal/util/paramtable/service_param_test.go | 9 ++++++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/util/paramtable/service_param.go b/internal/util/paramtable/service_param.go index c432d74c09..5cffdbf147 100644 --- a/internal/util/paramtable/service_param.go +++ b/internal/util/paramtable/service_param.go @@ -394,12 +394,8 @@ func (p *PulsarConfig) initAuthParams() { } } - if len(jsonMap) == 0 { - p.AuthParams = "" - } else { - jsonData, _ := json.Marshal(&jsonMap) - p.AuthParams = string(jsonData) - } + jsonData, _ := json.Marshal(&jsonMap) + p.AuthParams = string(jsonData) } func (p *PulsarConfig) initTenant() { diff --git a/internal/util/paramtable/service_param_test.go b/internal/util/paramtable/service_param_test.go index 78e0175ce2..41aade3191 100644 --- a/internal/util/paramtable/service_param_test.go +++ b/internal/util/paramtable/service_param_test.go @@ -112,7 +112,14 @@ func TestServiceParam(t *testing.T) { assert.Equal(t, "", Params.AuthPlugin) Params.initAuthParams() - assert.Equal(t, "", Params.AuthParams) + assert.Equal(t, "{}", Params.AuthParams) + }) + + t.Run("test pulsar auth config formatter", func(t *testing.T) { + Params := SParams.PulsarCfg + + Params.initAuthParams() + assert.Equal(t, "{}", Params.AuthParams) }) t.Run("test pulsar tenant/namespace config", func(t *testing.T) {