-
Notifications
You must be signed in to change notification settings - Fork 621
Webhook: validate the combination of port, protocol, and hostname are unique for each listener. #1457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webhook: validate the combination of port, protocol, and hostname are unique for each listener. #1457
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,14 +136,37 @@ func TestValidateGateway(t *testing.T) { | |
| }, | ||
| "names are not unique within the Gateway": { | ||
| mutate: func(gw *gatewayv1b1.Gateway) { | ||
| hostnameFoo := gatewayv1b1.Hostname("foo.com") | ||
| hostnameBar := gatewayv1b1.Hostname("bar.com") | ||
| gw.Spec.Listeners[0].Name = "foo" | ||
| gw.Spec.Listeners = append(gw.Spec.Listeners, gatewayv1b1.Listener{ | ||
| Name: "foo", | ||
| }, | ||
| gw.Spec.Listeners[0].Hostname = &hostnameFoo | ||
| gw.Spec.Listeners = append(gw.Spec.Listeners, | ||
| gatewayv1b1.Listener{ | ||
| Name: "foo", | ||
| Hostname: &hostnameBar, | ||
| }, | ||
| ) | ||
| }, | ||
| expectErrsOnFields: []string{"spec.listeners[1].name"}, | ||
| }, | ||
| "combination of port, protocol, and name are not unique for each listener": { | ||
| mutate: func(gw *gatewayv1b1.Gateway) { | ||
| hostnameFoo := gatewayv1b1.Hostname("foo.com") | ||
| gw.Spec.Listeners[0].Name = "foo" | ||
| gw.Spec.Listeners[0].Hostname = &hostnameFoo | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since hostname is optional can you add one more test case that shows that the same setup fails when both listeners have separate hostnames?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, it would be helpful to have additional test cases where everything was the same except for one of the fields (port, protocol, or hostname) to ensure those are all still valid.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do you mean to test the combination of port and protocol are unique when hostnames not set? If yes, I've add one: d75ab56#diff-e3c0a139e14037364db162e955588e8153e795f4cbe84b6fce32149d62ca2a73R170-R184
Updated, thank you! |
||
| gw.Spec.Listeners[0].Protocol = gatewayv1b1.HTTPProtocolType | ||
| gw.Spec.Listeners[0].Port = 80 | ||
| gw.Spec.Listeners = append(gw.Spec.Listeners, | ||
| gatewayv1b1.Listener{ | ||
| Name: "bar", | ||
| Hostname: &hostnameFoo, | ||
| Protocol: gatewayv1b1.HTTPProtocolType, | ||
| Port: 80, | ||
| }, | ||
| ) | ||
| }, | ||
| expectErrsOnFields: []string{"spec.listeners[1]"}, | ||
| }, | ||
| } | ||
|
|
||
| for name, tc := range testCases { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.