Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional unit tests to fleet-server config #2499

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions internal/pkg/agent/configuration/fleet_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/elastic/elastic-agent-libs/transport/tlscommon"
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
)

Expand Down Expand Up @@ -53,6 +54,49 @@ func TestElasticsearchFromConnStr(t *testing.T) {
insecure: false,
es: Elasticsearch{},
err: errors.New("invalid connection string: must include a service token"),
}, {
name: "http connection",
conn: "http://localhost:9200",
token: "my-token",
path: "",
insecure: false,
es: Elasticsearch{
Protocol: "http",
Hosts: []string{"localhost:9200"},
ServiceToken: "my-token",
},
err: nil,
}, {
name: "insecure https",
conn: "https://localhost:9200",
token: "my-token",
path: "",
insecure: true,
es: Elasticsearch{
Protocol: "https",
Hosts: []string{"localhost:9200"},
ServiceToken: "my-token",
TLS: &tlscommon.Config{
VerificationMode: tlscommon.VerifyNone,
},
},
err: nil,
}, {
name: "file schema",
conn: "file:///path/to/socket",
token: "my-token",
path: "",
insecure: false,
es: Elasticsearch{},
err: errors.New("invalid connection string: scheme must be http or https"),
}, {
name: "bad conn string",
conn: "http://local host",
token: "my-token",
path: "",
insecure: false,
es: Elasticsearch{},
err: errors.New("parse \"http://local host\": invalid character \" \" in host name"),
}}

for _, tc := range testcases {
Expand Down