diff --git a/internal/dag/httpproxy_processor.go b/internal/dag/httpproxy_processor.go index a0ede5f154a..377132d928e 100644 --- a/internal/dag/httpproxy_processor.go +++ b/internal/dag/httpproxy_processor.go @@ -705,7 +705,8 @@ func (p *HTTPProxyProcessor) validHTTPProxies() []*contour_api_v1.HTTPProxy { valid = append(valid, proxy) continue } - fqdnHTTPProxies[proxy.Spec.VirtualHost.Fqdn] = append(fqdnHTTPProxies[proxy.Spec.VirtualHost.Fqdn], proxy) + fqdn := strings.ToLower(proxy.Spec.VirtualHost.Fqdn) + fqdnHTTPProxies[fqdn] = append(fqdnHTTPProxies[fqdn], proxy) } for fqdn, proxies := range fqdnHTTPProxies { diff --git a/internal/dag/status_test.go b/internal/dag/status_test.go index 91dde118dcd..5dc7ceac86d 100644 --- a/internal/dag/status_test.go +++ b/internal/dag/status_test.go @@ -810,6 +810,24 @@ func TestDAGStatus(t *testing.T) { }, } + proxyValidReuseCaseExampleCom := &contour_api_v1.HTTPProxy{ + ObjectMeta: metav1.ObjectMeta{ + Name: "case-example", + Namespace: "roots", + }, + Spec: contour_api_v1.HTTPProxySpec{ + VirtualHost: &contour_api_v1.VirtualHost{ + Fqdn: "EXAMPLE.com", + }, + Routes: []contour_api_v1.Route{{ + Services: []contour_api_v1.Service{{ + Name: "kuard", + Port: 8080, + }}, + }}, + }, + } + run(t, "conflicting proxies due to fqdn reuse", testcase{ objs: []interface{}{proxyValidExampleCom, proxyValidReuseExampleCom}, want: map[types.NamespacedName]contour_api_v1.DetailedCondition{ @@ -822,6 +840,18 @@ func TestDAGStatus(t *testing.T) { }, }) + run(t, "conflicting proxies due to fqdn reuse with uppercase/lowercase", testcase{ + objs: []interface{}{proxyValidExampleCom, proxyValidReuseCaseExampleCom}, + want: map[types.NamespacedName]contour_api_v1.DetailedCondition{ + {Name: proxyValidExampleCom.Name, Namespace: proxyValidExampleCom.Namespace}: fixture.NewValidCondition(). + WithGeneration(proxyValidExampleCom.Generation). + WithError(contour_api_v1.ConditionTypeVirtualHostError, "DuplicateVhost", `fqdn "example.com" is used in multiple HTTPProxies: roots/case-example, roots/example-com`), + {Name: proxyValidReuseCaseExampleCom.Name, Namespace: proxyValidReuseCaseExampleCom.Namespace}: fixture.NewValidCondition(). + WithGeneration(proxyValidReuseCaseExampleCom.Generation). + WithError(contour_api_v1.ConditionTypeVirtualHostError, "DuplicateVhost", `fqdn "example.com" is used in multiple HTTPProxies: roots/case-example, roots/example-com`), + }, + }) + proxyRootIncludesRoot := &contour_api_v1.HTTPProxy{ ObjectMeta: metav1.ObjectMeta{ Name: "root-blog",