diff --git a/x-pack/elastic-agent/CHANGELOG.asciidoc b/x-pack/elastic-agent/CHANGELOG.asciidoc index 45ddd69a275c..e178ffe3e8b5 100644 --- a/x-pack/elastic-agent/CHANGELOG.asciidoc +++ b/x-pack/elastic-agent/CHANGELOG.asciidoc @@ -23,6 +23,7 @@ - Remove the kbn-version on each request to the Kibana API. {pull}17764[17764] - Fixed process spawning on Windows {pull}17751[17751] - Fixed injected log path to monitoring beat {pull}17833[17833] +- Make sure that the Elastic Agent connect over TLS in cloud. {pull}xx[xxx] ==== New features diff --git a/x-pack/elastic-agent/pkg/kibana/config.go b/x-pack/elastic-agent/pkg/kibana/config.go index 34975d933d98..14182898bc50 100644 --- a/x-pack/elastic-agent/pkg/kibana/config.go +++ b/x-pack/elastic-agent/pkg/kibana/config.go @@ -31,6 +31,8 @@ func (p *Protocol) Unpack(from string) error { if from != "https" && from != "http" { return fmt.Errorf("invalid protocol %s, accepted values are 'http' and 'https'", from) } + + *p = Protocol(from) return nil } diff --git a/x-pack/elastic-agent/pkg/kibana/config_test.go b/x-pack/elastic-agent/pkg/kibana/config_test.go new file mode 100644 index 000000000000..57809e747785 --- /dev/null +++ b/x-pack/elastic-agent/pkg/kibana/config_test.go @@ -0,0 +1,37 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package kibana + +import ( + "reflect" + "testing" + "time" + + "gopkg.in/yaml.v2" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestPackUnpack(t *testing.T) { + c := Config{ + Protocol: Protocol("https"), + SpaceID: "123", + Username: "foo", + Password: "bar", + Path: "/ok", + Timeout: 10 * time.Second, + } + + b, err := yaml.Marshal(&c) + require.NoError(t, err) + + c2 := Config{} + + err = yaml.Unmarshal(b, &c2) + require.NoError(t, err) + + assert.True(t, reflect.DeepEqual(c, c2)) +}