diff --git a/test/cel-validation/envoyproxy_test.go b/test/cel-validation/envoyproxy_test.go index 99912faff16..1d029655f7c 100644 --- a/test/cel-validation/envoyproxy_test.go +++ b/test/cel-validation/envoyproxy_test.go @@ -122,7 +122,7 @@ func TestEnvoyProxyProvider(t *testing.T) { wantErrors: []string{"allocateLoadBalancerNodePorts can only be set for LoadBalancer type"}, }, { - desc: "loadBalancerIP-pass-case1", + desc: "ServiceTypeLoadBalancer-with-valid-IP", mutate: func(envoy *egv1a1.EnvoyProxy) { envoy.Spec = egv1a1.EnvoyProxySpec{ Provider: &egv1a1.EnvoyProxyProvider{ @@ -139,14 +139,14 @@ func TestEnvoyProxyProvider(t *testing.T) { wantErrors: []string{}, }, { - desc: "loadBalancerIP-pass-case2", + desc: "ServiceTypeLoadBalancer-with-empty-IP", mutate: func(envoy *egv1a1.EnvoyProxy) { envoy.Spec = egv1a1.EnvoyProxySpec{ Provider: &egv1a1.EnvoyProxyProvider{ Type: egv1a1.ProviderTypeKubernetes, Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{ EnvoyService: &egv1a1.KubernetesServiceSpec{ - Type: ptr.To(egv1a1.ServiceTypeClusterIP), + Type: ptr.To(egv1a1.ServiceTypeLoadBalancer), }, }, }, @@ -155,38 +155,54 @@ func TestEnvoyProxyProvider(t *testing.T) { wantErrors: []string{}, }, { - desc: "loadBalancerIP-fail-case1", + desc: "ServiceTypeLoadBalancer-with-invalid-IP", mutate: func(envoy *egv1a1.EnvoyProxy) { envoy.Spec = egv1a1.EnvoyProxySpec{ Provider: &egv1a1.EnvoyProxyProvider{ Type: egv1a1.ProviderTypeKubernetes, Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{ EnvoyService: &egv1a1.KubernetesServiceSpec{ - Type: ptr.To(egv1a1.ServiceTypeClusterIP), + Type: ptr.To(egv1a1.ServiceTypeLoadBalancer), LoadBalancerIP: ptr.To("a.b.c.d"), }, }, }, } }, - wantErrors: []string{"loadBalancerIP can only be set for LoadBalancer type"}, + wantErrors: []string{"loadBalancerIP must be a valid IPv4 address"}, }, { - desc: "loadBalancerIP-fail-case2", + desc: "ServiceTypeClusterIP-with-empty-IP", mutate: func(envoy *egv1a1.EnvoyProxy) { envoy.Spec = egv1a1.EnvoyProxySpec{ Provider: &egv1a1.EnvoyProxyProvider{ Type: egv1a1.ProviderTypeKubernetes, Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{ EnvoyService: &egv1a1.KubernetesServiceSpec{ - Type: ptr.To(egv1a1.ServiceTypeLoadBalancer), - LoadBalancerIP: ptr.To("a.b.c.d"), + Type: ptr.To(egv1a1.ServiceTypeClusterIP), }, }, }, } }, - wantErrors: []string{"loadBalancerIP must be a valid IPv4 address"}, + wantErrors: []string{}, + }, + { + desc: "ServiceTypeClusterIP-with-LoadBalancerIP", + mutate: func(envoy *egv1a1.EnvoyProxy) { + envoy.Spec = egv1a1.EnvoyProxySpec{ + Provider: &egv1a1.EnvoyProxyProvider{ + Type: egv1a1.ProviderTypeKubernetes, + Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{ + EnvoyService: &egv1a1.KubernetesServiceSpec{ + Type: ptr.To(egv1a1.ServiceTypeClusterIP), + LoadBalancerIP: ptr.To("20.205.243.166"), // github ip for test only + }, + }, + }, + } + }, + wantErrors: []string{"loadBalancerIP can only be set for LoadBalancer type"}, }, }