use of io.envoyproxy.envoy.config.listener.v3.FilterChainMatch in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseServerSideListener_nonUniqueFilterChainMatch_sameFilter.
@Test
public void parseServerSideListener_nonUniqueFilterChainMatch_sameFilter() throws ResourceInvalidException {
Filter filter1 = buildHttpConnectionManagerFilter(HttpFilter.newBuilder().setName("http-filter-1").setTypedConfig(Any.pack(Router.newBuilder().build())).setIsOptional(true).build());
FilterChainMatch filterChainMatch1 = FilterChainMatch.newBuilder().addAllSourcePorts(Arrays.asList(80, 8080)).addAllPrefixRanges(Arrays.asList(CidrRange.newBuilder().setAddressPrefix("10.0.0.0").setPrefixLen(UInt32Value.of(8)).build())).build();
FilterChain filterChain1 = FilterChain.newBuilder().setName("filter-chain-1").setFilterChainMatch(filterChainMatch1).addFilters(filter1).build();
Filter filter2 = buildHttpConnectionManagerFilter(HttpFilter.newBuilder().setName("http-filter-2").setTypedConfig(Any.pack(Router.newBuilder().build())).setIsOptional(true).build());
FilterChainMatch filterChainMatch2 = FilterChainMatch.newBuilder().addAllSourcePorts(Arrays.asList(443, 8080)).addAllPrefixRanges(Arrays.asList(CidrRange.newBuilder().setAddressPrefix("192.168.0.0").setPrefixLen(UInt32Value.of(16)).build(), CidrRange.newBuilder().setAddressPrefix("192.168.0.0").setPrefixLen(UInt32Value.of(16)).build())).build();
FilterChain filterChain2 = FilterChain.newBuilder().setName("filter-chain-2").setFilterChainMatch(filterChainMatch2).addFilters(filter2).build();
Listener listener = Listener.newBuilder().setName("listener1").setTrafficDirection(TrafficDirection.INBOUND).addAllFilterChains(Arrays.asList(filterChain1, filterChain2)).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("FilterChainMatch must be unique. Found duplicate:");
ClientXdsClient.parseServerSideListener(listener, new HashSet<String>(), null, filterRegistry, null, true);
}
use of io.envoyproxy.envoy.config.listener.v3.FilterChainMatch in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseServerSideListener_uniqueFilterChainMatch.
@Test
public void parseServerSideListener_uniqueFilterChainMatch() throws ResourceInvalidException {
Filter filter1 = buildHttpConnectionManagerFilter(HttpFilter.newBuilder().setName("http-filter-1").setTypedConfig(Any.pack(Router.newBuilder().build())).setIsOptional(true).build());
FilterChainMatch filterChainMatch1 = FilterChainMatch.newBuilder().addAllSourcePorts(Arrays.asList(80, 8080)).addAllPrefixRanges(Arrays.asList(CidrRange.newBuilder().setAddressPrefix("192.168.0.0").setPrefixLen(UInt32Value.of(16)).build(), CidrRange.newBuilder().setAddressPrefix("10.0.0.0").setPrefixLen(UInt32Value.of(8)).build())).setSourceType(FilterChainMatch.ConnectionSourceType.EXTERNAL).build();
FilterChain filterChain1 = FilterChain.newBuilder().setName("filter-chain-1").setFilterChainMatch(filterChainMatch1).addFilters(filter1).build();
Filter filter2 = buildHttpConnectionManagerFilter(HttpFilter.newBuilder().setName("http-filter-2").setTypedConfig(Any.pack(Router.newBuilder().build())).setIsOptional(true).build());
FilterChainMatch filterChainMatch2 = FilterChainMatch.newBuilder().addAllSourcePorts(Arrays.asList(443, 8080)).addAllPrefixRanges(Arrays.asList(CidrRange.newBuilder().setAddressPrefix("2001:DB8::8:800:200C:417A").setPrefixLen(UInt32Value.of(60)).build(), CidrRange.newBuilder().setAddressPrefix("192.168.0.0").setPrefixLen(UInt32Value.of(16)).build())).setSourceType(FilterChainMatch.ConnectionSourceType.ANY).build();
FilterChain filterChain2 = FilterChain.newBuilder().setName("filter-chain-2").setFilterChainMatch(filterChainMatch2).addFilters(filter2).build();
Listener listener = Listener.newBuilder().setName("listener1").setTrafficDirection(TrafficDirection.INBOUND).addAllFilterChains(Arrays.asList(filterChain1, filterChain2)).build();
ClientXdsClient.parseServerSideListener(listener, new HashSet<String>(), null, filterRegistry, null, true);
}
use of io.envoyproxy.envoy.config.listener.v3.FilterChainMatch in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseServerSideListener_nonUniqueFilterChainMatch.
@Test
public void parseServerSideListener_nonUniqueFilterChainMatch() throws ResourceInvalidException {
Filter filter1 = buildHttpConnectionManagerFilter(HttpFilter.newBuilder().setName("http-filter-1").setTypedConfig(Any.pack(Router.newBuilder().build())).setIsOptional(true).build());
FilterChainMatch filterChainMatch1 = FilterChainMatch.newBuilder().addAllSourcePorts(Arrays.asList(80, 8080)).addAllPrefixRanges(Arrays.asList(CidrRange.newBuilder().setAddressPrefix("192.168.0.0").setPrefixLen(UInt32Value.of(16)).build(), CidrRange.newBuilder().setAddressPrefix("10.0.0.0").setPrefixLen(UInt32Value.of(8)).build())).build();
FilterChain filterChain1 = FilterChain.newBuilder().setName("filter-chain-1").setFilterChainMatch(filterChainMatch1).addFilters(filter1).build();
Filter filter2 = buildHttpConnectionManagerFilter(HttpFilter.newBuilder().setName("http-filter-2").setTypedConfig(Any.pack(Router.newBuilder().build())).setIsOptional(true).build());
FilterChainMatch filterChainMatch2 = FilterChainMatch.newBuilder().addAllSourcePorts(Arrays.asList(443, 8080)).addAllPrefixRanges(Arrays.asList(CidrRange.newBuilder().setAddressPrefix("2001:DB8::8:800:200C:417A").setPrefixLen(UInt32Value.of(60)).build(), CidrRange.newBuilder().setAddressPrefix("192.168.0.0").setPrefixLen(UInt32Value.of(16)).build())).build();
FilterChain filterChain2 = FilterChain.newBuilder().setName("filter-chain-2").setFilterChainMatch(filterChainMatch2).addFilters(filter2).build();
Listener listener = Listener.newBuilder().setName("listener1").setTrafficDirection(TrafficDirection.INBOUND).addAllFilterChains(Arrays.asList(filterChain1, filterChain2)).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("FilterChainMatch must be unique. Found duplicate:");
ClientXdsClient.parseServerSideListener(listener, new HashSet<String>(), null, filterRegistry, null, true);
}
use of io.envoyproxy.envoy.config.listener.v3.FilterChainMatch in project grpc-java by grpc.
the class FakeControlPlaneXdsIntegrationTest method serverListener.
private static Listener serverListener(String name) {
HttpFilter routerFilter = HttpFilter.newBuilder().setName("terminal-filter").setTypedConfig(Any.pack(Router.newBuilder().build())).setIsOptional(true).build();
VirtualHost virtualHost = io.envoyproxy.envoy.config.route.v3.VirtualHost.newBuilder().setName("virtual-host-0").addDomains("*").addRoutes(Route.newBuilder().setMatch(RouteMatch.newBuilder().setPrefix("/").build()).setNonForwardingAction(NonForwardingAction.newBuilder().build()).build()).build();
RouteConfiguration routeConfig = RouteConfiguration.newBuilder().addVirtualHosts(virtualHost).build();
Filter filter = Filter.newBuilder().setName("network-filter-0").setTypedConfig(Any.pack(HttpConnectionManager.newBuilder().setRouteConfig(routeConfig).addAllHttpFilters(Collections.singletonList(routerFilter)).build())).build();
FilterChainMatch filterChainMatch = FilterChainMatch.newBuilder().setSourceType(FilterChainMatch.ConnectionSourceType.ANY).build();
FilterChain filterChain = FilterChain.newBuilder().setName("filter-chain-0").setFilterChainMatch(filterChainMatch).addFilters(filter).build();
return Listener.newBuilder().setName(name).setTrafficDirection(TrafficDirection.INBOUND).addFilterChains(filterChain).build();
}
Aggregations