@@ -223,7 +223,65 @@ func (s) TestValidateCluster_Success(t *testing.T) {
223
223
}
224
224
}
225
225
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
+
226
279
func (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
+
227
285
const (
228
286
identityPluginInstance = "identityPluginInstance"
229
287
identityCertName = "identityCert"
0 commit comments