diff --git a/internal/testutils/marshal_any.go b/internal/testutils/marshal_any.go index 9ddef6de15d6..c84096eb2548 100644 --- a/internal/testutils/marshal_any.go +++ b/internal/testutils/marshal_any.go @@ -18,19 +18,21 @@ package testutils import ( - "fmt" + "testing" "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" + "google.golang.org/protobuf/protoadapt" "google.golang.org/protobuf/types/known/anypb" ) // MarshalAny is a convenience function to marshal protobuf messages into any -// protos. It will panic if the marshaling fails. -func MarshalAny(m proto.Message) *anypb.Any { - a, err := ptypes.MarshalAny(m) +// protos. function will fail the test with a fatal error if the marshaling fails. +func MarshalAny(t *testing.T, m proto.Message) *anypb.Any { + t.Helper() + + a, err := anypb.New(protoadapt.MessageV2Of(m)) if err != nil { - panic(fmt.Sprintf("ptypes.MarshalAny(%+v) failed: %v", m, err)) + t.Fatalf("Failed to marshal proto %+v into an Any: %v", m, err) } return a } diff --git a/internal/testutils/xds/e2e/clientresources.go b/internal/testutils/xds/e2e/clientresources.go index 7bf4151b6c4c..dc3b592b2c48 100644 --- a/internal/testutils/xds/e2e/clientresources.go +++ b/internal/testutils/xds/e2e/clientresources.go @@ -23,9 +23,10 @@ import ( "net" "strconv" + "google.golang.org/protobuf/protoadapt" + "github.com/envoyproxy/go-control-plane/pkg/wellknown" "github.com/golang/protobuf/proto" - "google.golang.org/grpc/internal/testutils" "google.golang.org/protobuf/types/known/anypb" v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" @@ -106,7 +107,7 @@ var RouterHTTPFilter = HTTPFilter("router", &v3routerpb.Router{}) // DefaultClientListener returns a basic xds Listener resource to be used on // the client side. func DefaultClientListener(target, routeName string) *v3listenerpb.Listener { - hcm := testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + hcm := marshalAny(&v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ ConfigSourceSpecifier: &v3corepb.ConfigSource_Ads{Ads: &v3corepb.AggregatedConfigSource{}}, @@ -128,6 +129,14 @@ func DefaultClientListener(target, routeName string) *v3listenerpb.Listener { } } +func marshalAny(m proto.Message) *anypb.Any { + a, err := anypb.New(protoadapt.MessageV2Of(m)) + if err != nil { + panic(fmt.Sprintf("anypb.New(%+v) failed: %v", m, err)) + } + return a +} + // DefaultServerListener returns a basic xds Listener resource to be used on // the server side. func DefaultServerListener(host string, port uint32, secLevel SecurityLevel) *v3listenerpb.Listener { @@ -163,7 +172,7 @@ func DefaultServerListener(host string, port uint32, secLevel SecurityLevel) *v3 ts = &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(tlsContext), + TypedConfig: marshalAny(tlsContext), }, } } @@ -205,7 +214,7 @@ func DefaultServerListener(host string, port uint32, secLevel SecurityLevel) *v3 { Name: "filter-1", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: marshalAny(&v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: &v3routepb.RouteConfiguration{ Name: "routeName", @@ -253,7 +262,7 @@ func DefaultServerListener(host string, port uint32, secLevel SecurityLevel) *v3 { Name: "filter-1", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: marshalAny(&v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: &v3routepb.RouteConfiguration{ Name: "routeName", @@ -285,7 +294,7 @@ func HTTPFilter(name string, config proto.Message) *v3httppb.HttpFilter { return &v3httppb.HttpFilter{ Name: name, ConfigType: &v3httppb.HttpFilter_TypedConfig{ - TypedConfig: testutils.MarshalAny(config), + TypedConfig: marshalAny(config), }, } } @@ -570,7 +579,7 @@ func ClusterResourceWithOptions(opts ClusterOptions) *v3clusterpb.Cluster { cluster.ClusterDiscoveryType = &v3clusterpb.Cluster_ClusterType{ ClusterType: &v3clusterpb.Cluster_CustomClusterType{ Name: "envoy.clusters.aggregate", - TypedConfig: testutils.MarshalAny(&v3aggregateclusterpb.ClusterConfig{ + TypedConfig: marshalAny(&v3aggregateclusterpb.ClusterConfig{ Clusters: opts.ChildNames, }), }, @@ -580,7 +589,7 @@ func ClusterResourceWithOptions(opts ClusterOptions) *v3clusterpb.Cluster { cluster.TransportSocket = &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(tlsContext), + TypedConfig: marshalAny(tlsContext), }, } } diff --git a/internal/xds/rbac/converter_test.go b/internal/xds/rbac/converter_test.go index 222e504d82c3..b920ed54d1f5 100644 --- a/internal/xds/rbac/converter_test.go +++ b/internal/xds/rbac/converter_test.go @@ -51,7 +51,7 @@ func (s) TestBuildLoggerErrors(t *testing.T) { loggerConfig: &v3rbacpb.RBAC_AuditLoggingOptions_AuditLoggerConfig{ AuditLogger: &v3corepb.TypedExtensionConfig{ Name: "TestAuditLoggerBuffer", - TypedConfig: testutils.MarshalAny(&v3rbacpb.RBAC_AuditLoggingOptions{}), + TypedConfig: testutils.MarshalAny(t, &v3rbacpb.RBAC_AuditLoggingOptions{}), }, }, expectedError: "custom config not implemented for type ", diff --git a/test/xds/xds_client_custom_lb_test.go b/test/xds/xds_client_custom_lb_test.go index b72686106c6d..e6f9de552cf3 100644 --- a/test/xds/xds_client_custom_lb_test.go +++ b/test/xds/xds_client_custom_lb_test.go @@ -55,13 +55,13 @@ import ( // wrrLocality is a helper that takes a proto message and returns a // WrrLocalityProto with the proto message marshaled into a proto.Any as a // child. -func wrrLocality(m proto.Message) *v3wrrlocalitypb.WrrLocality { +func wrrLocality(t *testing.T, m proto.Message) *v3wrrlocalitypb.WrrLocality { return &v3wrrlocalitypb.WrrLocality{ EndpointPickingPolicy: &v3clusterpb.LoadBalancingPolicy{ Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(m), + TypedConfig: testutils.MarshalAny(t, m), }, }, }, @@ -78,7 +78,7 @@ func clusterWithLBConfiguration(clusterName, edsServiceName string, secLevel e2e Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(m), + TypedConfig: testutils.MarshalAny(&testing.T{}, m), }, }, }, @@ -132,7 +132,7 @@ func (s) TestWrrLocality(t *testing.T) { }{ { name: "rr_child", - wrrLocalityConfiguration: wrrLocality(&v3roundrobinpb.RoundRobin{}), + wrrLocalityConfiguration: wrrLocality(t, &v3roundrobinpb.RoundRobin{}), // Each addresses expected probability is locality weight of // locality / total locality weights multiplied by 1 / number of // endpoints in each locality (due to round robin across endpoints @@ -157,7 +157,7 @@ func (s) TestWrrLocality(t *testing.T) { // (e.g. Address 1 for locality 1, and Address 3 for locality 2). { name: "custom_lb_child_pick_first", - wrrLocalityConfiguration: wrrLocality(&v3xdsxdstypepb.TypedStruct{ + wrrLocalityConfiguration: wrrLocality(t, &v3xdsxdstypepb.TypedStruct{ TypeUrl: "type.googleapis.com/pick_first", Value: &structpb.Struct{}, }), @@ -178,7 +178,7 @@ func (s) TestWrrLocality(t *testing.T) { // above. { name: "custom_lb_child_wrr/", - wrrLocalityConfiguration: wrrLocality(&v3clientsideweightedroundrobinpb.ClientSideWeightedRoundRobin{ + wrrLocalityConfiguration: wrrLocality(t, &v3clientsideweightedroundrobinpb.ClientSideWeightedRoundRobin{ EnableOobLoadReport: &wrapperspb.BoolValue{ Value: false, }, @@ -203,7 +203,7 @@ func (s) TestWrrLocality(t *testing.T) { }, { name: "custom_lb_least_request", - wrrLocalityConfiguration: wrrLocality(&v3leastrequestpb.LeastRequest{ + wrrLocalityConfiguration: wrrLocality(t, &v3leastrequestpb.LeastRequest{ ChoiceCount: wrapperspb.UInt32(2), }), // The test performs a Unary RPC, and blocks until the RPC returns, diff --git a/test/xds/xds_rls_clusterspecifier_plugin_test.go b/test/xds/xds_rls_clusterspecifier_plugin_test.go index bca198081a7c..26facc595e66 100644 --- a/test/xds/xds_rls_clusterspecifier_plugin_test.go +++ b/test/xds/xds_rls_clusterspecifier_plugin_test.go @@ -46,7 +46,7 @@ import ( // defaultClientResourcesWithRLSCSP returns a set of resources (LDS, RDS, CDS, EDS) for a // client to connect to a server with a RLS Load Balancer as a child of Cluster Manager. -func defaultClientResourcesWithRLSCSP(lb e2e.LoadBalancingPolicy, params e2e.ResourceParams, rlsProto *rlspb.RouteLookupConfig) e2e.UpdateOptions { +func defaultClientResourcesWithRLSCSP(t *testing.T, lb e2e.LoadBalancingPolicy, params e2e.ResourceParams, rlsProto *rlspb.RouteLookupConfig) e2e.UpdateOptions { routeConfigName := "route-" + params.DialTarget clusterName := "cluster-" + params.DialTarget endpointsName := "endpoints-" + params.DialTarget @@ -58,7 +58,7 @@ func defaultClientResourcesWithRLSCSP(lb e2e.LoadBalancingPolicy, params e2e.Res ListenerName: params.DialTarget, ClusterSpecifierType: e2e.RouteConfigClusterSpecifierTypeClusterSpecifierPlugin, ClusterSpecifierPluginName: "rls-csp", - ClusterSpecifierPluginConfig: testutils.MarshalAny(&rlspb.RouteLookupClusterSpecifier{ + ClusterSpecifierPluginConfig: testutils.MarshalAny(t, &rlspb.RouteLookupClusterSpecifier{ RouteLookupConfig: rlsProto, }), })}, @@ -127,7 +127,7 @@ func testRLSinxDS(t *testing.T, lbPolicy e2e.LoadBalancingPolicy) { } const serviceName = "my-service-client-side-xds" - resources := defaultClientResourcesWithRLSCSP(lbPolicy, e2e.ResourceParams{ + resources := defaultClientResourcesWithRLSCSP(t, lbPolicy, e2e.ResourceParams{ DialTarget: serviceName, NodeID: nodeID, Host: "localhost", diff --git a/test/xds/xds_security_config_nack_test.go b/test/xds/xds_security_config_nack_test.go index 1dc3250935bf..0d6003070674 100644 --- a/test/xds/xds_security_config_nack_test.go +++ b/test/xds/xds_security_config_nack_test.go @@ -53,7 +53,7 @@ func (s) TestUnmarshalListener_WithUpdateValidatorFunc(t *testing.T) { securityConfig: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ InstanceName: missingIdentityProviderInstance, @@ -76,7 +76,7 @@ func (s) TestUnmarshalListener_WithUpdateValidatorFunc(t *testing.T) { securityConfig: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ InstanceName: missingIdentityProviderInstance, @@ -99,7 +99,7 @@ func (s) TestUnmarshalListener_WithUpdateValidatorFunc(t *testing.T) { securityConfig: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ InstanceName: e2e.ServerSideCertProviderInstance, @@ -122,7 +122,7 @@ func (s) TestUnmarshalListener_WithUpdateValidatorFunc(t *testing.T) { securityConfig: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ InstanceName: e2e.ServerSideCertProviderInstance, @@ -227,7 +227,7 @@ func (s) TestUnmarshalCluster_WithUpdateValidatorFunc(t *testing.T) { securityConfig: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ InstanceName: missingIdentityProviderInstance, @@ -250,7 +250,7 @@ func (s) TestUnmarshalCluster_WithUpdateValidatorFunc(t *testing.T) { securityConfig: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ InstanceName: missingIdentityProviderInstance, @@ -273,7 +273,7 @@ func (s) TestUnmarshalCluster_WithUpdateValidatorFunc(t *testing.T) { securityConfig: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ InstanceName: e2e.ClientSideCertProviderInstance, @@ -296,7 +296,7 @@ func (s) TestUnmarshalCluster_WithUpdateValidatorFunc(t *testing.T) { securityConfig: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ InstanceName: e2e.ClientSideCertProviderInstance, diff --git a/test/xds/xds_server_rbac_test.go b/test/xds/xds_server_rbac_test.go index fa684104281b..0f44455981a9 100644 --- a/test/xds/xds_server_rbac_test.go +++ b/test/xds/xds_server_rbac_test.go @@ -189,7 +189,7 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) { { Name: "filter-1", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{e2e.HTTPFilter("router", &v3routerpb.Router{})}, RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: &v3routepb.RouteConfiguration{ @@ -227,7 +227,7 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) { { Name: "filter-1", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{e2e.HTTPFilter("router", &v3routerpb.Router{})}, RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: &v3routepb.RouteConfiguration{ @@ -299,7 +299,7 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) { // serverListenerWithRBACHTTPFilters returns an xds Listener resource with HTTP Filters defined in the HCM, and a route // configuration that always matches to a route and a VH. -func serverListenerWithRBACHTTPFilters(host string, port uint32, rbacCfg *rpb.RBAC) *v3listenerpb.Listener { +func serverListenerWithRBACHTTPFilters(t *testing.T, host string, port uint32, rbacCfg *rpb.RBAC) *v3listenerpb.Listener { // Rather than declare typed config inline, take a HCM proto and append the // RBAC Filters to it. hcm := &v3httppb.HttpConnectionManager{ @@ -317,7 +317,7 @@ func serverListenerWithRBACHTTPFilters(host string, port uint32, rbacCfg *rpb.RB // This tests override parsing + building when RBAC Filter // passed both normal and override config. TypedPerFilterConfig: map[string]*anypb.Any{ - "rbac": testutils.MarshalAny(&rpb.RBACPerRoute{Rbac: rbacCfg}), + "rbac": testutils.MarshalAny(t, &rpb.RBACPerRoute{Rbac: rbacCfg}), }, }}}, }, @@ -364,7 +364,7 @@ func serverListenerWithRBACHTTPFilters(host string, port uint32, rbacCfg *rpb.RB { Name: "filter-1", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(hcm), + TypedConfig: testutils.MarshalAny(t, hcm), }, }, }, @@ -394,7 +394,7 @@ func serverListenerWithRBACHTTPFilters(host string, port uint32, rbacCfg *rpb.RB { Name: "filter-1", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(hcm), + TypedConfig: testutils.MarshalAny(t, hcm), }, }, }, @@ -656,7 +656,7 @@ func (s) TestRBACHTTPFilter(t *testing.T) { Port: port, SecLevel: e2e.SecurityLevelNone, }) - inboundLis := serverListenerWithRBACHTTPFilters(host, port, test.rbacCfg) + inboundLis := serverListenerWithRBACHTTPFilters(t, host, port, test.rbacCfg) resources.Listeners = append(resources.Listeners, inboundLis) ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) @@ -712,7 +712,7 @@ func (s) TestRBACHTTPFilter(t *testing.T) { // serverListenerWithBadRouteConfiguration returns an xds Listener resource with // a Route Configuration that will never successfully match in order to test // RBAC Environment variable being toggled on and off. -func serverListenerWithBadRouteConfiguration(host string, port uint32) *v3listenerpb.Listener { +func serverListenerWithBadRouteConfiguration(t *testing.T, host string, port uint32) *v3listenerpb.Listener { return &v3listenerpb.Listener{ Name: fmt.Sprintf(e2e.ServerListenerResourceNameTemplate, net.JoinHostPort(host, strconv.Itoa(int(port)))), Address: &v3corepb.Address{ @@ -751,7 +751,7 @@ func serverListenerWithBadRouteConfiguration(host string, port uint32) *v3listen { Name: "filter-1", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: &v3routepb.RouteConfiguration{ Name: "routeName", @@ -799,7 +799,7 @@ func serverListenerWithBadRouteConfiguration(host string, port uint32) *v3listen { Name: "filter-1", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: &v3routepb.RouteConfiguration{ Name: "routeName", @@ -858,7 +858,7 @@ func (s) TestRBACToggledOn_WithBadRouteConfiguration(t *testing.T) { // Since RBAC support is turned ON, all the RPC's should get denied with // status code Unavailable due to not matching to a route of type Non // Forwarding Action (Route Table not configured properly). - inboundLis := serverListenerWithBadRouteConfiguration(host, port) + inboundLis := serverListenerWithBadRouteConfiguration(t, host, port) resources.Listeners = append(resources.Listeners, inboundLis) ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) @@ -915,7 +915,7 @@ func (s) TestRBACToggledOff_WithBadRouteConfiguration(t *testing.T) { // This bad route configuration shouldn't affect incoming RPC's from // proceeding as normal, as the configuration shouldn't be parsed due to the // RBAC Environment variable not being set to true. - inboundLis := serverListenerWithBadRouteConfiguration(host, port) + inboundLis := serverListenerWithBadRouteConfiguration(t, host, port) resources.Listeners = append(resources.Listeners, inboundLis) ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) diff --git a/xds/csds/csds_e2e_test.go b/xds/csds/csds_e2e_test.go index 481e93929fa2..2f328bc83414 100644 --- a/xds/csds/csds_e2e_test.go +++ b/xds/csds/csds_e2e_test.go @@ -192,19 +192,19 @@ func (s) TestCSDS(t *testing.T) { listenerAnys := make([]*anypb.Any, len(ldsTargets)) for i := range ldsTargets { listeners[i] = e2e.DefaultClientListener(ldsTargets[i], rdsTargets[i]) - listenerAnys[i] = testutils.MarshalAny(listeners[i]) + listenerAnys[i] = testutils.MarshalAny(t, listeners[i]) } routes := make([]*v3routepb.RouteConfiguration, len(rdsTargets)) routeAnys := make([]*anypb.Any, len(rdsTargets)) for i := range rdsTargets { routes[i] = e2e.DefaultRouteConfig(rdsTargets[i], ldsTargets[i], cdsTargets[i]) - routeAnys[i] = testutils.MarshalAny(routes[i]) + routeAnys[i] = testutils.MarshalAny(t, routes[i]) } clusters := make([]*v3clusterpb.Cluster, len(cdsTargets)) clusterAnys := make([]*anypb.Any, len(cdsTargets)) for i := range cdsTargets { clusters[i] = e2e.DefaultCluster(cdsTargets[i], edsTargets[i], e2e.SecurityLevelNone) - clusterAnys[i] = testutils.MarshalAny(clusters[i]) + clusterAnys[i] = testutils.MarshalAny(t, clusters[i]) } endpoints := make([]*v3endpointpb.ClusterLoadAssignment, len(edsTargets)) endpointAnys := make([]*anypb.Any, len(edsTargets)) @@ -212,7 +212,7 @@ func (s) TestCSDS(t *testing.T) { ports := []uint32{123, 456} for i := range edsTargets { endpoints[i] = e2e.DefaultEndpoint(edsTargets[i], ips[i], ports[i:i+1]) - endpointAnys[i] = testutils.MarshalAny(endpoints[i]) + endpointAnys[i] = testutils.MarshalAny(t, endpoints[i]) } // Register watches on the xDS client for two resources of each type. diff --git a/xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go b/xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go index 11a7d33ed523..109530105929 100644 --- a/xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go +++ b/xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go @@ -514,7 +514,7 @@ func (s) TestSecurityConfigUpdate_BadToGood(t *testing.T) { cluster.TransportSocket = &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_ValidationContextCertificateProviderInstance{ ValidationContextCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ @@ -681,7 +681,7 @@ func (s) TestSecurityConfigUpdate_GoodToBad(t *testing.T) { cluster.TransportSocket = &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_ValidationContextCertificateProviderInstance{ ValidationContextCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ diff --git a/xds/internal/clusterspecifier/rls/rls_test.go b/xds/internal/clusterspecifier/rls/rls_test.go index 0be52f4db406..3297aa83a9af 100644 --- a/xds/internal/clusterspecifier/rls/rls_test.go +++ b/xds/internal/clusterspecifier/rls/rls_test.go @@ -57,13 +57,60 @@ func (s) TestParseClusterSpecifierConfig(t *testing.T) { wantErr bool }{ { - name: "invalid-rls-cluster-specifier", - rlcs: rlsClusterSpecifierConfigError, + + // This will error because the required_match field is set in grpc key builder + name: "invalid-rls-cluster-specifier", + rlcs: testutils.MarshalAny(t, &rlspb.RouteLookupClusterSpecifier{ + RouteLookupConfig: &rlspb.RouteLookupConfig{ + GrpcKeybuilders: []*rlspb.GrpcKeyBuilder{ + { + Names: []*rlspb.GrpcKeyBuilder_Name{ + { + Service: "service", + Method: "method", + }, + }, + Headers: []*rlspb.NameMatcher{ + { + Key: "k1", + RequiredMatch: true, + Names: []string{"v1"}, + }, + }, + }, + }, + }, + }), wantErr: true, }, { - name: "valid-rls-cluster-specifier", - rlcs: rlsClusterSpecifierConfigWithoutTransformations, + name: "valid-rls-cluster-specifier", + rlcs: testutils.MarshalAny(t, &rlspb.RouteLookupClusterSpecifier{ + RouteLookupConfig: &rlspb.RouteLookupConfig{ + GrpcKeybuilders: []*rlspb.GrpcKeyBuilder{ + { + Names: []*rlspb.GrpcKeyBuilder_Name{ + { + Service: "service", + Method: "method", + }, + }, + Headers: []*rlspb.NameMatcher{ + { + Key: "k1", + Names: []string{"v1"}, + }, + }, + }, + }, + LookupService: "target", + LookupServiceTimeout: &durationpb.Duration{Seconds: 100}, + MaxAge: &durationpb.Duration{Seconds: 60}, + StaleAge: &durationpb.Duration{Seconds: 50}, + CacheSizeBytes: 1000, + DefaultTarget: "passthrough:///default", + }, + }), wantConfig: configWithoutTransformationsWant, }, } @@ -106,58 +153,6 @@ func (s) TestParseClusterSpecifierConfig(t *testing.T) { } } -// This will error because the required match field is set in grpc key builder. -var rlsClusterSpecifierConfigError = testutils.MarshalAny(&rlspb.RouteLookupClusterSpecifier{ - RouteLookupConfig: &rlspb.RouteLookupConfig{ - GrpcKeybuilders: []*rlspb.GrpcKeyBuilder{ - { - Names: []*rlspb.GrpcKeyBuilder_Name{ - { - Service: "service", - Method: "method", - }, - }, - Headers: []*rlspb.NameMatcher{ - { - Key: "k1", - RequiredMatch: true, - Names: []string{"v1"}, - }, - }, - }, - }, - }, -}) - -// Corresponds to the rls unit test case in -// balancer/rls/internal/config_test.go. -var rlsClusterSpecifierConfigWithoutTransformations = testutils.MarshalAny(&rlspb.RouteLookupClusterSpecifier{ - RouteLookupConfig: &rlspb.RouteLookupConfig{ - GrpcKeybuilders: []*rlspb.GrpcKeyBuilder{ - { - Names: []*rlspb.GrpcKeyBuilder_Name{ - { - Service: "service", - Method: "method", - }, - }, - Headers: []*rlspb.NameMatcher{ - { - Key: "k1", - Names: []string{"v1"}, - }, - }, - }, - }, - LookupService: "target", - LookupServiceTimeout: &durationpb.Duration{Seconds: 100}, - MaxAge: &durationpb.Duration{Seconds: 60}, - StaleAge: &durationpb.Duration{Seconds: 50}, - CacheSizeBytes: 1000, - DefaultTarget: "passthrough:///default", - }, -}) - var configWithoutTransformationsWant = clusterspecifier.BalancerConfig{{"rls_experimental": &lbConfigJSON{ RouteLookupConfig: []byte(`{"grpcKeybuilders":[{"names":[{"service":"service","method":"method"}],"headers":[{"key":"k1","names":["v1"]}]}],"lookupService":"target","lookupServiceTimeout":"100s","maxAge":"60s","staleAge":"50s","cacheSizeBytes":"1000","defaultTarget":"passthrough:///default"}`), ChildPolicy: []map[string]json.RawMessage{ diff --git a/xds/internal/httpfilter/fault/fault_test.go b/xds/internal/httpfilter/fault/fault_test.go index 48fac43c46d7..34300a419546 100644 --- a/xds/internal/httpfilter/fault/fault_test.go +++ b/xds/internal/httpfilter/fault/fault_test.go @@ -517,7 +517,7 @@ func (s) TestFaultInjection_Unary(t *testing.T) { hcm.HttpFilters = append(hcm.HttpFilters, e2e.HTTPFilter(fmt.Sprintf("fault%d", i), cfg)) } hcm.HttpFilters = append(hcm.HttpFilters, routerFilter) - hcmAny := testutils.MarshalAny(hcm) + hcmAny := testutils.MarshalAny(t, hcm) resources.Listeners[0].ApiListener.ApiListener = hcmAny resources.Listeners[0].FilterChains[0].Filters[0].ConfigType = &v3listenerpb.Filter_TypedConfig{TypedConfig: hcmAny} @@ -592,7 +592,7 @@ func (s) TestFaultInjection_MaxActiveFaults(t *testing.T) { }, })}, hcm.HttpFilters...) - hcmAny := testutils.MarshalAny(hcm) + hcmAny := testutils.MarshalAny(t, hcm) resources.Listeners[0].ApiListener.ApiListener = hcmAny resources.Listeners[0].FilterChains[0].Filters[0].ConfigType = &v3listenerpb.Filter_TypedConfig{TypedConfig: hcmAny} diff --git a/xds/internal/resolver/cluster_specifier_plugin_test.go b/xds/internal/resolver/cluster_specifier_plugin_test.go index 38ab9acf5b9f..d6186e9c137e 100644 --- a/xds/internal/resolver/cluster_specifier_plugin_test.go +++ b/xds/internal/resolver/cluster_specifier_plugin_test.go @@ -153,7 +153,7 @@ func (s) TestResolverClusterSpecifierPlugin(t *testing.T) { ListenerName: serviceName, ClusterSpecifierType: e2e.RouteConfigClusterSpecifierTypeClusterSpecifierPlugin, ClusterSpecifierPluginName: "cspA", - ClusterSpecifierPluginConfig: testutils.MarshalAny(&wrapperspb.StringValue{Value: "anything"}), + ClusterSpecifierPluginConfig: testutils.MarshalAny(t, &wrapperspb.StringValue{Value: "anything"}), })}, SkipValidation: true, } @@ -223,7 +223,7 @@ func (s) TestResolverClusterSpecifierPlugin(t *testing.T) { ListenerName: serviceName, ClusterSpecifierType: e2e.RouteConfigClusterSpecifierTypeClusterSpecifierPlugin, ClusterSpecifierPluginName: "cspA", - ClusterSpecifierPluginConfig: testutils.MarshalAny(&wrapperspb.StringValue{Value: "changed"}), + ClusterSpecifierPluginConfig: testutils.MarshalAny(t, &wrapperspb.StringValue{Value: "changed"}), })}, SkipValidation: true, } @@ -306,7 +306,7 @@ func (s) TestXDSResolverDelayedOnCommittedCSP(t *testing.T) { ListenerName: serviceName, ClusterSpecifierType: e2e.RouteConfigClusterSpecifierTypeClusterSpecifierPlugin, ClusterSpecifierPluginName: "cspA", - ClusterSpecifierPluginConfig: testutils.MarshalAny(&wrapperspb.StringValue{Value: "anythingA"}), + ClusterSpecifierPluginConfig: testutils.MarshalAny(t, &wrapperspb.StringValue{Value: "anythingA"}), })}, SkipValidation: true, } @@ -379,7 +379,7 @@ func (s) TestXDSResolverDelayedOnCommittedCSP(t *testing.T) { ListenerName: serviceName, ClusterSpecifierType: e2e.RouteConfigClusterSpecifierTypeClusterSpecifierPlugin, ClusterSpecifierPluginName: "cspB", - ClusterSpecifierPluginConfig: testutils.MarshalAny(&wrapperspb.StringValue{Value: "anythingB"}), + ClusterSpecifierPluginConfig: testutils.MarshalAny(t, &wrapperspb.StringValue{Value: "anythingB"}), })}, SkipValidation: true, } diff --git a/xds/internal/resolver/xds_resolver_test.go b/xds/internal/resolver/xds_resolver_test.go index 4e0782646f4c..621e9f5408a9 100644 --- a/xds/internal/resolver/xds_resolver_test.go +++ b/xds/internal/resolver/xds_resolver_test.go @@ -81,12 +81,14 @@ const ( var ( target = resolver.Target{URL: *testutils.MustParseURL("xds:///" + targetStr)} - - routerHTTPFilter = httpfilter.Get(router.TypeURL) - routerConfig, _ = routerHTTPFilter.ParseFilterConfig(testutils.MarshalAny(&v3routerpb.Router{})) - routerFilter = xdsresource.HTTPFilter{Name: "rtr", Filter: routerHTTPFilter, Config: routerConfig} ) +func makeRouterFilter(t *testing.T) xdsresource.HTTPFilter { + f := httpfilter.Get(router.TypeURL) + cfg, _ := f.ParseFilterConfig(testutils.MarshalAny(t, &v3routerpb.Router{})) + return xdsresource.HTTPFilter{Name: "rtr", Filter: f, Config: cfg} +} + type s struct { grpctest.Tester } @@ -597,7 +599,7 @@ func (s) TestResolverBadServiceUpdate(t *testing.T) { // Configure a listener resource that is expected to be NACKed because it // does not contain the `RouteSpecifier` field in the HTTPConnectionManager. - hcm := testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + hcm := testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{e2e.HTTPFilter("router", &v3routerpb.Router{})}, }) lis := &v3listenerpb.Listener{ @@ -1319,7 +1321,7 @@ func (s) TestResolverMaxStreamDuration(t *testing.T) { // different values of max stream duration. ldsName := serviceName rdsName := "route-" + serviceName - hcm := testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + hcm := testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ ConfigSourceSpecifier: &v3corepb.ConfigSource_Ads{Ads: &v3corepb.AggregatedConfigSource{}}, @@ -1706,7 +1708,7 @@ func (s) TestResolverMultipleLDSUpdates(t *testing.T) { // the same route configuration resource but has different values for some // other fields. There is still no route configuration resource on the // management server. - hcm := testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + hcm := testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ ConfigSourceSpecifier: &v3corepb.ConfigSource_Ads{Ads: &v3corepb.AggregatedConfigSource{}}, @@ -1871,7 +1873,7 @@ func (s) TestXDSResolverHTTPFilters(t *testing.T) { ldsFilters: []xdsresource.HTTPFilter{ {Name: "foo", Filter: &filterBuilder{path: &path}, Config: filterCfg{s: "foo1"}}, {Name: "bar", Filter: &filterBuilder{path: &path}, Config: filterCfg{s: "bar1", newStreamErr: errors.New("bar newstream err")}}, - routerFilter, + makeRouterFilter(t), }, rtCfgUpdate: xdsresource.RouteConfigUpdate{ VirtualHosts: []*xdsresource.VirtualHost{ @@ -1900,7 +1902,7 @@ func (s) TestXDSResolverHTTPFilters(t *testing.T) { ldsFilters: []xdsresource.HTTPFilter{ {Name: "foo", Filter: &filterBuilder{path: &path}, Config: filterCfg{s: "foo1", newStreamErr: errors.New("this is overridden to nil")}}, {Name: "bar", Filter: &filterBuilder{path: &path}, Config: filterCfg{s: "bar1"}}, - routerFilter, + makeRouterFilter(t), }, rtCfgUpdate: xdsresource.RouteConfigUpdate{ VirtualHosts: []*xdsresource.VirtualHost{ diff --git a/xds/internal/server/listener_wrapper_test.go b/xds/internal/server/listener_wrapper_test.go index 7d246f6373eb..1a74620a36f2 100644 --- a/xds/internal/server/listener_wrapper_test.go +++ b/xds/internal/server/listener_wrapper_test.go @@ -51,111 +51,116 @@ const ( defaultTestShortTimeout = 10 * time.Millisecond ) -var listenerWithRouteConfiguration = &v3listenerpb.Listener{ - FilterChains: []*v3listenerpb.FilterChain{ - { - FilterChainMatch: &v3listenerpb.FilterChainMatch{ - PrefixRanges: []*v3corepb.CidrRange{ - { - AddressPrefix: "192.168.0.0", - PrefixLen: &wrapperspb.UInt32Value{ - Value: uint32(16), +func listenerWithRouteConfiguration(t *testing.T) *v3listenerpb.Listener { + return &v3listenerpb.Listener{ + FilterChains: []*v3listenerpb.FilterChain{ + { + FilterChainMatch: &v3listenerpb.FilterChainMatch{ + PrefixRanges: []*v3corepb.CidrRange{ + { + AddressPrefix: "192.168.0.0", + PrefixLen: &wrapperspb.UInt32Value{ + Value: uint32(16), + }, }, }, - }, - SourceType: v3listenerpb.FilterChainMatch_SAME_IP_OR_LOOPBACK, - SourcePrefixRanges: []*v3corepb.CidrRange{ - { - AddressPrefix: "192.168.0.0", - PrefixLen: &wrapperspb.UInt32Value{ - Value: uint32(16), + SourceType: v3listenerpb.FilterChainMatch_SAME_IP_OR_LOOPBACK, + SourcePrefixRanges: []*v3corepb.CidrRange{ + { + AddressPrefix: "192.168.0.0", + PrefixLen: &wrapperspb.UInt32Value{ + Value: uint32(16), + }, }, }, + SourcePorts: []uint32{80}, }, - SourcePorts: []uint32{80}, - }, - Filters: []*v3listenerpb.Filter{ - { - Name: "filter-1", - ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ - RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ - Rds: &v3httppb.Rds{ - ConfigSource: &v3corepb.ConfigSource{ - ConfigSourceSpecifier: &v3corepb.ConfigSource_Ads{Ads: &v3corepb.AggregatedConfigSource{}}, + Filters: []*v3listenerpb.Filter{ + { + Name: "filter-1", + ConfigType: &v3listenerpb.Filter_TypedConfig{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ + RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ + Rds: &v3httppb.Rds{ + ConfigSource: &v3corepb.ConfigSource{ + ConfigSourceSpecifier: &v3corepb.ConfigSource_Ads{Ads: &v3corepb.AggregatedConfigSource{}}, + }, + RouteConfigName: "route-1", }, - RouteConfigName: "route-1", }, - }, - HttpFilters: []*v3httppb.HttpFilter{e2e.RouterHTTPFilter}, - }), + HttpFilters: []*v3httppb.HttpFilter{e2e.RouterHTTPFilter}, + }), + }, }, }, }, }, - }, + } } -var listenerWithFilterChains = &v3listenerpb.Listener{ - FilterChains: []*v3listenerpb.FilterChain{ - { - FilterChainMatch: &v3listenerpb.FilterChainMatch{ - PrefixRanges: []*v3corepb.CidrRange{ - { - AddressPrefix: "192.168.0.0", - PrefixLen: &wrapperspb.UInt32Value{ - Value: uint32(16), - }, - }, - }, - SourceType: v3listenerpb.FilterChainMatch_SAME_IP_OR_LOOPBACK, - SourcePrefixRanges: []*v3corepb.CidrRange{ - { - AddressPrefix: "192.168.0.0", - PrefixLen: &wrapperspb.UInt32Value{ - Value: uint32(16), +func listenerWithFilterChains(t *testing.T) *v3listenerpb.Listener { + return &v3listenerpb.Listener{ + FilterChains: []*v3listenerpb.FilterChain{ + { + FilterChainMatch: &v3listenerpb.FilterChainMatch{ + PrefixRanges: []*v3corepb.CidrRange{ + { + AddressPrefix: "192.168.0.0", + PrefixLen: &wrapperspb.UInt32Value{ + Value: uint32(16), + }, }, }, - }, - SourcePorts: []uint32{80}, - }, - TransportSocket: &v3corepb.TransportSocket{ - Name: "envoy.transport_sockets.tls", - ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ - CommonTlsContext: &v3tlspb.CommonTlsContext{ - TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ - InstanceName: "identityPluginInstance", - CertificateName: "identityCertName", + SourceType: v3listenerpb.FilterChainMatch_SAME_IP_OR_LOOPBACK, + SourcePrefixRanges: []*v3corepb.CidrRange{ + { + AddressPrefix: "192.168.0.0", + PrefixLen: &wrapperspb.UInt32Value{ + Value: uint32(16), }, }, - }), + }, + SourcePorts: []uint32{80}, }, - }, - Filters: []*v3listenerpb.Filter{ - { - Name: "filter-1", - ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ - RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ - RouteConfig: &v3routepb.RouteConfiguration{ - Name: "routeName", - VirtualHosts: []*v3routepb.VirtualHost{{ - Domains: []string{"lds.target.good:3333"}, - Routes: []*v3routepb.Route{{ - Match: &v3routepb.RouteMatch{ - PathSpecifier: &v3routepb.RouteMatch_Prefix{Prefix: "/"}, - }, - Action: &v3routepb.Route_NonForwardingAction{}, - }}}}}, + TransportSocket: &v3corepb.TransportSocket{ + Name: "envoy.transport_sockets.tls", + ConfigType: &v3corepb.TransportSocket_TypedConfig{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ + CommonTlsContext: &v3tlspb.CommonTlsContext{ + TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ + InstanceName: "identityPluginInstance", + CertificateName: "identityCertName", + }, }, - HttpFilters: []*v3httppb.HttpFilter{e2e.RouterHTTPFilter}, }), }, }, + Filters: []*v3listenerpb.Filter{ + { + Name: "filter-1", + ConfigType: &v3listenerpb.Filter_TypedConfig{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ + RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ + RouteConfig: &v3routepb.RouteConfiguration{ + Name: "routeName", + VirtualHosts: []*v3routepb.VirtualHost{{ + Domains: []string{"lds.target.good:3333"}, + Routes: []*v3routepb.Route{{ + Match: &v3routepb.RouteMatch{ + PathSpecifier: &v3routepb.RouteMatch_Prefix{Prefix: "/"}, + }, + Action: &v3routepb.Route_NonForwardingAction{}, + }}}}}, + }, + HttpFilters: []*v3httppb.HttpFilter{e2e.RouterHTTPFilter}, + }), + }, + }, + }, }, }, - }, + } + } type s struct { @@ -283,7 +288,7 @@ func (s) TestNewListenerWrapper(t *testing.T) { t.Fatalf("ready channel written to after receipt of a bad Listener update") } - fcm, err := xdsresource.NewFilterChainManager(listenerWithFilterChains) + fcm, err := xdsresource.NewFilterChainManager(listenerWithFilterChains(t)) if err != nil { t.Fatalf("xdsclient.NewFilterChainManager() failed with error: %v", err) } @@ -347,7 +352,7 @@ func (s) TestNewListenerWrapperWithRouteUpdate(t *testing.T) { if name != testListenerResourceName { t.Fatalf("listenerWrapper registered a lds watch on %s, want %s", name, testListenerResourceName) } - fcm, err := xdsresource.NewFilterChainManager(listenerWithRouteConfiguration) + fcm, err := xdsresource.NewFilterChainManager(listenerWithRouteConfiguration(t)) if err != nil { t.Fatalf("xdsclient.NewFilterChainManager() failed with error: %v", err) } @@ -410,7 +415,7 @@ func (s) TestListenerWrapper_Accept(t *testing.T) { // Push a good update with a filter chain which accepts local connections on // 192.168.0.0/16 subnet and port 80. - fcm, err := xdsresource.NewFilterChainManager(listenerWithFilterChains) + fcm, err := xdsresource.NewFilterChainManager(listenerWithFilterChains(t)) if err != nil { t.Fatalf("xdsclient.NewFilterChainManager() failed with error: %v", err) } diff --git a/xds/internal/xdsclient/tests/dump_test.go b/xds/internal/xdsclient/tests/dump_test.go index 5f2c5e05e4dd..a446bd32426c 100644 --- a/xds/internal/xdsclient/tests/dump_test.go +++ b/xds/internal/xdsclient/tests/dump_test.go @@ -76,19 +76,19 @@ func (s) TestDumpResources(t *testing.T) { listenerAnys := make([]*anypb.Any, len(ldsTargets)) for i := range ldsTargets { listeners[i] = e2e.DefaultClientListener(ldsTargets[i], rdsTargets[i]) - listenerAnys[i] = testutils.MarshalAny(listeners[i]) + listenerAnys[i] = testutils.MarshalAny(t, listeners[i]) } routes := make([]*v3routepb.RouteConfiguration, len(rdsTargets)) routeAnys := make([]*anypb.Any, len(rdsTargets)) for i := range rdsTargets { routes[i] = e2e.DefaultRouteConfig(rdsTargets[i], ldsTargets[i], cdsTargets[i]) - routeAnys[i] = testutils.MarshalAny(routes[i]) + routeAnys[i] = testutils.MarshalAny(t, routes[i]) } clusters := make([]*v3clusterpb.Cluster, len(cdsTargets)) clusterAnys := make([]*anypb.Any, len(cdsTargets)) for i := range cdsTargets { clusters[i] = e2e.DefaultCluster(cdsTargets[i], edsTargets[i], e2e.SecurityLevelNone) - clusterAnys[i] = testutils.MarshalAny(clusters[i]) + clusterAnys[i] = testutils.MarshalAny(t, clusters[i]) } endpoints := make([]*v3endpointpb.ClusterLoadAssignment, len(edsTargets)) endpointAnys := make([]*anypb.Any, len(edsTargets)) @@ -96,7 +96,7 @@ func (s) TestDumpResources(t *testing.T) { ports := []uint32{123, 456} for i := range edsTargets { endpoints[i] = e2e.DefaultEndpoint(edsTargets[i], ips[i], ports[i:i+1]) - endpointAnys[i] = testutils.MarshalAny(endpoints[i]) + endpointAnys[i] = testutils.MarshalAny(t, endpoints[i]) } // Spin up an xDS management server on a local port. diff --git a/xds/internal/xdsclient/tests/lds_watchers_test.go b/xds/internal/xdsclient/tests/lds_watchers_test.go index 7e41a81361ff..a70ee152f70a 100644 --- a/xds/internal/xdsclient/tests/lds_watchers_test.go +++ b/xds/internal/xdsclient/tests/lds_watchers_test.go @@ -82,8 +82,8 @@ const ( // badListenerResource returns a listener resource for the given name which does // not contain the `RouteSpecifier` field in the HTTPConnectionManager, and // hence is expected to be NACKed by the client. -func badListenerResource(name string) *v3listenerpb.Listener { - hcm := testutils.MarshalAny(&v3httppb.HttpConnectionManager{ +func badListenerResource(t *testing.T, name string) *v3listenerpb.Listener { + hcm := testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{e2e.HTTPFilter("router", &v3routerpb.Router{})}, }) return &v3listenerpb.Listener{ @@ -819,7 +819,7 @@ func (s) TestLDSWatch_NACKError(t *testing.T) { // which is expected to be NACKed by the client. resources := e2e.UpdateOptions{ NodeID: nodeID, - Listeners: []*v3listenerpb.Listener{badListenerResource(ldsName)}, + Listeners: []*v3listenerpb.Listener{badListenerResource(t, ldsName)}, SkipValidation: true, } if err := mgmtServer.Update(ctx, resources); err != nil { @@ -877,7 +877,7 @@ func (s) TestLDSWatch_PartialValid(t *testing.T) { resources := e2e.UpdateOptions{ NodeID: nodeID, Listeners: []*v3listenerpb.Listener{ - badListenerResource(badResourceName), + badListenerResource(t, badResourceName), e2e.DefaultClientListener(goodResourceName, rdsName), }, SkipValidation: true, diff --git a/xds/internal/xdsclient/tests/resource_update_test.go b/xds/internal/xdsclient/tests/resource_update_test.go index 3a2ccc114e8d..13db5fd434bb 100644 --- a/xds/internal/xdsclient/tests/resource_update_test.go +++ b/xds/internal/xdsclient/tests/resource_update_test.go @@ -95,7 +95,7 @@ func (s) TestHandleListenerResponseFromManagementServer(t *testing.T) { emptyRouterFilter = e2e.RouterHTTPFilter apiListener = &v3listenerpb.ApiListener{ ApiListener: func() *anypb.Any { - return testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + return testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ @@ -160,7 +160,7 @@ func (s) TestHandleListenerResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.listener.v3.Listener", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(&v3routepb.RouteConfiguration{})}, + Resources: []*anypb.Any{testutils.MarshalAny(t, &v3routepb.RouteConfiguration{})}, }, wantErr: "Listener not found in received response", wantUpdateMetadata: map[string]xdsresource.UpdateWithMD{ @@ -173,10 +173,10 @@ func (s) TestHandleListenerResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.listener.v3.Listener", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(&v3listenerpb.Listener{ + Resources: []*anypb.Any{testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: resourceName1, ApiListener: &v3listenerpb.ApiListener{ - ApiListener: testutils.MarshalAny(&v3httppb.HttpConnectionManager{}), + ApiListener: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{}), }}), }, }, @@ -197,7 +197,7 @@ func (s) TestHandleListenerResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.listener.v3.Listener", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(resource1)}, + Resources: []*anypb.Any{testutils.MarshalAny(t, resource1)}, }, wantUpdate: xdsresource.ListenerUpdate{ RouteConfigName: "route-configuration-name", @@ -206,7 +206,7 @@ func (s) TestHandleListenerResponseFromManagementServer(t *testing.T) { wantUpdateMetadata: map[string]xdsresource.UpdateWithMD{ "resource-name-1": { MD: xdsresource.UpdateMetadata{Status: xdsresource.ServiceStatusACKed, Version: "1"}, - Raw: testutils.MarshalAny(resource1), + Raw: testutils.MarshalAny(t, resource1), }, }, }, @@ -216,7 +216,7 @@ func (s) TestHandleListenerResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.listener.v3.Listener", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(resource1), testutils.MarshalAny(resource2)}, + Resources: []*anypb.Any{testutils.MarshalAny(t, resource1), testutils.MarshalAny(t, resource2)}, }, wantUpdate: xdsresource.ListenerUpdate{ RouteConfigName: "route-configuration-name", @@ -225,7 +225,7 @@ func (s) TestHandleListenerResponseFromManagementServer(t *testing.T) { wantUpdateMetadata: map[string]xdsresource.UpdateWithMD{ "resource-name-1": { MD: xdsresource.UpdateMetadata{Status: xdsresource.ServiceStatusACKed, Version: "1"}, - Raw: testutils.MarshalAny(resource1), + Raw: testutils.MarshalAny(t, resource1), }, }, }, @@ -403,7 +403,7 @@ func (s) TestHandleRouteConfigResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.route.v3.RouteConfiguration", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(&v3clusterpb.Cluster{})}, + Resources: []*anypb.Any{testutils.MarshalAny(t, &v3clusterpb.Cluster{})}, }, wantErr: "RouteConfiguration not found in received response", wantUpdateMetadata: map[string]xdsresource.UpdateWithMD{ @@ -416,7 +416,7 @@ func (s) TestHandleRouteConfigResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.route.v3.RouteConfiguration", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(&v3routepb.RouteConfiguration{ + Resources: []*anypb.Any{testutils.MarshalAny(t, &v3routepb.RouteConfiguration{ Name: resourceName1, VirtualHosts: []*v3routepb.VirtualHost{{ Domains: []string{"lds-resource-name"}, @@ -448,7 +448,7 @@ func (s) TestHandleRouteConfigResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.route.v3.RouteConfiguration", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(resource1)}, + Resources: []*anypb.Any{testutils.MarshalAny(t, resource1)}, }, wantUpdate: xdsresource.RouteConfigUpdate{ VirtualHosts: []*xdsresource.VirtualHost{ @@ -463,7 +463,7 @@ func (s) TestHandleRouteConfigResponseFromManagementServer(t *testing.T) { wantUpdateMetadata: map[string]xdsresource.UpdateWithMD{ "resource-name-1": { MD: xdsresource.UpdateMetadata{Status: xdsresource.ServiceStatusACKed, Version: "1"}, - Raw: testutils.MarshalAny(resource1), + Raw: testutils.MarshalAny(t, resource1), }, }, }, @@ -473,7 +473,7 @@ func (s) TestHandleRouteConfigResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.route.v3.RouteConfiguration", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(resource1), testutils.MarshalAny(resource2)}, + Resources: []*anypb.Any{testutils.MarshalAny(t, resource1), testutils.MarshalAny(t, resource2)}, }, wantUpdate: xdsresource.RouteConfigUpdate{ VirtualHosts: []*xdsresource.VirtualHost{ @@ -488,7 +488,7 @@ func (s) TestHandleRouteConfigResponseFromManagementServer(t *testing.T) { wantUpdateMetadata: map[string]xdsresource.UpdateWithMD{ "resource-name-1": { MD: xdsresource.UpdateMetadata{Status: xdsresource.ServiceStatusACKed, Version: "1"}, - Raw: testutils.MarshalAny(resource1), + Raw: testutils.MarshalAny(t, resource1), }, }, }, @@ -638,7 +638,7 @@ func (s) TestHandleClusterResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.cluster.v3.Cluster", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(&v3endpointpb.ClusterLoadAssignment{})}, + Resources: []*anypb.Any{testutils.MarshalAny(t, &v3endpointpb.ClusterLoadAssignment{})}, }, wantErr: "Cluster not found in received response", wantUpdateMetadata: map[string]xdsresource.UpdateWithMD{ @@ -651,7 +651,7 @@ func (s) TestHandleClusterResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.cluster.v3.Cluster", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(&v3clusterpb.Cluster{ + Resources: []*anypb.Any{testutils.MarshalAny(t, &v3clusterpb.Cluster{ Name: resourceName1, ClusterDiscoveryType: &v3clusterpb.Cluster_Type{Type: v3clusterpb.Cluster_EDS}, EdsClusterConfig: &v3clusterpb.Cluster_EdsClusterConfig{ @@ -682,7 +682,7 @@ func (s) TestHandleClusterResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.cluster.v3.Cluster", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(resource1)}, + Resources: []*anypb.Any{testutils.MarshalAny(t, resource1)}, }, wantUpdate: xdsresource.ClusterUpdate{ ClusterName: "resource-name-1", @@ -692,7 +692,7 @@ func (s) TestHandleClusterResponseFromManagementServer(t *testing.T) { wantUpdateMetadata: map[string]xdsresource.UpdateWithMD{ "resource-name-1": { MD: xdsresource.UpdateMetadata{Status: xdsresource.ServiceStatusACKed, Version: "1"}, - Raw: testutils.MarshalAny(resource1), + Raw: testutils.MarshalAny(t, resource1), }, }, }, @@ -702,7 +702,7 @@ func (s) TestHandleClusterResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.cluster.v3.Cluster", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(resource1), testutils.MarshalAny(resource2)}, + Resources: []*anypb.Any{testutils.MarshalAny(t, resource1), testutils.MarshalAny(t, resource2)}, }, wantUpdate: xdsresource.ClusterUpdate{ ClusterName: "resource-name-1", @@ -712,7 +712,7 @@ func (s) TestHandleClusterResponseFromManagementServer(t *testing.T) { wantUpdateMetadata: map[string]xdsresource.UpdateWithMD{ "resource-name-1": { MD: xdsresource.UpdateMetadata{Status: xdsresource.ServiceStatusACKed, Version: "1"}, - Raw: testutils.MarshalAny(resource1), + Raw: testutils.MarshalAny(t, resource1), }, }, }, @@ -919,7 +919,7 @@ func (s) TestHandleEndpointsResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.route.v3.RouteConfiguration", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(&v3listenerpb.Listener{})}, + Resources: []*anypb.Any{testutils.MarshalAny(t, &v3listenerpb.Listener{})}, }, wantErr: "Endpoints not found in received response", wantUpdateMetadata: map[string]xdsresource.UpdateWithMD{ @@ -932,7 +932,7 @@ func (s) TestHandleEndpointsResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(&v3endpointpb.ClusterLoadAssignment{ + Resources: []*anypb.Any{testutils.MarshalAny(t, &v3endpointpb.ClusterLoadAssignment{ ClusterName: resourceName1, Endpoints: []*v3endpointpb.LocalityLbEndpoints{ { @@ -981,7 +981,7 @@ func (s) TestHandleEndpointsResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(resource1)}, + Resources: []*anypb.Any{testutils.MarshalAny(t, resource1)}, }, wantUpdate: xdsresource.EndpointsUpdate{ Localities: []xdsresource.Locality{ @@ -1002,7 +1002,7 @@ func (s) TestHandleEndpointsResponseFromManagementServer(t *testing.T) { wantUpdateMetadata: map[string]xdsresource.UpdateWithMD{ "resource-name-1": { MD: xdsresource.UpdateMetadata{Status: xdsresource.ServiceStatusACKed, Version: "1"}, - Raw: testutils.MarshalAny(resource1), + Raw: testutils.MarshalAny(t, resource1), }, }, }, @@ -1012,7 +1012,7 @@ func (s) TestHandleEndpointsResponseFromManagementServer(t *testing.T) { managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", VersionInfo: "1", - Resources: []*anypb.Any{testutils.MarshalAny(resource1), testutils.MarshalAny(resource2)}, + Resources: []*anypb.Any{testutils.MarshalAny(t, resource1), testutils.MarshalAny(t, resource2)}, }, wantUpdate: xdsresource.EndpointsUpdate{ Localities: []xdsresource.Locality{ @@ -1033,7 +1033,7 @@ func (s) TestHandleEndpointsResponseFromManagementServer(t *testing.T) { wantUpdateMetadata: map[string]xdsresource.UpdateWithMD{ "resource-name-1": { MD: xdsresource.UpdateMetadata{Status: xdsresource.ServiceStatusACKed, Version: "1"}, - Raw: testutils.MarshalAny(resource1), + Raw: testutils.MarshalAny(t, resource1), }, }, }, diff --git a/xds/internal/xdsclient/transport/transport_ack_nack_test.go b/xds/internal/xdsclient/transport/transport_ack_nack_test.go index f887ae1de0bd..e458101e2816 100644 --- a/xds/internal/xdsclient/transport/transport_ack_nack_test.go +++ b/xds/internal/xdsclient/transport/transport_ack_nack_test.go @@ -109,7 +109,7 @@ func (s) TestSimpleAckAndNack(t *testing.T) { // Configure the management server with appropriate resources. apiListener := &v3listenerpb.ApiListener{ ApiListener: func() *anypb.Any { - return testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + return testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ @@ -288,7 +288,7 @@ func (s) TestInvalidFirstResponse(t *testing.T) { // Configure the management server with appropriate resources. apiListener := &v3listenerpb.ApiListener{ ApiListener: func() *anypb.Any { - return testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + return testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ @@ -411,7 +411,7 @@ func (s) TestResourceIsNotRequestedAnymore(t *testing.T) { // Configure the management server with appropriate resources. apiListener := &v3listenerpb.ApiListener{ ApiListener: func() *anypb.Any { - return testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + return testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ diff --git a/xds/internal/xdsclient/transport/transport_backoff_test.go b/xds/internal/xdsclient/transport/transport_backoff_test.go index db7587ca7c30..96ba3e9dd2f5 100644 --- a/xds/internal/xdsclient/transport/transport_backoff_test.go +++ b/xds/internal/xdsclient/transport/transport_backoff_test.go @@ -227,7 +227,7 @@ func (s) TestTransport_RetriesAfterBrokenStream(t *testing.T) { // Configure the management server with appropriate resources. apiListener := &v3listenerpb.ApiListener{ ApiListener: func() *anypb.Any { - return testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + return testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ diff --git a/xds/internal/xdsclient/transport/transport_resource_test.go b/xds/internal/xdsclient/transport/transport_resource_test.go index 0824af77f4ff..43ec82ae74ed 100644 --- a/xds/internal/xdsclient/transport/transport_resource_test.go +++ b/xds/internal/xdsclient/transport/transport_resource_test.go @@ -87,7 +87,7 @@ func (s) TestHandleResponseFromManagementServer(t *testing.T) { } apiListener = &v3listenerpb.ApiListener{ ApiListener: func() *anypb.Any { - return testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + return testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ @@ -138,30 +138,30 @@ func (s) TestHandleResponseFromManagementServer(t *testing.T) { resourceNamesToRequest: []string{resourceName1}, managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.listener.v3.Listener", - Resources: []*anypb.Any{testutils.MarshalAny(resource1)}, + Resources: []*anypb.Any{testutils.MarshalAny(t, resource1)}, }, wantURL: "type.googleapis.com/envoy.config.listener.v3.Listener", - wantResources: []*anypb.Any{testutils.MarshalAny(resource1)}, + wantResources: []*anypb.Any{testutils.MarshalAny(t, resource1)}, }, { desc: "two good resources", resourceNamesToRequest: []string{resourceName1, resourceName2}, managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.listener.v3.Listener", - Resources: []*anypb.Any{testutils.MarshalAny(resource1), testutils.MarshalAny(resource2)}, + Resources: []*anypb.Any{testutils.MarshalAny(t, resource1), testutils.MarshalAny(t, resource2)}, }, wantURL: "type.googleapis.com/envoy.config.listener.v3.Listener", - wantResources: []*anypb.Any{testutils.MarshalAny(resource1), testutils.MarshalAny(resource2)}, + wantResources: []*anypb.Any{testutils.MarshalAny(t, resource1), testutils.MarshalAny(t, resource2)}, }, { desc: "two resources when we requested one", resourceNamesToRequest: []string{resourceName1}, managementServerResponse: &v3discoverypb.DiscoveryResponse{ TypeUrl: "type.googleapis.com/envoy.config.listener.v3.Listener", - Resources: []*anypb.Any{testutils.MarshalAny(resource1), testutils.MarshalAny(resource2)}, + Resources: []*anypb.Any{testutils.MarshalAny(t, resource1), testutils.MarshalAny(t, resource2)}, }, wantURL: "type.googleapis.com/envoy.config.listener.v3.Listener", - wantResources: []*anypb.Any{testutils.MarshalAny(resource1), testutils.MarshalAny(resource2)}, + wantResources: []*anypb.Any{testutils.MarshalAny(t, resource1), testutils.MarshalAny(t, resource2)}, }, } diff --git a/xds/internal/xdsclient/xdslbregistry/xdslbregistry_test.go b/xds/internal/xdsclient/xdslbregistry/xdslbregistry_test.go index e679c4a5b29a..f213b2983417 100644 --- a/xds/internal/xdsclient/xdslbregistry/xdslbregistry_test.go +++ b/xds/internal/xdsclient/xdslbregistry/xdslbregistry_test.go @@ -89,7 +89,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3ringhashpb.RingHash{ + TypedConfig: testutils.MarshalAny(t, &v3ringhashpb.RingHash{ HashFunction: v3ringhashpb.RingHash_XX_HASH, MinimumRingSize: wrapperspb.UInt64(10), MaximumRingSize: wrapperspb.UInt64(100), @@ -106,7 +106,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3leastrequestpb.LeastRequest{ + TypedConfig: testutils.MarshalAny(t, &v3leastrequestpb.LeastRequest{ ChoiceCount: wrapperspb.UInt32(3), }), }, @@ -122,7 +122,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3pickfirstpb.PickFirst{ + TypedConfig: testutils.MarshalAny(t, &v3pickfirstpb.PickFirst{ ShuffleAddressList: true, }), }, @@ -137,7 +137,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3pickfirstpb.PickFirst{}), + TypedConfig: testutils.MarshalAny(t, &v3pickfirstpb.PickFirst{}), }, }, }, @@ -150,7 +150,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3roundrobinpb.RoundRobin{}), + TypedConfig: testutils.MarshalAny(t, &v3roundrobinpb.RoundRobin{}), }, }, }, @@ -163,12 +163,12 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3roundrobinpb.RoundRobin{}), + TypedConfig: testutils.MarshalAny(t, &v3roundrobinpb.RoundRobin{}), }, }, { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3ringhashpb.RingHash{ + TypedConfig: testutils.MarshalAny(t, &v3ringhashpb.RingHash{ HashFunction: v3ringhashpb.RingHash_XX_HASH, MinimumRingSize: wrapperspb.UInt64(10), MaximumRingSize: wrapperspb.UInt64(100), @@ -185,7 +185,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3ringhashpb.RingHash{ + TypedConfig: testutils.MarshalAny(t, &v3ringhashpb.RingHash{ HashFunction: v3ringhashpb.RingHash_XX_HASH, MinimumRingSize: wrapperspb.UInt64(10), MaximumRingSize: wrapperspb.UInt64(100), @@ -194,7 +194,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { }, { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3roundrobinpb.RoundRobin{}), + TypedConfig: testutils.MarshalAny(t, &v3roundrobinpb.RoundRobin{}), }, }, }, @@ -208,14 +208,14 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3pickfirstpb.PickFirst{ + TypedConfig: testutils.MarshalAny(t, &v3pickfirstpb.PickFirst{ ShuffleAddressList: true, }), }, }, { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3roundrobinpb.RoundRobin{}), + TypedConfig: testutils.MarshalAny(t, &v3roundrobinpb.RoundRobin{}), }, }, }, @@ -228,14 +228,14 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3leastrequestpb.LeastRequest{ + TypedConfig: testutils.MarshalAny(t, &v3leastrequestpb.LeastRequest{ ChoiceCount: wrapperspb.UInt32(32), }), }, }, { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3roundrobinpb.RoundRobin{}), + TypedConfig: testutils.MarshalAny(t, &v3roundrobinpb.RoundRobin{}), }, }, }, @@ -250,7 +250,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ // The type not registered in gRPC Policy registry. // Should fallback to next policy in list. - TypedConfig: testutils.MarshalAny(&v3xdsxdstypepb.TypedStruct{ + TypedConfig: testutils.MarshalAny(t, &v3xdsxdstypepb.TypedStruct{ TypeUrl: "type.googleapis.com/myorg.ThisTypeDoesNotExist", Value: &structpb.Struct{}, }), @@ -258,7 +258,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { }, { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3xdsxdstypepb.TypedStruct{ + TypedConfig: testutils.MarshalAny(t, &v3xdsxdstypepb.TypedStruct{ TypeUrl: "type.googleapis.com/myorg.MyCustomLeastRequestPolicy", Value: &structpb.Struct{}, }), @@ -274,7 +274,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v1xdsudpatypepb.TypedStruct{ + TypedConfig: testutils.MarshalAny(t, &v1xdsudpatypepb.TypedStruct{ TypeUrl: "type.googleapis.com/myorg.MyCustomLeastRequestPolicy", Value: &structpb.Struct{}, }), @@ -290,7 +290,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: wrrLocalityAny(&v3roundrobinpb.RoundRobin{}), + TypedConfig: wrrLocalityAny(t, &v3roundrobinpb.RoundRobin{}), }, }, }, @@ -303,7 +303,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: wrrLocalityAny(&v3xdsxdstypepb.TypedStruct{ + TypedConfig: wrrLocalityAny(t, &v3xdsxdstypepb.TypedStruct{ TypeUrl: "type.googleapis.com/myorg.MyCustomLeastRequestPolicy", Value: &structpb.Struct{}, }), @@ -319,7 +319,7 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: wrrLocalityAny(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(&v3roundrobinpb.RoundRobin{}))))))))))))))), + TypedConfig: wrrLocalityAny(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, &v3roundrobinpb.RoundRobin{}))))))))))))))), }, }, }, @@ -388,7 +388,7 @@ func (s) TestConvertToServiceConfigFailure(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3ringhashpb.RingHash{ + TypedConfig: testutils.MarshalAny(t, &v3ringhashpb.RingHash{ HashFunction: v3ringhashpb.RingHash_MURMUR_HASH_2, MinimumRingSize: wrapperspb.UInt64(10), MaximumRingSize: wrapperspb.UInt64(100), @@ -406,7 +406,7 @@ func (s) TestConvertToServiceConfigFailure(t *testing.T) { { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ // The type not registered in gRPC Policy registry. - TypedConfig: testutils.MarshalAny(&v3xdsxdstypepb.TypedStruct{ + TypedConfig: testutils.MarshalAny(t, &v3xdsxdstypepb.TypedStruct{ TypeUrl: "type.googleapis.com/myorg.ThisTypeDoesNotExist", Value: &structpb.Struct{}, }), @@ -415,7 +415,7 @@ func (s) TestConvertToServiceConfigFailure(t *testing.T) { { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ // Not supported by gRPC-Go. - TypedConfig: testutils.MarshalAny(&v3leastrequestpb.LeastRequest{}), + TypedConfig: testutils.MarshalAny(t, &v3leastrequestpb.LeastRequest{}), }, }, }, @@ -428,7 +428,7 @@ func (s) TestConvertToServiceConfigFailure(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: wrrLocalityAny(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(wrrLocality(&v3roundrobinpb.RoundRobin{})))))))))))))))), + TypedConfig: wrrLocalityAny(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, wrrLocality(t, &v3roundrobinpb.RoundRobin{})))))))))))))))), }, }, }, @@ -455,13 +455,13 @@ func (s) TestConvertToServiceConfigFailure(t *testing.T) { // wrrLocality is a helper that takes a proto message and returns a // WrrLocalityProto with the proto message marshaled into a proto.Any as a // child. -func wrrLocality(m proto.Message) *v3wrrlocalitypb.WrrLocality { +func wrrLocality(t *testing.T, m proto.Message) *v3wrrlocalitypb.WrrLocality { return &v3wrrlocalitypb.WrrLocality{ EndpointPickingPolicy: &v3clusterpb.LoadBalancingPolicy{ Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(m), + TypedConfig: testutils.MarshalAny(t, m), }, }, }, @@ -471,6 +471,6 @@ func wrrLocality(m proto.Message) *v3wrrlocalitypb.WrrLocality { // wrrLocalityAny takes a proto message and returns a wrr locality proto // marshaled as an any with an any child set to the marshaled proto message. -func wrrLocalityAny(m proto.Message) *anypb.Any { - return testutils.MarshalAny(wrrLocality(m)) +func wrrLocalityAny(t *testing.T, m proto.Message) *anypb.Any { + return testutils.MarshalAny(t, wrrLocality(t, m)) } diff --git a/xds/internal/xdsclient/xdsresource/filter_chain_test.go b/xds/internal/xdsclient/xdsresource/filter_chain_test.go index 4edf9ce006f1..c90e45c683c9 100644 --- a/xds/internal/xdsclient/xdsresource/filter_chain_test.go +++ b/xds/internal/xdsclient/xdsresource/filter_chain_test.go @@ -52,6 +52,22 @@ const ( rLevel = "route level" ) +func emptyValidNetworkFilters(t *testing.T) []*v3listenerpb.Filter { + return []*v3listenerpb.Filter{ + { + Name: "filter-1", + ConfigType: &v3listenerpb.Filter_TypedConfig{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ + RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ + RouteConfig: routeConfig, + }, + HttpFilters: []*v3httppb.HttpFilter{emptyRouterFilter}, + }), + }, + }, + } +} + var ( routeConfig = &v3routepb.RouteConfiguration{ Name: "routeName", @@ -68,19 +84,7 @@ var ( Domains: []string{"lds.target.good:3333"}, Routes: []*Route{{Prefix: newStringP("/"), ActionType: RouteActionNonForwardingAction}}, }}} - emptyValidNetworkFilters = []*v3listenerpb.Filter{ - { - Name: "filter-1", - ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ - RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ - RouteConfig: routeConfig, - }, - HttpFilters: []*v3httppb.HttpFilter{emptyRouterFilter}, - }), - }, - }, - } + validServerSideHTTPFilter1 = &v3httppb.HttpFilter{ Name: "serverOnlyCustomFilter", ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: serverOnlyCustomFilterConfig}, @@ -90,12 +94,18 @@ var ( ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: serverOnlyCustomFilterConfig}, } emptyRouterFilter = e2e.RouterHTTPFilter - routerBuilder = httpfilter.Get(router.TypeURL) - routerConfig, _ = routerBuilder.ParseFilterConfig(testutils.MarshalAny(&v3routerpb.Router{})) - routerFilter = HTTPFilter{Name: "router", Filter: routerBuilder, Config: routerConfig} - routerFilterList = []HTTPFilter{routerFilter} ) +func makeRouterFilter(t *testing.T) HTTPFilter { + routerBuilder := httpfilter.Get(router.TypeURL) + routerConfig, _ := routerBuilder.ParseFilterConfig(testutils.MarshalAny(t, &v3routerpb.Router{})) + return HTTPFilter{Name: "router", Filter: routerBuilder, Config: routerConfig} +} + +func makeRouterFilterList(t *testing.T) []HTTPFilter { + return []HTTPFilter{makeRouterFilter(t)} +} + // TestNewFilterChainImpl_Failure_BadMatchFields verifies cases where we have a // single filter chain with match criteria that contains unsupported fields. func (s) TestNewFilterChainImpl_Failure_BadMatchFields(t *testing.T) { @@ -209,13 +219,13 @@ func (s) TestNewFilterChainImpl_Failure_OverlappingMatchingRules(t *testing.T) { FilterChainMatch: &v3listenerpb.FilterChainMatch{ PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16), cidrRangeFromAddressAndPrefixLen("10.0.0.0", 0)}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.2.2", 16)}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -226,19 +236,19 @@ func (s) TestNewFilterChainImpl_Failure_OverlappingMatchingRules(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { FilterChainMatch: &v3listenerpb.FilterChainMatch{SourceType: v3listenerpb.FilterChainMatch_ANY}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{SourceType: v3listenerpb.FilterChainMatch_SAME_IP_OR_LOOPBACK}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{SourceType: v3listenerpb.FilterChainMatch_EXTERNAL}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{SourceType: v3listenerpb.FilterChainMatch_EXTERNAL}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -251,13 +261,13 @@ func (s) TestNewFilterChainImpl_Failure_OverlappingMatchingRules(t *testing.T) { FilterChainMatch: &v3listenerpb.FilterChainMatch{ SourcePrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16), cidrRangeFromAddressAndPrefixLen("10.0.0.0", 0)}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ SourcePrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.2.2", 16)}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -268,15 +278,15 @@ func (s) TestNewFilterChainImpl_Failure_OverlappingMatchingRules(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { FilterChainMatch: &v3listenerpb.FilterChainMatch{SourcePorts: []uint32{1, 2, 3, 4, 5}}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{SourcePorts: []uint32{5, 6, 7}}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -312,7 +322,7 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { TransportSocket: &v3corepb.TransportSocket{Name: "unsupported-transport-socket-name"}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -326,10 +336,10 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{}), + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{}), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -349,7 +359,7 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { }, }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -363,10 +373,10 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{}), + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{}), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -380,12 +390,12 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ RequireSni: &wrapperspb.BoolValue{Value: true}, }), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -399,12 +409,12 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ OcspStaplePolicy: v3tlspb.DownstreamTlsContext_STRICT_STAPLING, }), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -418,7 +428,7 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_ValidationContextSdsSecretConfig{ ValidationContextSdsSecretConfig: &v3tlspb.SdsSecretConfig{ @@ -429,7 +439,7 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { }), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -443,7 +453,7 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_ValidationContextSdsSecretConfig{ ValidationContextSdsSecretConfig: &v3tlspb.SdsSecretConfig{ @@ -454,7 +464,7 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { }), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -468,7 +478,7 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ RequireClientCertificate: &wrapperspb.BoolValue{Value: true}, CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ @@ -479,7 +489,7 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { }), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -493,12 +503,12 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{}, }), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -539,7 +549,7 @@ func (s) TestNewFilterChainImpl_Success_RouteUpdate(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ @@ -560,7 +570,7 @@ func (s) TestNewFilterChainImpl_Success_RouteUpdate(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ @@ -586,7 +596,7 @@ func (s) TestNewFilterChainImpl_Success_RouteUpdate(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { RouteConfigName: "route-1", - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -597,7 +607,7 @@ func (s) TestNewFilterChainImpl_Success_RouteUpdate(t *testing.T) { }, def: &FilterChain{ RouteConfigName: "route-1", - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, RouteConfigNames: map[string]bool{"route-1": true}, }, @@ -612,7 +622,7 @@ func (s) TestNewFilterChainImpl_Success_RouteUpdate(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: routeConfig, }, @@ -628,7 +638,7 @@ func (s) TestNewFilterChainImpl_Success_RouteUpdate(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: routeConfig, }, @@ -649,7 +659,7 @@ func (s) TestNewFilterChainImpl_Success_RouteUpdate(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -660,7 +670,7 @@ func (s) TestNewFilterChainImpl_Success_RouteUpdate(t *testing.T) { }, def: &FilterChain{ InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -676,7 +686,7 @@ func (s) TestNewFilterChainImpl_Success_RouteUpdate(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ @@ -697,7 +707,7 @@ func (s) TestNewFilterChainImpl_Success_RouteUpdate(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ @@ -723,7 +733,7 @@ func (s) TestNewFilterChainImpl_Success_RouteUpdate(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { RouteConfigName: "route-1", - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -734,7 +744,7 @@ func (s) TestNewFilterChainImpl_Success_RouteUpdate(t *testing.T) { }, def: &FilterChain{ RouteConfigName: "route-2", - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, RouteConfigNames: map[string]bool{ "route-1": true, @@ -780,7 +790,7 @@ func (s) TestNewFilterChainImpl_Failure_BadRouteUpdate(t *testing.T) { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{emptyRouterFilter}, }), }, @@ -793,7 +803,7 @@ func (s) TestNewFilterChainImpl_Failure_BadRouteUpdate(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{emptyRouterFilter}, }), }, @@ -814,7 +824,7 @@ func (s) TestNewFilterChainImpl_Failure_BadRouteUpdate(t *testing.T) { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ RouteConfigName: "route-1", @@ -832,7 +842,7 @@ func (s) TestNewFilterChainImpl_Failure_BadRouteUpdate(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ RouteConfigName: "route-1", @@ -857,7 +867,7 @@ func (s) TestNewFilterChainImpl_Failure_BadRouteUpdate(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_ScopedRoutes{}, HttpFilters: []*v3httppb.HttpFilter{emptyRouterFilter}, }), @@ -871,7 +881,7 @@ func (s) TestNewFilterChainImpl_Failure_BadRouteUpdate(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_ScopedRoutes{}, HttpFilters: []*v3httppb.HttpFilter{emptyRouterFilter}, }), @@ -913,7 +923,7 @@ func (s) TestNewFilterChainImpl_Failure_BadHTTPFilters(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{ { Name: "clientOnlyCustomFilter", @@ -940,7 +950,7 @@ func (s) TestNewFilterChainImpl_Failure_BadHTTPFilters(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{ validServerSideHTTPFilter1, { @@ -991,7 +1001,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{ validServerSideHTTPFilter1, emptyRouterFilter, @@ -1010,7 +1020,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{ validServerSideHTTPFilter1, emptyRouterFilter, @@ -1038,7 +1048,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { Filter: serverOnlyHTTPFilter{}, Config: filterConfig{Cfg: serverOnlyCustomFilterConfig}, }, - routerFilter, + makeRouterFilter(t), }, InlineRouteConfig: inlineRouteConfig, }, @@ -1056,7 +1066,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { Filter: serverOnlyHTTPFilter{}, Config: filterConfig{Cfg: serverOnlyCustomFilterConfig}, }, - routerFilter, + makeRouterFilter(t), }, InlineRouteConfig: inlineRouteConfig, }, @@ -1072,7 +1082,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{ validServerSideHTTPFilter1, validServerSideHTTPFilter2, @@ -1092,7 +1102,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{ validServerSideHTTPFilter1, validServerSideHTTPFilter2, @@ -1126,7 +1136,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { Filter: serverOnlyHTTPFilter{}, Config: filterConfig{Cfg: serverOnlyCustomFilterConfig}, }, - routerFilter, + makeRouterFilter(t), }, InlineRouteConfig: inlineRouteConfig, }, @@ -1148,7 +1158,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { Filter: serverOnlyHTTPFilter{}, Config: filterConfig{Cfg: serverOnlyCustomFilterConfig}, }, - routerFilter, + makeRouterFilter(t), }, InlineRouteConfig: inlineRouteConfig, }, @@ -1166,7 +1176,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{ validServerSideHTTPFilter1, validServerSideHTTPFilter2, @@ -1181,7 +1191,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { { Name: "hcm2", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{ validServerSideHTTPFilter1, emptyRouterFilter, @@ -1200,7 +1210,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { { Name: "hcm", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{ validServerSideHTTPFilter1, validServerSideHTTPFilter2, @@ -1215,7 +1225,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { { Name: "hcm2", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ HttpFilters: []*v3httppb.HttpFilter{ validServerSideHTTPFilter1, emptyRouterFilter, @@ -1248,7 +1258,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { Filter: serverOnlyHTTPFilter{}, Config: filterConfig{Cfg: serverOnlyCustomFilterConfig}, }, - routerFilter, + makeRouterFilter(t), }, InlineRouteConfig: inlineRouteConfig, }, @@ -1270,7 +1280,7 @@ func (s) TestNewFilterChainImpl_Success_HTTPFilters(t *testing.T) { Filter: serverOnlyHTTPFilter{}, Config: filterConfig{Cfg: serverOnlyCustomFilterConfig}, }, - routerFilter, + makeRouterFilter(t), }, InlineRouteConfig: inlineRouteConfig, }, @@ -1310,11 +1320,11 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { Name: "filter-chain-1", - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, DefaultFilterChain: &v3listenerpb.FilterChain{ - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, wantFC: &FilterChainManager{ @@ -1327,7 +1337,7 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1338,7 +1348,7 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { }, def: &FilterChain{ InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1350,7 +1360,7 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ InstanceName: "identityPluginInstance", @@ -1360,14 +1370,14 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { }), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, DefaultFilterChain: &v3listenerpb.FilterChain{ TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ InstanceName: "defaultIdentityPluginInstance", @@ -1377,7 +1387,7 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { }), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, wantFC: &FilterChainManager{ @@ -1394,7 +1404,7 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { IdentityCertName: "identityCertName", }, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1409,7 +1419,7 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { IdentityCertName: "defaultIdentityCertName", }, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1421,7 +1431,7 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ RequireClientCertificate: &wrapperspb.BoolValue{Value: true}, CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ @@ -1438,7 +1448,7 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { }), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, DefaultFilterChain: &v3listenerpb.FilterChain{ @@ -1446,7 +1456,7 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ RequireClientCertificate: &wrapperspb.BoolValue{Value: true}, CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ @@ -1463,7 +1473,7 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { }), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, wantFC: &FilterChainManager{ @@ -1483,7 +1493,7 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { RequireClientCert: true, }, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1501,7 +1511,7 @@ func (s) TestNewFilterChainImpl_Success_SecurityConfig(t *testing.T) { RequireClientCert: true, }, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1539,7 +1549,7 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1559,7 +1569,7 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { Name: "good-chain", - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { Name: "unsupported-destination-port", @@ -1567,10 +1577,10 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}, DestinationPort: &wrapperspb.UInt32Value{Value: 666}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, - DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters}, + DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters(t)}, }, wantFC: &FilterChainManager{ dstPrefixMap: map[string]*destPrefixEntry{ @@ -1578,7 +1588,7 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { }, def: &FilterChain{ InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1588,7 +1598,7 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { Name: "good-chain", - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { Name: "unsupported-server-names", @@ -1596,10 +1606,10 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}, ServerNames: []string{"example-server"}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, - DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters}, + DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters(t)}, }, wantFC: &FilterChainManager{ dstPrefixMap: map[string]*destPrefixEntry{ @@ -1610,7 +1620,7 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { }, def: &FilterChain{ InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1620,7 +1630,7 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { Name: "good-chain", - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { Name: "unsupported-transport-protocol", @@ -1628,10 +1638,10 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}, TransportProtocol: "tls", }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, - DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters}, + DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters(t)}, }, wantFC: &FilterChainManager{ dstPrefixMap: map[string]*destPrefixEntry{ @@ -1642,7 +1652,7 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { }, def: &FilterChain{ InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1652,7 +1662,7 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { Name: "good-chain", - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { Name: "unsupported-application-protocol", @@ -1660,10 +1670,10 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}, ApplicationProtocols: []string{"h2"}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, - DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters}, + DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters(t)}, }, wantFC: &FilterChainManager{ dstPrefixMap: map[string]*destPrefixEntry{ @@ -1674,7 +1684,7 @@ func (s) TestNewFilterChainImpl_Success_UnsupportedMatchFields(t *testing.T) { }, def: &FilterChain{ InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1713,7 +1723,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { { // Unspecified destination prefix. FilterChainMatch: &v3listenerpb.FilterChainMatch{}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { // v4 wildcard destination prefix. @@ -1721,7 +1731,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("0.0.0.0", 0)}, SourceType: v3listenerpb.FilterChainMatch_EXTERNAL, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { // v6 wildcard destination prefix. @@ -1729,18 +1739,18 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("::", 0)}, SourceType: v3listenerpb.FilterChainMatch_EXTERNAL, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("10.0.0.0", 8)}}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, - DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters}, + DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters(t)}, }, wantFC: &FilterChainManager{ dstPrefixMap: map[string]*destPrefixEntry{ @@ -1752,7 +1762,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1771,7 +1781,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1790,7 +1800,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1807,7 +1817,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1824,7 +1834,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1835,7 +1845,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { }, def: &FilterChain{ InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1845,17 +1855,17 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { FilterChainMatch: &v3listenerpb.FilterChainMatch{SourceType: v3listenerpb.FilterChainMatch_SAME_IP_OR_LOOPBACK}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}, SourceType: v3listenerpb.FilterChainMatch_EXTERNAL, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, - DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters}, + DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters(t)}, }, wantFC: &FilterChainManager{ dstPrefixMap: map[string]*destPrefixEntry{ @@ -1868,7 +1878,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1887,7 +1897,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1898,7 +1908,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { }, def: &FilterChain{ InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1908,17 +1918,17 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { FilterChainMatch: &v3listenerpb.FilterChainMatch{SourcePrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("10.0.0.0", 8)}}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}, SourcePrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, - DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters}, + DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters(t)}, }, wantFC: &FilterChainManager{ dstPrefixMap: map[string]*destPrefixEntry{ @@ -1931,7 +1941,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1949,7 +1959,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1960,7 +1970,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { }, def: &FilterChain{ InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1970,7 +1980,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { FilterChainMatch: &v3listenerpb.FilterChainMatch{SourcePorts: []uint32{1, 2, 3}}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ @@ -1979,10 +1989,10 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { SourceType: v3listenerpb.FilterChainMatch_EXTERNAL, SourcePorts: []uint32{1, 2, 3}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, - DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters}, + DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters(t)}, }, wantFC: &FilterChainManager{ dstPrefixMap: map[string]*destPrefixEntry{ @@ -1994,15 +2004,15 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 1: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, 2: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, 3: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -2022,15 +2032,15 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 1: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, 2: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, 3: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -2041,7 +2051,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { }, def: &FilterChain{ InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -2051,18 +2061,18 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { FilterChainMatch: &v3listenerpb.FilterChainMatch{}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("10.0.0.0", 8)}, TransportProtocol: "raw_buffer", }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { // This chain will be dropped in favor of the above @@ -2076,7 +2086,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { SourceType: v3listenerpb.FilterChainMatch_EXTERNAL, SourcePrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("10.0.0.0", 16)}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { // This chain will be dropped for unsupported server @@ -2085,7 +2095,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.100.1", 32)}, ServerNames: []string{"foo", "bar"}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { // This chain will be dropped for unsupported transport @@ -2094,7 +2104,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.100.2", 32)}, TransportProtocol: "not-raw-buffer", }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { // This chain will be dropped for unsupported @@ -2103,10 +2113,10 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.100.3", 32)}, ApplicationProtocols: []string{"h2"}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, - DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters}, + DefaultFilterChain: &v3listenerpb.FilterChain{Filters: emptyValidNetworkFilters(t)}, }, wantFC: &FilterChainManager{ dstPrefixMap: map[string]*destPrefixEntry{ @@ -2118,7 +2128,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -2135,7 +2145,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -2152,7 +2162,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -2175,7 +2185,7 @@ func (s) TestNewFilterChainImpl_Success_AllCombinations(t *testing.T) { }, def: &FilterChain{ InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -2207,7 +2217,7 @@ func (s) TestLookup_Failures(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { FilterChainMatch: &v3listenerpb.FilterChainMatch{PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -2226,7 +2236,7 @@ func (s) TestLookup_Failures(t *testing.T) { PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}, SourceType: v3listenerpb.FilterChainMatch_SAME_IP_OR_LOOPBACK, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -2246,7 +2256,7 @@ func (s) TestLookup_Failures(t *testing.T) { SourcePrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 24)}, SourceType: v3listenerpb.FilterChainMatch_SAME_IP_OR_LOOPBACK, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -2263,14 +2273,14 @@ func (s) TestLookup_Failures(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { FilterChainMatch: &v3listenerpb.FilterChainMatch{SourcePorts: []uint32{1, 2, 3}}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}, SourcePorts: []uint32{1}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -2289,7 +2299,7 @@ func (s) TestLookup_Failures(t *testing.T) { FilterChains: []*v3listenerpb.FilterChain{ { FilterChainMatch: &v3listenerpb.FilterChainMatch{SourcePorts: []uint32{1, 2, 3}}, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -2312,13 +2322,13 @@ func (s) TestLookup_Failures(t *testing.T) { PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.100.1", 32)}, ServerNames: []string{"foo"}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.100.0", 16)}, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, }, @@ -2359,14 +2369,14 @@ func (s) TestLookup_Successes(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{InstanceName: "instance1"}, }, }), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, }, // A default filter chain with an empty transport socket. @@ -2374,49 +2384,49 @@ func (s) TestLookup_Successes(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{InstanceName: "default"}, }, }), }, }, - Filters: emptyValidNetworkFilters, + Filters: emptyValidNetworkFilters(t), }, } lisWithoutDefaultChain := &v3listenerpb.Listener{ FilterChains: []*v3listenerpb.FilterChain{ { - TransportSocket: transportSocketWithInstanceName("unspecified-dest-and-source-prefix"), - Filters: emptyValidNetworkFilters, + TransportSocket: transportSocketWithInstanceName(t, "unspecified-dest-and-source-prefix"), + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("0.0.0.0", 0)}, SourcePrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("0.0.0.0", 0)}, }, - TransportSocket: transportSocketWithInstanceName("wildcard-prefixes-v4"), - Filters: emptyValidNetworkFilters, + TransportSocket: transportSocketWithInstanceName(t, "wildcard-prefixes-v4"), + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ SourcePrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("::", 0)}, }, - TransportSocket: transportSocketWithInstanceName("wildcard-source-prefix-v6"), - Filters: emptyValidNetworkFilters, + TransportSocket: transportSocketWithInstanceName(t, "wildcard-source-prefix-v6"), + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 16)}}, - TransportSocket: transportSocketWithInstanceName("specific-destination-prefix-unspecified-source-type"), - Filters: emptyValidNetworkFilters, + TransportSocket: transportSocketWithInstanceName(t, "specific-destination-prefix-unspecified-source-type"), + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ PrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.1.1", 24)}, SourceType: v3listenerpb.FilterChainMatch_EXTERNAL, }, - TransportSocket: transportSocketWithInstanceName("specific-destination-prefix-specific-source-type"), - Filters: emptyValidNetworkFilters, + TransportSocket: transportSocketWithInstanceName(t, "specific-destination-prefix-specific-source-type"), + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ @@ -2424,8 +2434,8 @@ func (s) TestLookup_Successes(t *testing.T) { SourcePrefixRanges: []*v3corepb.CidrRange{cidrRangeFromAddressAndPrefixLen("192.168.92.1", 24)}, SourceType: v3listenerpb.FilterChainMatch_EXTERNAL, }, - TransportSocket: transportSocketWithInstanceName("specific-destination-prefix-specific-source-type-specific-source-prefix"), - Filters: emptyValidNetworkFilters, + TransportSocket: transportSocketWithInstanceName(t, "specific-destination-prefix-specific-source-type-specific-source-prefix"), + Filters: emptyValidNetworkFilters(t), }, { FilterChainMatch: &v3listenerpb.FilterChainMatch{ @@ -2434,8 +2444,8 @@ func (s) TestLookup_Successes(t *testing.T) { SourceType: v3listenerpb.FilterChainMatch_EXTERNAL, SourcePorts: []uint32{80}, }, - TransportSocket: transportSocketWithInstanceName("specific-destination-prefix-specific-source-type-specific-source-prefix-specific-source-port"), - Filters: emptyValidNetworkFilters, + TransportSocket: transportSocketWithInstanceName(t, "specific-destination-prefix-specific-source-type-specific-source-prefix-specific-source-port"), + Filters: emptyValidNetworkFilters(t), }, }, } @@ -2456,7 +2466,7 @@ func (s) TestLookup_Successes(t *testing.T) { wantFC: &FilterChain{ SecurityCfg: &SecurityConfig{IdentityInstanceName: "default"}, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, { @@ -2471,7 +2481,7 @@ func (s) TestLookup_Successes(t *testing.T) { wantFC: &FilterChain{ SecurityCfg: &SecurityConfig{IdentityInstanceName: "unspecified-dest-and-source-prefix"}, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, { @@ -2486,7 +2496,7 @@ func (s) TestLookup_Successes(t *testing.T) { wantFC: &FilterChain{ SecurityCfg: &SecurityConfig{IdentityInstanceName: "wildcard-prefixes-v4"}, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, { @@ -2501,7 +2511,7 @@ func (s) TestLookup_Successes(t *testing.T) { wantFC: &FilterChain{ SecurityCfg: &SecurityConfig{IdentityInstanceName: "wildcard-source-prefix-v6"}, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, { @@ -2516,7 +2526,7 @@ func (s) TestLookup_Successes(t *testing.T) { wantFC: &FilterChain{ SecurityCfg: &SecurityConfig{IdentityInstanceName: "specific-destination-prefix-unspecified-source-type"}, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, { @@ -2531,7 +2541,7 @@ func (s) TestLookup_Successes(t *testing.T) { wantFC: &FilterChain{ SecurityCfg: &SecurityConfig{IdentityInstanceName: "specific-destination-prefix-specific-source-type"}, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, { @@ -2546,7 +2556,7 @@ func (s) TestLookup_Successes(t *testing.T) { wantFC: &FilterChain{ SecurityCfg: &SecurityConfig{IdentityInstanceName: "specific-destination-prefix-specific-source-type-specific-source-prefix"}, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, { @@ -2561,7 +2571,7 @@ func (s) TestLookup_Successes(t *testing.T) { wantFC: &FilterChain{ SecurityCfg: &SecurityConfig{IdentityInstanceName: "specific-destination-prefix-specific-source-type-specific-source-prefix-specific-source-port"}, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, } @@ -2949,11 +2959,11 @@ func ipNetFromCIDR(cidr string) *net.IPNet { return ipnet } -func transportSocketWithInstanceName(name string) *v3corepb.TransportSocket { +func transportSocketWithInstanceName(t *testing.T, name string) *v3corepb.TransportSocket { return &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{InstanceName: name}, }, diff --git a/xds/internal/xdsclient/xdsresource/tests/unmarshal_cds_test.go b/xds/internal/xdsclient/xdsresource/tests/unmarshal_cds_test.go index d522eac8261d..3e8f3e443555 100644 --- a/xds/internal/xdsclient/xdsresource/tests/unmarshal_cds_test.go +++ b/xds/internal/xdsclient/xdsresource/tests/unmarshal_cds_test.go @@ -68,13 +68,13 @@ const ( var emptyUpdate = xdsresource.ClusterUpdate{ClusterName: clusterName, LRSServerConfig: xdsresource.ClusterLRSOff} -func wrrLocality(m proto.Message) *v3wrrlocalitypb.WrrLocality { +func wrrLocality(t *testing.T, m proto.Message) *v3wrrlocalitypb.WrrLocality { return &v3wrrlocalitypb.WrrLocality{ EndpointPickingPolicy: &v3clusterpb.LoadBalancingPolicy{ Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(m), + TypedConfig: testutils.MarshalAny(t, m), }, }, }, @@ -82,8 +82,8 @@ func wrrLocality(m proto.Message) *v3wrrlocalitypb.WrrLocality { } } -func wrrLocalityAny(m proto.Message) *anypb.Any { - return testutils.MarshalAny(wrrLocality(m)) +func wrrLocalityAny(t *testing.T, m proto.Message) *anypb.Any { + return testutils.MarshalAny(t, wrrLocality(t, m)) } type customLBConfig struct { @@ -162,7 +162,7 @@ func (s) TestValidateCluster_Success(t *testing.T) { ClusterDiscoveryType: &v3clusterpb.Cluster_ClusterType{ ClusterType: &v3clusterpb.Cluster_CustomClusterType{ Name: "envoy.clusters.aggregate", - TypedConfig: testutils.MarshalAny(&v3aggregateclusterpb.ClusterConfig{ + TypedConfig: testutils.MarshalAny(t, &v3aggregateclusterpb.ClusterConfig{ Clusters: []string{"a", "b", "c"}, }), }, @@ -385,7 +385,7 @@ func (s) TestValidateCluster_Success(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3ringhashpb.RingHash{ + TypedConfig: testutils.MarshalAny(t, &v3ringhashpb.RingHash{ HashFunction: v3ringhashpb.RingHash_XX_HASH, MinimumRingSize: wrapperspb.UInt64(10), MaximumRingSize: wrapperspb.UInt64(100), @@ -424,7 +424,7 @@ func (s) TestValidateCluster_Success(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: wrrLocalityAny(&v3roundrobinpb.RoundRobin{}), + TypedConfig: wrrLocalityAny(t, &v3roundrobinpb.RoundRobin{}), }, }, }, @@ -460,7 +460,7 @@ func (s) TestValidateCluster_Success(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: wrrLocalityAny(&v3xdsxdstypepb.TypedStruct{ + TypedConfig: wrrLocalityAny(t, &v3xdsxdstypepb.TypedStruct{ TypeUrl: "type.googleapis.com/myorg.MyCustomLeastRequestPolicy", Value: &structpb.Struct{}, }), @@ -507,7 +507,7 @@ func (s) TestValidateCluster_Success(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3ringhashpb.RingHash{ + TypedConfig: testutils.MarshalAny(t, &v3ringhashpb.RingHash{ HashFunction: v3ringhashpb.RingHash_XX_HASH, MinimumRingSize: wrapperspb.UInt64(10), MaximumRingSize: wrapperspb.UInt64(100), @@ -554,7 +554,7 @@ func (s) TestValidateCluster_Success(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3ringhashpb.RingHash{ + TypedConfig: testutils.MarshalAny(t, &v3ringhashpb.RingHash{ HashFunction: v3ringhashpb.RingHash_XX_HASH, MinimumRingSize: wrapperspb.UInt64(10), MaximumRingSize: wrapperspb.UInt64(100), diff --git a/xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go b/xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go index f54935e741e3..5cf329e3c1bf 100644 --- a/xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go +++ b/xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go @@ -204,7 +204,7 @@ func (s) TestValidateCluster_Failure(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3ringhashpb.RingHash{ + TypedConfig: testutils.MarshalAny(t, &v3ringhashpb.RingHash{ HashFunction: v3ringhashpb.RingHash_XX_HASH, MinimumRingSize: wrapperspb.UInt64(10), MaximumRingSize: wrapperspb.UInt64(ringHashSizeUpperBound + 1), @@ -234,7 +234,7 @@ func (s) TestValidateCluster_Failure(t *testing.T) { Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{ { TypedExtensionConfig: &v3corepb.TypedExtensionConfig{ - TypedConfig: testutils.MarshalAny(&v3leastrequestpb.LeastRequest{}), + TypedConfig: testutils.MarshalAny(t, &v3leastrequestpb.LeastRequest{}), }, }, }, @@ -250,7 +250,7 @@ func (s) TestValidateCluster_Failure(t *testing.T) { ClusterDiscoveryType: &v3clusterpb.Cluster_ClusterType{ ClusterType: &v3clusterpb.Cluster_CustomClusterType{ Name: "envoy.clusters.aggregate", - TypedConfig: testutils.MarshalAny(&v3aggregateclusterpb.ClusterConfig{}), + TypedConfig: testutils.MarshalAny(t, &v3aggregateclusterpb.ClusterConfig{}), }, }, LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN, @@ -265,7 +265,7 @@ func (s) TestValidateCluster_Failure(t *testing.T) { ClusterDiscoveryType: &v3clusterpb.Cluster_ClusterType{ ClusterType: &v3clusterpb.Cluster_CustomClusterType{ Name: "envoy.clusters.aggregate", - TypedConfig: testutils.MarshalAny(&v3aggregateclusterpb.ClusterConfig{ + TypedConfig: testutils.MarshalAny(t, &v3aggregateclusterpb.ClusterConfig{ Clusters: []string{}, }), }, @@ -313,7 +313,7 @@ func (s) TestValidateClusterWithSecurityConfig_EnvVarOff(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_ValidationContextCertificateProviderInstance{ ValidationContextCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ @@ -638,7 +638,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN, TransportSocket: &v3corepb.TransportSocket{ ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsParams: &v3tlspb.TlsParameters{}, }, @@ -663,7 +663,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN, TransportSocket: &v3corepb.TransportSocket{ ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ CustomHandshaker: &v3corepb.TypedExtensionConfig{}, }, @@ -688,7 +688,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN, TransportSocket: &v3corepb.TransportSocket{ ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_ValidationContextSdsSecretConfig{ ValidationContextSdsSecretConfig: &v3tlspb.SdsSecretConfig{ @@ -717,7 +717,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN, TransportSocket: &v3corepb.TransportSocket{ ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{}, }), }, @@ -740,7 +740,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN, TransportSocket: &v3corepb.TransportSocket{ ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_CombinedValidationContext{ CombinedValidationContext: &v3tlspb.CommonTlsContext_CombinedCertificateValidationContext{ @@ -777,7 +777,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN, TransportSocket: &v3corepb.TransportSocket{ ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_CombinedValidationContext{ CombinedValidationContext: &v3tlspb.CommonTlsContext_CombinedCertificateValidationContext{ @@ -814,7 +814,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN, TransportSocket: &v3corepb.TransportSocket{ ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_CombinedValidationContext{ CombinedValidationContext: &v3tlspb.CommonTlsContext_CombinedCertificateValidationContext{ @@ -851,7 +851,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN, TransportSocket: &v3corepb.TransportSocket{ ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_CombinedValidationContext{ CombinedValidationContext: &v3tlspb.CommonTlsContext_CombinedCertificateValidationContext{ @@ -888,7 +888,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN, TransportSocket: &v3corepb.TransportSocket{ ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_CombinedValidationContext{ CombinedValidationContext: &v3tlspb.CommonTlsContext_CombinedCertificateValidationContext{ @@ -927,7 +927,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_ValidationContextCertificateProviderInstance{ ValidationContextCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ @@ -967,7 +967,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_ValidationContext{ ValidationContext: &v3tlspb.CertificateValidationContext{ @@ -1009,7 +1009,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ InstanceName: identityPluginInstance, @@ -1055,7 +1055,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ InstanceName: identityPluginInstance, @@ -1103,7 +1103,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ InstanceName: identityPluginInstance, @@ -1170,7 +1170,7 @@ func (s) TestValidateClusterWithSecurityConfig(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ InstanceName: identityPluginInstance, @@ -1241,7 +1241,7 @@ func (s) TestUnmarshalCluster(t *testing.T) { v3Service = "v3Service" ) var ( - v3ClusterAny = testutils.MarshalAny(&v3clusterpb.Cluster{ + v3ClusterAny = testutils.MarshalAny(t, &v3clusterpb.Cluster{ Name: v3ClusterName, ClusterDiscoveryType: &v3clusterpb.Cluster_Type{Type: v3clusterpb.Cluster_EDS}, EdsClusterConfig: &v3clusterpb.Cluster_EdsClusterConfig{ @@ -1260,7 +1260,7 @@ func (s) TestUnmarshalCluster(t *testing.T) { }, }) - v3ClusterAnyWithEDSConfigSourceSelf = testutils.MarshalAny(&v3clusterpb.Cluster{ + v3ClusterAnyWithEDSConfigSourceSelf = testutils.MarshalAny(t, &v3clusterpb.Cluster{ Name: v3ClusterName, ClusterDiscoveryType: &v3clusterpb.Cluster_Type{Type: v3clusterpb.Cluster_EDS}, EdsClusterConfig: &v3clusterpb.Cluster_EdsClusterConfig{ @@ -1300,7 +1300,7 @@ func (s) TestUnmarshalCluster(t *testing.T) { }, { name: "bad cluster resource", - resource: testutils.MarshalAny(&v3clusterpb.Cluster{ + resource: testutils.MarshalAny(t, &v3clusterpb.Cluster{ Name: "test", ClusterDiscoveryType: &v3clusterpb.Cluster_Type{Type: v3clusterpb.Cluster_STATIC}, }), @@ -1309,7 +1309,7 @@ func (s) TestUnmarshalCluster(t *testing.T) { }, { name: "cluster resource with non-self lrs_server field", - resource: testutils.MarshalAny(&v3clusterpb.Cluster{ + resource: testutils.MarshalAny(t, &v3clusterpb.Cluster{ Name: "test", ClusterDiscoveryType: &v3clusterpb.Cluster_Type{Type: v3clusterpb.Cluster_EDS}, EdsClusterConfig: &v3clusterpb.Cluster_EdsClusterConfig{ @@ -1342,7 +1342,7 @@ func (s) TestUnmarshalCluster(t *testing.T) { }, { name: "v3 cluster wrapped", - resource: testutils.MarshalAny(&v3discoverypb.Resource{Resource: v3ClusterAny}), + resource: testutils.MarshalAny(t, &v3discoverypb.Resource{Resource: v3ClusterAny}), wantName: v3ClusterName, wantUpdate: ClusterUpdate{ ClusterName: v3ClusterName, @@ -1362,7 +1362,7 @@ func (s) TestUnmarshalCluster(t *testing.T) { }, { name: "xdstp cluster resource with unset EDS service name", - resource: testutils.MarshalAny(&v3clusterpb.Cluster{ + resource: testutils.MarshalAny(t, &v3clusterpb.Cluster{ Name: "xdstp:foo", ClusterDiscoveryType: &v3clusterpb.Cluster_Type{Type: v3clusterpb.Cluster_EDS}, EdsClusterConfig: &v3clusterpb.Cluster_EdsClusterConfig{ diff --git a/xds/internal/xdsclient/xdsresource/unmarshal_eds_test.go b/xds/internal/xdsclient/xdsresource/unmarshal_eds_test.go index cfb452b26fad..a5c466dd4d74 100644 --- a/xds/internal/xdsclient/xdsresource/unmarshal_eds_test.go +++ b/xds/internal/xdsclient/xdsresource/unmarshal_eds_test.go @@ -221,7 +221,7 @@ func (s) TestEDSParseRespProto(t *testing.T) { } func (s) TestUnmarshalEndpoints(t *testing.T) { - var v3EndpointsAny = testutils.MarshalAny(func() *v3endpointpb.ClusterLoadAssignment { + var v3EndpointsAny = testutils.MarshalAny(t, func() *v3endpointpb.ClusterLoadAssignment { clab0 := newClaBuilder("test", nil) clab0.addLocality("locality-1", 1, 1, []string{"addr1:314"}, &addLocalityOptions{ Health: []v3corepb.HealthStatus{v3corepb.HealthStatus_UNHEALTHY}, @@ -256,7 +256,7 @@ func (s) TestUnmarshalEndpoints(t *testing.T) { }, { name: "bad endpoints resource", - resource: testutils.MarshalAny(func() *v3endpointpb.ClusterLoadAssignment { + resource: testutils.MarshalAny(t, func() *v3endpointpb.ClusterLoadAssignment { clab0 := newClaBuilder("test", nil) clab0.addLocality("locality-1", 1, 0, []string{"addr1:314"}, nil) clab0.addLocality("locality-2", 1, 2, []string{"addr2:159"}, nil) @@ -298,7 +298,7 @@ func (s) TestUnmarshalEndpoints(t *testing.T) { }, { name: "v3 endpoints wrapped", - resource: testutils.MarshalAny(&v3discoverypb.Resource{Resource: v3EndpointsAny}), + resource: testutils.MarshalAny(t, &v3discoverypb.Resource{Resource: v3EndpointsAny}), wantName: "test", wantUpdate: EndpointsUpdate{ Drops: nil, diff --git a/xds/internal/xdsclient/xdsresource/unmarshal_lds_test.go b/xds/internal/xdsclient/xdsresource/unmarshal_lds_test.go index 2dfeb5965b72..5e412af324d0 100644 --- a/xds/internal/xdsclient/xdsresource/unmarshal_lds_test.go +++ b/xds/internal/xdsclient/xdsresource/unmarshal_lds_test.go @@ -67,11 +67,11 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { } oldTypedStructFilter = &v3httppb.HttpFilter{ Name: "customFilter", - ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: wrappedCustomFilterOldTypedStructConfig}, + ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: testutils.MarshalAny(t, customFilterOldTypedStructConfig)}, } newTypedStructFilter = &v3httppb.HttpFilter{ Name: "customFilter", - ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: wrappedCustomFilterNewTypedStructConfig}, + ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: testutils.MarshalAny(t, customFilterNewTypedStructConfig)}, } customOptionalFilter = &v3httppb.HttpFilter{ Name: "customFilter", @@ -113,10 +113,10 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: unknownFilterConfig}, IsOptional: true, } - v3LisWithInlineRoute = testutils.MarshalAny(&v3listenerpb.Listener{ + v3LisWithInlineRoute = testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, ApiListener: &v3listenerpb.ApiListener{ - ApiListener: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + ApiListener: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: &v3routepb.RouteConfiguration{ Name: routeName, @@ -140,10 +140,10 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { }) v3LisWithFilters = func(fs ...*v3httppb.HttpFilter) *anypb.Any { fs = append(fs, emptyRouterFilter) - return testutils.MarshalAny(&v3listenerpb.Listener{ + return testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, ApiListener: &v3listenerpb.ApiListener{ - ApiListener: testutils.MarshalAny( + ApiListener: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ @@ -162,10 +162,10 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { }) } v3LisToTestRBAC = func(xffNumTrustedHops uint32, originalIpDetectionExtensions []*v3corepb.TypedExtensionConfig) *anypb.Any { - return testutils.MarshalAny(&v3listenerpb.Listener{ + return testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, ApiListener: &v3listenerpb.ApiListener{ - ApiListener: testutils.MarshalAny( + ApiListener: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ @@ -186,10 +186,10 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { }) } - v3ListenerWithCDSConfigSourceSelf = testutils.MarshalAny(&v3listenerpb.Listener{ + v3ListenerWithCDSConfigSourceSelf = testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, ApiListener: &v3listenerpb.ApiListener{ - ApiListener: testutils.MarshalAny( + ApiListener: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ @@ -240,10 +240,10 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { }, { name: "wrong type in apiListener", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, ApiListener: &v3listenerpb.ApiListener{ - ApiListener: testutils.MarshalAny(&v2xdspb.Listener{}), + ApiListener: testutils.MarshalAny(t, &v2xdspb.Listener{}), }, }), wantName: v3LDSTarget, @@ -251,10 +251,10 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { }, { name: "empty httpConnMgr in apiListener", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, ApiListener: &v3listenerpb.ApiListener{ - ApiListener: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + ApiListener: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{}, }, @@ -266,10 +266,10 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { }, { name: "scopedRoutes routeConfig in apiListener", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, ApiListener: &v3listenerpb.ApiListener{ - ApiListener: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + ApiListener: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_ScopedRoutes{}, }), }, @@ -283,16 +283,16 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { wantName: v3LDSTarget, wantUpdate: ListenerUpdate{ RouteConfigName: v3RouteConfigName, - HTTPFilters: []HTTPFilter{routerFilter}, + HTTPFilters: []HTTPFilter{makeRouterFilter(t)}, Raw: v3ListenerWithCDSConfigSourceSelf, }, }, { name: "rds.ConfigSource in apiListener is not ADS or Self", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, ApiListener: &v3listenerpb.ApiListener{ - ApiListener: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + ApiListener: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ ConfigSource: &v3corepb.ConfigSource{ @@ -316,16 +316,16 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { wantUpdate: ListenerUpdate{ RouteConfigName: v3RouteConfigName, MaxStreamDuration: time.Second, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), Raw: v3LisWithFilters(), }, }, { name: "v3 no terminal filter", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, ApiListener: &v3listenerpb.ApiListener{ - ApiListener: testutils.MarshalAny( + ApiListener: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_Rds{ Rds: &v3httppb.Rds{ @@ -356,7 +356,7 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { Filter: httpFilter{}, Config: filterConfig{Cfg: customFilterConfig}, }, - routerFilter, + makeRouterFilter(t), }, Raw: v3LisWithFilters(customFilter), }, @@ -373,7 +373,7 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { Filter: httpFilter{}, Config: filterConfig{Cfg: customFilterOldTypedStructConfig}, }, - routerFilter, + makeRouterFilter(t), }, Raw: v3LisWithFilters(oldTypedStructFilter), }, @@ -390,7 +390,7 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { Filter: httpFilter{}, Config: filterConfig{Cfg: customFilterNewTypedStructConfig}, }, - routerFilter, + makeRouterFilter(t), }, Raw: v3LisWithFilters(newTypedStructFilter), }, @@ -407,7 +407,7 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { Filter: httpFilter{}, Config: filterConfig{Cfg: customFilterConfig}, }, - routerFilter, + makeRouterFilter(t), }, Raw: v3LisWithFilters(customOptionalFilter), }, @@ -433,7 +433,7 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { Filter: httpFilter{}, Config: filterConfig{Cfg: customFilterConfig}, }, - routerFilter, + makeRouterFilter(t), }, Raw: v3LisWithFilters(customFilter, customFilter2), }, @@ -452,7 +452,7 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { RouteConfigName: v3RouteConfigName, MaxStreamDuration: time.Second, Raw: v3LisWithFilters(serverOnlyOptionalCustomFilter), - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, { @@ -467,7 +467,7 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { Filter: clientOnlyHTTPFilter{}, Config: filterConfig{Cfg: clientOnlyCustomFilterConfig}, }, - routerFilter}, + makeRouterFilter(t)}, Raw: v3LisWithFilters(clientOnlyCustomFilter), }, }, @@ -496,7 +496,7 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { wantUpdate: ListenerUpdate{ RouteConfigName: v3RouteConfigName, MaxStreamDuration: time.Second, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), Raw: v3LisWithFilters(unknownOptionalFilter), }, }, @@ -507,18 +507,18 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { wantUpdate: ListenerUpdate{ RouteConfigName: v3RouteConfigName, MaxStreamDuration: time.Second, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), Raw: v3LisWithFilters(), }, }, { name: "v3 listener resource wrapped", - resource: testutils.MarshalAny(&v3discoverypb.Resource{Resource: v3LisWithFilters()}), + resource: testutils.MarshalAny(t, &v3discoverypb.Resource{Resource: v3LisWithFilters()}), wantName: v3LDSTarget, wantUpdate: ListenerUpdate{ RouteConfigName: v3RouteConfigName, MaxStreamDuration: time.Second, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), Raw: v3LisWithFilters(), }, }, @@ -533,7 +533,7 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { wantUpdate: ListenerUpdate{ RouteConfigName: v3RouteConfigName, MaxStreamDuration: time.Second, - HTTPFilters: []HTTPFilter{routerFilter}, + HTTPFilters: []HTTPFilter{makeRouterFilter(t)}, Raw: v3LisToTestRBAC(0, nil), }, }, @@ -570,7 +570,7 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { }}}, MaxStreamDuration: time.Second, Raw: v3LisWithInlineRoute, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, } @@ -626,7 +626,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { { Name: "filter-1", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: routeConfig, }, @@ -645,7 +645,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, }, } - listenerEmptyTransportSocket = testutils.MarshalAny(&v3listenerpb.Listener{ + listenerEmptyTransportSocket = testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -655,7 +655,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, }, }) - listenerNoValidationContextDeprecatedFields = testutils.MarshalAny(&v3listenerpb.Listener{ + listenerNoValidationContextDeprecatedFields = testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -665,7 +665,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ InstanceName: "identityPluginInstance", @@ -683,7 +683,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ InstanceName: "defaultIdentityPluginInstance", @@ -695,7 +695,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, }, }) - listenerNoValidationContextNewFields = testutils.MarshalAny(&v3listenerpb.Listener{ + listenerNoValidationContextNewFields = testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -705,7 +705,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ InstanceName: "identityPluginInstance", @@ -723,7 +723,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ InstanceName: "defaultIdentityPluginInstance", @@ -735,7 +735,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, }, }) - listenerWithValidationContextDeprecatedFields = testutils.MarshalAny(&v3listenerpb.Listener{ + listenerWithValidationContextDeprecatedFields = testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -745,7 +745,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ RequireClientCertificate: &wrapperspb.BoolValue{Value: true}, CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ @@ -770,7 +770,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ RequireClientCertificate: &wrapperspb.BoolValue{Value: true}, CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ @@ -789,7 +789,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, }, }) - listenerWithValidationContextNewFields = testutils.MarshalAny(&v3listenerpb.Listener{ + listenerWithValidationContextNewFields = testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -799,7 +799,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ RequireClientCertificate: &wrapperspb.BoolValue{Value: true}, CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ @@ -826,7 +826,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ RequireClientCertificate: &wrapperspb.BoolValue{Value: true}, CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ @@ -851,7 +851,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }) ) v3LisToTestRBAC := func(xffNumTrustedHops uint32, originalIpDetectionExtensions []*v3corepb.TypedExtensionConfig) *anypb.Any { - return testutils.MarshalAny(&v3listenerpb.Listener{ + return testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -861,7 +861,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { { Name: "filter-1", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: routeConfig, }, @@ -877,7 +877,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }) } v3LisWithBadRBACConfiguration := func(rbacCfg *v3rbacpb.RBAC) *anypb.Any { - return testutils.MarshalAny(&v3listenerpb.Listener{ + return testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -887,7 +887,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { { Name: "filter-1", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: routeConfig, }, @@ -940,7 +940,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }{ { name: "non-empty listener filters", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, ListenerFilters: []*v3listenerpb.ListenerFilter{ {Name: "listener-filter-1"}, @@ -951,7 +951,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "use_original_dst is set", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, UseOriginalDst: &wrapperspb.BoolValue{Value: true}, }), @@ -960,13 +960,13 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "no address field", - resource: testutils.MarshalAny(&v3listenerpb.Listener{Name: v3LDSTarget}), + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{Name: v3LDSTarget}), wantName: v3LDSTarget, wantErr: "no address field in LDS response", }, { name: "no socket address field", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: &v3corepb.Address{}, }), @@ -975,7 +975,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "no filter chains and no default filter chain", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -990,7 +990,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "missing http connection manager network filter", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1004,7 +1004,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "missing filter name in http filter", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1013,7 +1013,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { Filters: []*v3listenerpb.Filter{ { ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{}), + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{}), }, }, }, @@ -1025,7 +1025,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "duplicate filter names in http filter", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1035,7 +1035,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { { Name: "name", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: routeConfig, }, @@ -1046,7 +1046,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { { Name: "name", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: routeConfig, }, @@ -1063,7 +1063,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "no terminal filter", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1073,7 +1073,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { { Name: "name", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: routeConfig, }, @@ -1089,7 +1089,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "terminal filter not last", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1099,7 +1099,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { { Name: "name", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: routeConfig, }, @@ -1116,7 +1116,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "last not terminal filter", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1126,7 +1126,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { { Name: "name", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{ + TypedConfig: testutils.MarshalAny(t, &v3httppb.HttpConnectionManager{ RouteSpecifier: &v3httppb.HttpConnectionManager_RouteConfig{ RouteConfig: routeConfig, }, @@ -1143,7 +1143,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "unsupported oneof in typed config of http filter", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1163,7 +1163,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "overlapping filter chain match criteria", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1186,7 +1186,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "unsupported network filter", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1196,7 +1196,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { { Name: "name", ConfigType: &v3listenerpb.Filter_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3httppb.LocalReplyConfig{}), + TypedConfig: testutils.MarshalAny(t, &v3httppb.LocalReplyConfig{}), }, }, }, @@ -1208,7 +1208,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "badly marshaled network filter", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1233,7 +1233,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "unexpected transport socket name", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1251,7 +1251,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "unexpected transport socket typedConfig URL", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1261,7 +1261,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.UpstreamTlsContext{}), + TypedConfig: testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{}), }, }, }, @@ -1272,7 +1272,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "badly marshaled transport socket", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1296,7 +1296,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "missing CommonTlsContext", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1306,7 +1306,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{}), + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{}), }, }, }, @@ -1333,7 +1333,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1373,7 +1373,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "unsupported validation context in transport socket", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1383,7 +1383,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{ ValidationContextType: &v3tlspb.CommonTlsContext_ValidationContextSdsSecretConfig{ ValidationContextSdsSecretConfig: &v3tlspb.SdsSecretConfig{ @@ -1418,7 +1418,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { srcPortMap: map[int]*FilterChain{ 0: { InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1434,7 +1434,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "no identity and root certificate providers using deprecated fields", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1444,7 +1444,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ RequireClientCertificate: &wrapperspb.BoolValue{Value: true}, CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateCertificateProviderInstance: &v3tlspb.CommonTlsContext_CertificateProviderInstance{ @@ -1463,7 +1463,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "no identity and root certificate providers using new fields", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1473,7 +1473,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ RequireClientCertificate: &wrapperspb.BoolValue{Value: true}, CommonTlsContext: &v3tlspb.CommonTlsContext{ TlsCertificateProviderInstance: &v3tlspb.CertificateProviderPluginInstance{ @@ -1492,7 +1492,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { }, { name: "no identity certificate provider with require_client_cert", - resource: testutils.MarshalAny(&v3listenerpb.Listener{ + resource: testutils.MarshalAny(t, &v3listenerpb.Listener{ Name: v3LDSTarget, Address: localSocketAddress, FilterChains: []*v3listenerpb.FilterChain{ @@ -1502,7 +1502,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { TransportSocket: &v3corepb.TransportSocket{ Name: "envoy.transport_sockets.tls", ConfigType: &v3corepb.TransportSocket_TypedConfig{ - TypedConfig: testutils.MarshalAny(&v3tlspb.DownstreamTlsContext{ + TypedConfig: testutils.MarshalAny(t, &v3tlspb.DownstreamTlsContext{ CommonTlsContext: &v3tlspb.CommonTlsContext{}, }), }, @@ -1535,7 +1535,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { IdentityCertName: "identityCertName", }, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1550,7 +1550,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { IdentityCertName: "defaultIdentityCertName", }, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1579,7 +1579,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { IdentityCertName: "identityCertName", }, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1594,7 +1594,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { IdentityCertName: "defaultIdentityCertName", }, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1626,7 +1626,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { RequireClientCert: true, }, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1644,7 +1644,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { RequireClientCert: true, }, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1676,7 +1676,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { RequireClientCert: true, }, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1694,7 +1694,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) { RequireClientCert: true, }, InlineRouteConfig: inlineRouteConfig, - HTTPFilters: routerFilterList, + HTTPFilters: makeRouterFilterList(t), }, }, }, @@ -1838,7 +1838,6 @@ var customFilterOldTypedStructConfig = &v1udpaudpatypepb.TypedStruct{ }, }, } -var wrappedCustomFilterOldTypedStructConfig *anypb.Any // This custom filter uses the new TypedStruct message from the cncf/xds repo. var customFilterNewTypedStructConfig = &v3xdsxdstypepb.TypedStruct{ @@ -1849,20 +1848,14 @@ var customFilterNewTypedStructConfig = &v3xdsxdstypepb.TypedStruct{ }, }, } -var wrappedCustomFilterNewTypedStructConfig *anypb.Any - -func init() { - wrappedCustomFilterOldTypedStructConfig = testutils.MarshalAny(customFilterOldTypedStructConfig) - wrappedCustomFilterNewTypedStructConfig = testutils.MarshalAny(customFilterNewTypedStructConfig) -} var unknownFilterConfig = &anypb.Any{ TypeUrl: "unknown.custom.filter", Value: []byte{1, 2, 3}, } -func wrappedOptionalFilter(name string) *anypb.Any { - return testutils.MarshalAny(&v3routepb.FilterConfig{ +func wrappedOptionalFilter(t *testing.T, name string) *anypb.Any { + return testutils.MarshalAny(t, &v3routepb.FilterConfig{ IsOptional: true, Config: &anypb.Any{ TypeUrl: name, diff --git a/xds/internal/xdsclient/xdsresource/unmarshal_rds_test.go b/xds/internal/xdsclient/xdsresource/unmarshal_rds_test.go index 6435237a3572..65853803c9ac 100644 --- a/xds/internal/xdsclient/xdsresource/unmarshal_rds_test.go +++ b/xds/internal/xdsclient/xdsresource/unmarshal_rds_test.go @@ -570,17 +570,17 @@ func (s) TestRDSGenerateRDSUpdateFromRouteConfiguration(t *testing.T) { }, { name: "good-route-config-with-http-filter-config-in-old-typed-struct", - rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedCustomFilterOldTypedStructConfig}), + rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"foo": testutils.MarshalAny(t, customFilterOldTypedStructConfig)}), wantUpdate: goodUpdateWithFilterConfigs(map[string]httpfilter.FilterConfig{"foo": filterConfig{Override: customFilterOldTypedStructConfig}}), }, { name: "good-route-config-with-http-filter-config-in-new-typed-struct", - rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedCustomFilterNewTypedStructConfig}), + rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"foo": testutils.MarshalAny(t, customFilterNewTypedStructConfig)}), wantUpdate: goodUpdateWithFilterConfigs(map[string]httpfilter.FilterConfig{"foo": filterConfig{Override: customFilterNewTypedStructConfig}}), }, { name: "good-route-config-with-optional-http-filter-config", - rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter("custom.filter")}), + rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter(t, "custom.filter")}), wantUpdate: goodUpdateWithFilterConfigs(map[string]httpfilter.FilterConfig{"foo": filterConfig{Override: customFilterConfig}}), }, { @@ -590,7 +590,7 @@ func (s) TestRDSGenerateRDSUpdateFromRouteConfiguration(t *testing.T) { }, { name: "good-route-config-with-http-optional-err-filter-config", - rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter("err.custom.filter")}), + rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter(t, "err.custom.filter")}), wantError: true, }, { @@ -600,12 +600,12 @@ func (s) TestRDSGenerateRDSUpdateFromRouteConfiguration(t *testing.T) { }, { name: "good-route-config-with-http-optional-unknown-filter-config", - rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter("unknown.custom.filter")}), + rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter(t, "unknown.custom.filter")}), wantUpdate: goodUpdateWithFilterConfigs(nil), }, { name: "good-route-config-with-bad-rbac-http-filter-configuration", - rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"rbac": testutils.MarshalAny(&v3rbacpb.RBACPerRoute{Rbac: &v3rbacpb.RBAC{ + rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"rbac": testutils.MarshalAny(t, &v3rbacpb.RBACPerRoute{Rbac: &v3rbacpb.RBAC{ Rules: &rpb.RBAC{ Action: rpb.RBAC_ALLOW, Policies: map[string]*rpb.Policy{ @@ -836,7 +836,7 @@ func (s) TestUnmarshalRouteConfig(t *testing.T) { }, }, } - v3RouteConfig = testutils.MarshalAny(&v3routepb.RouteConfiguration{ + v3RouteConfig = testutils.MarshalAny(t, &v3routepb.RouteConfiguration{ Name: v3RouteConfigName, VirtualHosts: v3VirtualHost, }) @@ -886,7 +886,7 @@ func (s) TestUnmarshalRouteConfig(t *testing.T) { }, { name: "v3 routeConfig resource wrapped", - resource: testutils.MarshalAny(&v3discoverypb.Resource{Resource: v3RouteConfig}), + resource: testutils.MarshalAny(t, &v3discoverypb.Resource{Resource: v3RouteConfig}), wantName: v3RouteConfigName, wantUpdate: RouteConfigUpdate{ VirtualHosts: []*VirtualHost{ @@ -1471,12 +1471,12 @@ func (s) TestRoutesProtoToSlice(t *testing.T) { }, { name: "with custom HTTP filter config in typed struct", - routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedCustomFilterOldTypedStructConfig}), + routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": testutils.MarshalAny(t, customFilterOldTypedStructConfig)}), wantRoutes: goodUpdateWithFilterConfigs(map[string]httpfilter.FilterConfig{"foo": filterConfig{Override: customFilterOldTypedStructConfig}}), }, { name: "with optional custom HTTP filter config", - routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter("custom.filter")}), + routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter(t, "custom.filter")}), wantRoutes: goodUpdateWithFilterConfigs(map[string]httpfilter.FilterConfig{"foo": filterConfig{Override: customFilterConfig}}), }, { @@ -1486,7 +1486,7 @@ func (s) TestRoutesProtoToSlice(t *testing.T) { }, { name: "with optional erroring custom HTTP filter config", - routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter("err.custom.filter")}), + routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter(t, "err.custom.filter")}), wantErr: true, }, { @@ -1496,7 +1496,7 @@ func (s) TestRoutesProtoToSlice(t *testing.T) { }, { name: "with optional unknown custom HTTP filter config", - routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter("unknown.custom.filter")}), + routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter(t, "unknown.custom.filter")}), wantRoutes: goodUpdateWithFilterConfigs(nil), }, }