diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index 2a5445b75c7..5c14b83d43b 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -610,7 +610,7 @@ func validatePorts(ports []api.ContainerPort) errs.ValidationErrorList { } if len(port.Protocol) == 0 { pErrs = append(pErrs, errs.NewFieldRequired("protocol")) - } else if !supportedPortProtocols.Has(strings.ToUpper(string(port.Protocol))) { + } else if !supportedPortProtocols.Has(string(port.Protocol)) { pErrs = append(pErrs, errs.NewFieldNotSupported("protocol", port.Protocol)) } allErrs = append(allErrs, pErrs.PrefixIndex(i)...) @@ -1144,7 +1144,7 @@ func validateServicePort(sp *api.ServicePort, requireName bool, allNames *util.S if len(sp.Protocol) == 0 { allErrs = append(allErrs, errs.NewFieldRequired("protocol")) - } else if !supportedPortProtocols.Has(strings.ToUpper(string(sp.Protocol))) { + } else if !supportedPortProtocols.Has(string(sp.Protocol)) { allErrs = append(allErrs, errs.NewFieldNotSupported("protocol", sp.Protocol)) } @@ -1680,7 +1680,7 @@ func validateEndpointPort(port *api.EndpointPort, requireName bool) errs.Validat } if len(port.Protocol) == 0 { allErrs = append(allErrs, errs.NewFieldRequired("protocol")) - } else if !supportedPortProtocols.Has(strings.ToUpper(string(port.Protocol))) { + } else if !supportedPortProtocols.Has(string(port.Protocol)) { allErrs = append(allErrs, errs.NewFieldNotSupported("protocol", port.Protocol)) } return allErrs diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index ea841e5680b..9ba9a0f14f1 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -493,7 +493,6 @@ func TestValidatePorts(t *testing.T) { {Name: "easy", ContainerPort: 82, Protocol: "TCP"}, {Name: "as", ContainerPort: 83, Protocol: "UDP"}, {Name: "do-re-me", ContainerPort: 84, Protocol: "UDP"}, - {Name: "baby-you-and-me", ContainerPort: 82, Protocol: "tcp"}, {ContainerPort: 85, Protocol: "TCP"}, } if errs := validatePorts(successCase); len(errs) != 0 { @@ -522,6 +521,7 @@ func TestValidatePorts(t *testing.T) { "zero container port": {[]api.ContainerPort{{ContainerPort: 0, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].containerPort", portRangeErrorMsg}, "invalid container port": {[]api.ContainerPort{{ContainerPort: 65536, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].containerPort", portRangeErrorMsg}, "invalid host port": {[]api.ContainerPort{{ContainerPort: 80, HostPort: 65536, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].hostPort", portRangeErrorMsg}, + "invalid protocol case": {[]api.ContainerPort{{ContainerPort: 80, Protocol: "tcp"}}, errors.ValidationErrorTypeNotSupported, "[0].protocol", ""}, "invalid protocol": {[]api.ContainerPort{{ContainerPort: 80, Protocol: "ICMP"}}, errors.ValidationErrorTypeNotSupported, "[0].protocol", ""}, "protocol required": {[]api.ContainerPort{{Name: "abc", ContainerPort: 80}}, errors.ValidationErrorTypeRequired, "[0].protocol", ""}, } diff --git a/test/e2e/dns.go b/test/e2e/dns.go index f527f39f9db..3c941995770 100644 --- a/test/e2e/dns.go +++ b/test/e2e/dns.go @@ -18,6 +18,9 @@ package e2e import ( "fmt" + "strings" + "time" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" @@ -25,8 +28,6 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait" - "strings" - "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -237,7 +238,7 @@ var _ = Describe("DNS", func() { Spec: api.ServiceSpec{ ClusterIP: "None", Ports: []api.ServicePort{ - {Port: 80, Name: "http", Protocol: "tcp"}, + {Port: 80, Name: "http", Protocol: "TCP"}, }, Selector: testServiceSelector, }, @@ -257,7 +258,7 @@ var _ = Describe("DNS", func() { }, Spec: api.ServiceSpec{ Ports: []api.ServicePort{ - {Port: 80, Name: "http", Protocol: "tcp"}, + {Port: 80, Name: "http", Protocol: "TCP"}, }, Selector: testServiceSelector, },