mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 10:48:15 +00:00
Fixing EndpointSlice port validation
This updates EndpointSlice port validation to mirror the validation already in use for Service and Endpoint ports. This is required to ensure all valid Service ports can be mapped directly to EndpointSlice ports.
This commit is contained in:
@@ -18,6 +18,7 @@ package validation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -104,6 +105,20 @@ func TestValidateEndpointSlice(t *testing.T) {
|
||||
}},
|
||||
},
|
||||
},
|
||||
"long-port-name": {
|
||||
expectedErrors: 0,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr(strings.Repeat("a", 63)),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateIPAddresses(1),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"empty-ports-and-endpoints": {
|
||||
expectedErrors: 0,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
@@ -200,6 +215,18 @@ func TestValidateEndpointSlice(t *testing.T) {
|
||||
Endpoints: []discovery.Endpoint{},
|
||||
},
|
||||
},
|
||||
"bad-port-name-length": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr(strings.Repeat("a", 64)),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{},
|
||||
},
|
||||
},
|
||||
"invalid-port-protocol": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
|
||||
Reference in New Issue
Block a user