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"
|
_ "embed"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -126,11 +127,12 @@ func (o *OAuth2) Init() error {
|
||||||
|
|
||||||
// Setup the configuration
|
// Setup the configuration
|
||||||
cfg := &clientcredentials.Config{
|
cfg := &clientcredentials.Config{
|
||||||
ClientID: cid.String(),
|
ClientID: cid.String(),
|
||||||
ClientSecret: csecret.String(),
|
ClientSecret: csecret.String(),
|
||||||
TokenURL: endpoint.TokenURL,
|
TokenURL: endpoint.TokenURL,
|
||||||
Scopes: c.Scopes,
|
Scopes: c.Scopes,
|
||||||
AuthStyle: endpoint.AuthStyle,
|
AuthStyle: endpoint.AuthStyle,
|
||||||
|
EndpointParams: url.Values{},
|
||||||
}
|
}
|
||||||
cid.Destroy()
|
cid.Destroy()
|
||||||
csecret.Destroy()
|
csecret.Destroy()
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSampleConfig(t *testing.T) {
|
func TestSampleConfig(t *testing.T) {
|
||||||
|
|
@ -19,6 +20,26 @@ func TestSampleConfig(t *testing.T) {
|
||||||
require.NotEmpty(t, plugin.SampleConfig())
|
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) {
|
func TestInitFail(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue