From e74820f4db34f2557fe8f9790e1eee4530f92677 Mon Sep 17 00:00:00 2001 From: Guillaume LEGRAIN Date: Thu, 4 Jul 2024 16:57:12 +0200 Subject: [PATCH] test: correct address as a list --- pkg/envoy/boilerplate_test.go | 2 +- pkg/envoy/configurator_test.go | 12 ++++++------ pkg/envoy/ingress_translator_test.go | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/envoy/boilerplate_test.go b/pkg/envoy/boilerplate_test.go index 42779e7..27e8ffb 100644 --- a/pkg/envoy/boilerplate_test.go +++ b/pkg/envoy/boilerplate_test.go @@ -77,7 +77,7 @@ func TestAccessLoggerConfig(t *testing.T) { cfg.Format = tc.format } - fileAccessLog := makeFileAccessLog(cfg) + fileAccessLog := makeFileAccessLog(cfg, "/var/log/envoy/") if fileAccessLog.Path != "/var/log/envoy/access.log" { t.Errorf("Expected access log to use default path but was, %s", fileAccessLog.Path) } diff --git a/pkg/envoy/configurator_test.go b/pkg/envoy/configurator_test.go index 9727829..a69a0ca 100644 --- a/pkg/envoy/configurator_test.go +++ b/pkg/envoy/configurator_test.go @@ -52,7 +52,7 @@ func TestGenerate(t *testing.T) { configurator := NewKubernetesConfigurator("a", []Certificate{ {Hosts: []string{"*"}, Cert: "b", Key: "c"}, - }, "d", []string{"bar"}, "/var/log/envoy/") + }, "d", []string{"bar"}, "/var/log/envoy/", func(c *KubernetesConfigurator) { c.envoyListenerIpv4Address = []string{"1.1.1.1"} }) snapshot, _ := configurator.Generate(ingresses, []*v1.Secret{}) @@ -73,7 +73,7 @@ func TestGenerateMultipleCerts(t *testing.T) { configurator := NewKubernetesConfigurator("a", []Certificate{ {Hosts: []string{"*.internal.api.com"}, Cert: "com", Key: "com"}, {Hosts: []string{"*.internal.api.co.uk"}, Cert: "couk", Key: "couk"}, - }, "d", []string{"bar"}, "/var/log/envoy/") + }, "d", []string{"bar"}, "/var/log/envoy/", func(c *KubernetesConfigurator) { c.envoyListenerIpv4Address = []string{"1.1.1.1"} }) snapshot, err := configurator.Generate(ingresses, []*v1.Secret{}) if err != nil { @@ -98,7 +98,7 @@ func TestGenerateMultipleHosts(t *testing.T) { configurator := NewKubernetesConfigurator("a", []Certificate{ {Hosts: []string{"*.internal.api.com", "*.internal.api.co.uk"}, Cert: "com", Key: "com"}, - }, "d", []string{"bar"}, "/var/log/envoy/") + }, "d", []string{"bar"}, "/var/log/envoy/", func(c *KubernetesConfigurator) { c.envoyListenerIpv4Address = []string{"1.1.1.1"} }) snapshot, err := configurator.Generate(ingresses, []*v1.Secret{}) if err != nil { @@ -123,7 +123,7 @@ func TestGenerateNoMatchingCert(t *testing.T) { configurator := NewKubernetesConfigurator("a", []Certificate{ {Hosts: []string{"*.internal.api.com"}, Cert: "com", Key: "com"}, - }, "d", []string{"bar"}, "/var/log/envoy/") + }, "d", []string{"bar"}, "/var/log/envoy/", func(c *KubernetesConfigurator) { c.envoyListenerIpv4Address = []string{"1.1.1.1"} }) snapshot, err := configurator.Generate(ingresses, []*v1.Secret{}) if err != nil { @@ -145,7 +145,7 @@ func TestGenerateIntoTwoCerts(t *testing.T) { configurator := NewKubernetesConfigurator("a", []Certificate{ {Hosts: []string{"*.internal.api.com"}, Cert: "com", Key: "com"}, {Hosts: []string{"*"}, Cert: "all", Key: "all"}, - }, "d", []string{"bar"}, "/var/log/envoy/") + }, "d", []string{"bar"}, "/var/log/envoy/", func(c *KubernetesConfigurator) { c.envoyListenerIpv4Address = []string{"1.1.1.1"} }) snapshot, err := configurator.Generate(ingresses, []*v1.Secret{}) if err != nil { @@ -218,7 +218,7 @@ func TestGenerateListeners(t *testing.T) { } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { - configurator := NewKubernetesConfigurator("a", tc.certs, "", nil, "/var/log/envoy/") + configurator := NewKubernetesConfigurator("a", tc.certs, "", nil, "/var/log/envoy/", func(c *KubernetesConfigurator) { c.envoyListenerIpv4Address = []string{"1.1.1.1"} }) ret, err := configurator.generateListeners(&envoyConfiguration{VirtualHosts: tc.virtualHost}) if err != nil { t.Fatalf("Error generating listeners %v", err) diff --git a/pkg/envoy/ingress_translator_test.go b/pkg/envoy/ingress_translator_test.go index 72d69bf..94322c1 100644 --- a/pkg/envoy/ingress_translator_test.go +++ b/pkg/envoy/ingress_translator_test.go @@ -334,10 +334,10 @@ func TestGeneratesForMultipleIngressSharingSpecHost(t *testing.T) { t.Errorf("expected 2 host, was %d", len(c.Clusters[0].Hosts)) } if c.Clusters[0].Hosts[0].Host != "foo.com" { - t.Errorf("expected cluster host for foo.com, was %s", c.Clusters[0].Hosts[0]) + t.Errorf("expected cluster host for foo.com, was %v", c.Clusters[0].Hosts[0]) } if c.Clusters[0].Hosts[1].Host != "bar.com" { - t.Errorf("expected cluster host for bar.com, was %s", c.Clusters[0].Hosts[1]) + t.Errorf("expected cluster host for bar.com, was %v", c.Clusters[0].Hosts[1]) } if c.VirtualHosts[0].UpstreamCluster != c.Clusters[0].Name { @@ -375,7 +375,7 @@ func TestIngressWithIP(t *testing.T) { } c := translateIngresses([]*k8s.Ingress{ingress}, false, []*v1.Secret{}, timeouts, "/var/log/envoy/") if c.Clusters[0].Hosts[0].Host != "127.0.0.1" { - t.Errorf("expected cluster host to be IP address, was %s", c.Clusters[0].Hosts[0]) + t.Errorf("expected cluster host to be IP address, was %v", c.Clusters[0].Hosts[0]) } }