Search in sources :

Example 1 with Filter

use of io.envoyproxy.envoy.config.listener.v3.Filter 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);
}
Also used : Listener(io.envoyproxy.envoy.config.listener.v3.Listener) ListenerFilter(io.envoyproxy.envoy.config.listener.v3.ListenerFilter) HttpFilter(io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter) Filter(io.envoyproxy.envoy.config.listener.v3.Filter) FilterChain(io.envoyproxy.envoy.config.listener.v3.FilterChain) FilterChainMatch(io.envoyproxy.envoy.config.listener.v3.FilterChainMatch) Test(org.junit.Test)

Example 2 with Filter

use of io.envoyproxy.envoy.config.listener.v3.Filter in project grpc-java by grpc.

the class FakeControlPlaneXdsIntegrationTest method clientListener.

private static Listener clientListener(String name) {
    HttpFilter httpFilter = HttpFilter.newBuilder().setName("terminal-filter").setTypedConfig(Any.pack(Router.newBuilder().build())).setIsOptional(true).build();
    ApiListener apiListener = ApiListener.newBuilder().setApiListener(Any.pack(io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.newBuilder().setRds(Rds.newBuilder().setRouteConfigName(rdsName).setConfigSource(ConfigSource.newBuilder().setAds(AggregatedConfigSource.getDefaultInstance()))).addAllHttpFilters(Collections.singletonList(httpFilter)).build(), HTTP_CONNECTION_MANAGER_TYPE_URL)).build();
    Listener listener = Listener.newBuilder().setName(name).setApiListener(apiListener).build();
    return listener;
}
Also used : Listener(io.envoyproxy.envoy.config.listener.v3.Listener) ApiListener(io.envoyproxy.envoy.config.listener.v3.ApiListener) ApiListener(io.envoyproxy.envoy.config.listener.v3.ApiListener) HttpFilter(io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter)

Example 3 with Filter

use of io.envoyproxy.envoy.config.listener.v3.Filter in project grpc-java by grpc.

the class ClientXdsClientDataTest method parseFilterChain_noHcm.

@Test
public void parseFilterChain_noHcm() throws ResourceInvalidException {
    FilterChain filterChain = FilterChain.newBuilder().setName("filter-chain-foo").setFilterChainMatch(FilterChainMatch.getDefaultInstance()).setTransportSocket(TransportSocket.getDefaultInstance()).build();
    thrown.expect(ResourceInvalidException.class);
    thrown.expectMessage("FilterChain filter-chain-foo should contain exact one HttpConnectionManager filter");
    ClientXdsClient.parseFilterChain(filterChain, new HashSet<String>(), null, filterRegistry, null, null, true);
}
Also used : FilterChain(io.envoyproxy.envoy.config.listener.v3.FilterChain) Test(org.junit.Test)

Example 4 with Filter

use of io.envoyproxy.envoy.config.listener.v3.Filter 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);
}
Also used : Listener(io.envoyproxy.envoy.config.listener.v3.Listener) ListenerFilter(io.envoyproxy.envoy.config.listener.v3.ListenerFilter) HttpFilter(io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter) Filter(io.envoyproxy.envoy.config.listener.v3.Filter) FilterChain(io.envoyproxy.envoy.config.listener.v3.FilterChain) FilterChainMatch(io.envoyproxy.envoy.config.listener.v3.FilterChainMatch) Test(org.junit.Test)

Example 5 with Filter

use of io.envoyproxy.envoy.config.listener.v3.Filter in project grpc-java by grpc.

the class ClientXdsClientDataTest method parseFilterChain_duplicateFilter.

@Test
public void parseFilterChain_duplicateFilter() throws ResourceInvalidException {
    Filter filter = buildHttpConnectionManagerFilter(HttpFilter.newBuilder().setName("http-filter-foo").setIsOptional(true).build());
    FilterChain filterChain = FilterChain.newBuilder().setName("filter-chain-foo").setFilterChainMatch(FilterChainMatch.getDefaultInstance()).setTransportSocket(TransportSocket.getDefaultInstance()).addAllFilters(Arrays.asList(filter, filter)).build();
    thrown.expect(ResourceInvalidException.class);
    thrown.expectMessage("FilterChain filter-chain-foo should contain exact one HttpConnectionManager filter");
    ClientXdsClient.parseFilterChain(filterChain, new HashSet<String>(), null, filterRegistry, null, null, true);
}
Also used : ListenerFilter(io.envoyproxy.envoy.config.listener.v3.ListenerFilter) HttpFilter(io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter) Filter(io.envoyproxy.envoy.config.listener.v3.Filter) FilterChain(io.envoyproxy.envoy.config.listener.v3.FilterChain) Test(org.junit.Test)

Aggregations

FilterChain (io.envoyproxy.envoy.config.listener.v3.FilterChain)9 HttpFilter (io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter)8 Test (org.junit.Test)8 Filter (io.envoyproxy.envoy.config.listener.v3.Filter)7 ListenerFilter (io.envoyproxy.envoy.config.listener.v3.ListenerFilter)6 FilterChainMatch (io.envoyproxy.envoy.config.listener.v3.FilterChainMatch)4 Listener (io.envoyproxy.envoy.config.listener.v3.Listener)4 ApiListener (io.envoyproxy.envoy.config.listener.v3.ApiListener)1 RouteConfiguration (io.envoyproxy.envoy.config.route.v3.RouteConfiguration)1 VirtualHost (io.envoyproxy.envoy.config.route.v3.VirtualHost)1