fix(secretstores.oauth2): Ensure endpoint params is not nil (#15531)
This commit is contained in:
parent
6fb42764e1
commit
80e94f7043
|
|
@ -6,6 +6,7 @@ import (
|
|||
_ "embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -126,11 +127,12 @@ func (o *OAuth2) Init() error {
|
|||
|
||||
// Setup the configuration
|
||||
cfg := &clientcredentials.Config{
|
||||
ClientID: cid.String(),
|
||||
ClientSecret: csecret.String(),
|
||||
TokenURL: endpoint.TokenURL,
|
||||
Scopes: c.Scopes,
|
||||
AuthStyle: endpoint.AuthStyle,
|
||||
ClientID: cid.String(),
|
||||
ClientSecret: csecret.String(),
|
||||
TokenURL: endpoint.TokenURL,
|
||||
Scopes: c.Scopes,
|
||||
AuthStyle: endpoint.AuthStyle,
|
||||
EndpointParams: url.Values{},
|
||||
}
|
||||
cid.Destroy()
|
||||
csecret.Destroy()
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/influxdata/telegraf/config"
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
)
|
||||
|
||||
func TestSampleConfig(t *testing.T) {
|
||||
|
|
@ -19,6 +20,26 @@ func TestSampleConfig(t *testing.T) {
|
|||
require.NotEmpty(t, plugin.SampleConfig())
|
||||
}
|
||||
|
||||
func TestEndpointParams(t *testing.T) {
|
||||
plugin := &OAuth2{
|
||||
Endpoint: "http://localhost:8080/token",
|
||||
Tenant: "tenantID",
|
||||
TokenConfigs: []TokenConfig{
|
||||
{
|
||||
ClientID: config.NewSecret([]byte("clientID")),
|
||||
ClientSecret: config.NewSecret([]byte("clientSecret")),
|
||||
Key: "test",
|
||||
Params: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
Log: testutil.Logger{},
|
||||
}
|
||||
|
||||
require.NoError(t, plugin.Init())
|
||||
}
|
||||
|
||||
func TestInitFail(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
|
|
|||
Loading…
Reference in New Issue