@@ -223,7 +223,65 @@ func (s) TestValidateCluster_Success(t *testing.T) {
223223 }
224224}
225225
226+ func (s ) TestValidateClusterWithSecurityConfig_EnvVarOff (t * testing.T ) {
227+ // Turn off the env var protection for client-side security.
228+ origClientSideSecurityEnvVar := env .ClientSideSecuritySupport
229+ env .ClientSideSecuritySupport = false
230+ defer func () { env .ClientSideSecuritySupport = origClientSideSecurityEnvVar }()
231+
232+ cluster := & v3clusterpb.Cluster {
233+ ClusterDiscoveryType : & v3clusterpb.Cluster_Type {Type : v3clusterpb .Cluster_EDS },
234+ EdsClusterConfig : & v3clusterpb.Cluster_EdsClusterConfig {
235+ EdsConfig : & v3corepb.ConfigSource {
236+ ConfigSourceSpecifier : & v3corepb.ConfigSource_Ads {
237+ Ads : & v3corepb.AggregatedConfigSource {},
238+ },
239+ },
240+ ServiceName : serviceName ,
241+ },
242+ LbPolicy : v3clusterpb .Cluster_ROUND_ROBIN ,
243+ TransportSocket : & v3corepb.TransportSocket {
244+ Name : "envoy.transport_sockets.tls" ,
245+ ConfigType : & v3corepb.TransportSocket_TypedConfig {
246+ TypedConfig : & anypb.Any {
247+ TypeUrl : version .V3UpstreamTLSContextURL ,
248+ Value : func () []byte {
249+ tls := & v3tlspb.UpstreamTlsContext {
250+ CommonTlsContext : & v3tlspb.CommonTlsContext {
251+ ValidationContextType : & v3tlspb.CommonTlsContext_ValidationContextCertificateProviderInstance {
252+ ValidationContextCertificateProviderInstance : & v3tlspb.CommonTlsContext_CertificateProviderInstance {
253+ InstanceName : "rootInstance" ,
254+ CertificateName : "rootCert" ,
255+ },
256+ },
257+ },
258+ }
259+ mtls , _ := proto .Marshal (tls )
260+ return mtls
261+ }(),
262+ },
263+ },
264+ },
265+ }
266+ wantUpdate := ClusterUpdate {
267+ ServiceName : serviceName ,
268+ EnableLRS : false ,
269+ }
270+ gotUpdate , err := validateCluster (cluster )
271+ if err != nil {
272+ t .Errorf ("validateCluster() failed: %v" , err )
273+ }
274+ if diff := cmp .Diff (wantUpdate , gotUpdate ); diff != "" {
275+ t .Errorf ("validateCluster() returned unexpected diff (-want, got):\n %s" , diff )
276+ }
277+ }
278+
226279func (s ) TestValidateClusterWithSecurityConfig (t * testing.T ) {
280+ // Turn on the env var protection for client-side security.
281+ origClientSideSecurityEnvVar := env .ClientSideSecuritySupport
282+ env .ClientSideSecuritySupport = true
283+ defer func () { env .ClientSideSecuritySupport = origClientSideSecurityEnvVar }()
284+
227285 const (
228286 identityPluginInstance = "identityPluginInstance"
229287 identityCertName = "identityCert"
0 commit comments