Skip to content

Commit

Permalink
test: correct address as a list
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulKyu committed Jul 4, 2024
1 parent e7d67d6 commit e74820f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/envoy/boilerplate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/envoy/configurator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})

Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pkg/envoy/ingress_translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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])
}
}

Expand Down

0 comments on commit e74820f

Please sign in to comment.