Skip to content

Commit

Permalink
Merge pull request #3211 from marsteg/issue-3210
Browse files Browse the repository at this point in the history
added fix to allow usage of uppercase letters
  • Loading branch information
georgethebeatle authored Apr 11, 2024
2 parents 0500fc1 + 318e022 commit e26bae2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion controllers/controllers/networking/cfroute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func generateServiceName(destination korifiv1alpha1.Destination) string {
}

func buildFQDN(cfRoute *korifiv1alpha1.CFRoute, cfDomain *korifiv1alpha1.CFDomain) string {
return fmt.Sprintf("%s.%s", cfRoute.Spec.Host, cfDomain.Spec.Name)
return fmt.Sprintf("%s.%s", strings.ToLower(cfRoute.Spec.Host), cfDomain.Spec.Name)
}

func toBackendRefs(destinations []korifiv1alpha1.Destination) []gatewayv1beta1.HTTPBackendRef {
Expand Down
13 changes: 13 additions & 0 deletions controllers/controllers/networking/cfroute_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,19 @@ var _ = Describe("CFRouteReconciler Integration Tests", func() {
})
})

When("the route's host contains upper case characters", func() {
BeforeEach(func() {
cfRoute.Spec.Host = "Test-Route"
})

It("uses the lowercased host in the httproute name and path match prefix", func() {
httpRoute := getHTTPRoute()
Expect(httpRoute.Spec.Hostnames).To(HaveLen(1))
Expect(httpRoute.Spec.Hostnames).To(HaveCap(1))
Expect(httpRoute.Spec.Hostnames[0]).To(Equal(gatewayv1beta1.Hostname("test-route.") + gatewayv1.Hostname(cfDomain.Spec.Name)))
})
})

It("creates a service for the destination", func() {
serviceName := fmt.Sprintf("s-%s", cfRoute.Spec.Destinations[0].GUID)
Eventually(func(g Gomega) {
Expand Down
1 change: 1 addition & 0 deletions controllers/webhooks/networking/cfroute_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ func validateFQDN(host, domain string) error {
}.ExportJSONError()
}

host = strings.ToLower(host)
err := validateHost(host)
if err != nil {
return webhooks.ValidationError{
Expand Down
4 changes: 2 additions & 2 deletions controllers/webhooks/networking/cfroute_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ var _ = Describe("CFRouteValidator", func() {

When("the host is invalid", func() {
BeforeEach(func() {
cfRoute.Spec.Host = "inVAlidnAme"
cfRoute.Spec.Host = "inVAl!dnAme?"
})

It("denies the request", func() {
Expect(retErr).To(matchers.BeValidationError(
networking.RouteHostNameValidationErrorType,
ContainSubstring("Host \"inVAlidnAme\" is not valid"),
ContainSubstring("Host \"inval!dname?\" is not valid"),
))
})
})
Expand Down

0 comments on commit e26bae2

Please sign in to comment.