Skip to content

Commit

Permalink
add and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersonQ committed Nov 7, 2024
1 parent 5c667b9 commit 93abbc2
Showing 1 changed file with 40 additions and 16 deletions.
56 changes: 40 additions & 16 deletions kibana/fleet_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,25 +447,49 @@ func TestCreateFleetProxy(t *testing.T) {
client, err := NewClientWithConfig(&cfg, "", "", "", "")
require.NoError(t, err)

id := uuid.Must(uuid.NewV4()).String()
req := ProxiesRequest{
ID: "CreateFleetServerHosts" + id,
Name: "CreateFleetServerHosts" + id,
URL: "https://proxy.elastic.co",
CertificateAuthorities: "some CA",
Certificate: "some certificate",
CertificateKey: "some certificate key",
IsPreconfigured: true,
ProxyHeaders: map[string]string{
"h1": "v1",
"h2": "v2",
tcs := []struct {
Name string
Req ProxiesRequest
}{
{
Name: "nil ProxyHeaders",
Req: ProxiesRequest{
ID: "CreateFleetServerHosts",
Name: "CreateFleetServerHosts",
URL: "https://proxy.elastic.co",
CertificateAuthorities: "some CA",
Certificate: "some certificate",
CertificateKey: "some certificate key",
},
},
{
Name: "with ProxyHeaders",
Req: ProxiesRequest{
ID: "CreateFleetServerHosts",
Name: "CreateFleetServerHosts",
URL: "https://proxy.elastic.co",
CertificateAuthorities: "some CA",
Certificate: "some certificate",
CertificateKey: "some certificate key",
ProxyHeaders: map[string]string{
"h1": "v1",
"h2": "v2",
},
},
},
}
got, err := client.CreateFleetProxy(ctx, req)
require.NoError(t, err, "error creating new fleet host")

require.Equal(t, req.ID, got.Item.ID)
require.Equal(t, req, got.Item)
for _, tc := range tcs {
id := uuid.Must(uuid.NewV4()).String()
tc.Req.ID += id
tc.Req.Name += id

got, err := client.CreateFleetProxy(ctx, tc.Req)
require.NoError(t, err, "error creating new fleet host")

require.Equal(t, tc.Req.ID, got.Item.ID)
require.Equal(t, tc.Req, got.Item)
}
}

func TestGetFleetServerHost(t *testing.T) {
Expand Down

0 comments on commit 93abbc2

Please sign in to comment.