From 93abbc2b8a25581a39d8cde67cc1676ac660f9c2 Mon Sep 17 00:00:00 2001 From: Anderson Queiroz Date: Thu, 7 Nov 2024 16:41:26 +0100 Subject: [PATCH] add and fix test --- kibana/fleet_integration_test.go | 56 +++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/kibana/fleet_integration_test.go b/kibana/fleet_integration_test.go index ca4145e..17838f7 100644 --- a/kibana/fleet_integration_test.go +++ b/kibana/fleet_integration_test.go @@ -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) {