use of io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseHttpConnectionManager_emptyFilters.
@Test
public void parseHttpConnectionManager_emptyFilters() throws ResourceInvalidException {
HttpConnectionManager hcm = HttpConnectionManager.newBuilder().build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("Missing HttpFilter in HttpConnectionManager.");
ClientXdsClient.parseHttpConnectionManager(hcm, new HashSet<String>(), filterRegistry, true, /* parseHttpFilter */
true);
}
use of io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseHttpConnectionManager_clusterSpecifierPlugin.
@Test
public void parseHttpConnectionManager_clusterSpecifierPlugin() throws Exception {
ClientXdsClient.enableRouteLookup = true;
RouteLookupConfig routeLookupConfig = RouteLookupConfig.newBuilder().addGrpcKeybuilders(GrpcKeyBuilder.newBuilder().addNames(Name.newBuilder().setService("service1")).addNames(Name.newBuilder().setService("service2")).addHeaders(NameMatcher.newBuilder().setKey("key1").addNames("v1").setRequiredMatch(true))).setLookupService("rls-cbt.googleapis.com").setLookupServiceTimeout(Durations.fromMillis(1234)).setCacheSizeBytes(5000).addValidTargets("valid-target").build();
RouteLookupClusterSpecifier specifier = RouteLookupClusterSpecifier.newBuilder().setRouteLookupConfig(routeLookupConfig).build();
TypedExtensionConfig typedExtensionConfig = TypedExtensionConfig.newBuilder().setName("rls-plugin-1").setTypedConfig(Any.pack(specifier)).build();
io.envoyproxy.envoy.config.route.v3.Route route = io.envoyproxy.envoy.config.route.v3.Route.newBuilder().setName("route-1").setMatch(io.envoyproxy.envoy.config.route.v3.RouteMatch.newBuilder().setPrefix("")).setRoute(io.envoyproxy.envoy.config.route.v3.RouteAction.newBuilder().setClusterSpecifierPlugin("rls-plugin-1")).build();
HttpConnectionManager hcm = HttpConnectionManager.newBuilder().setRouteConfig(RouteConfiguration.newBuilder().addClusterSpecifierPlugins(io.envoyproxy.envoy.config.route.v3.ClusterSpecifierPlugin.newBuilder().setExtension(typedExtensionConfig).build()).addVirtualHosts(io.envoyproxy.envoy.config.route.v3.VirtualHost.newBuilder().setName("virtual-host-1").addRoutes(route))).build();
io.grpc.xds.HttpConnectionManager parsedHcm = ClientXdsClient.parseHttpConnectionManager(hcm, new HashSet<String>(), filterRegistry, false, /* parseHttpFilter */
true);
VirtualHost virtualHost = Iterables.getOnlyElement(parsedHcm.virtualHosts());
Route parsedRoute = Iterables.getOnlyElement(virtualHost.routes());
NamedPluginConfig namedPluginConfig = parsedRoute.routeAction().namedClusterSpecifierPluginConfig();
assertThat(namedPluginConfig.name()).isEqualTo("rls-plugin-1");
assertThat(namedPluginConfig.config()).isInstanceOf(RlsPluginConfig.class);
}
use of io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseHttpConnectionManager_unknownFilters.
@Test
public void parseHttpConnectionManager_unknownFilters() throws ResourceInvalidException {
HttpConnectionManager hcm = HttpConnectionManager.newBuilder().addHttpFilters(HttpFilter.newBuilder().setName("envoy.filter.foo").setIsOptional(true)).addHttpFilters(HttpFilter.newBuilder().setName("envoy.filter.bar").setIsOptional(true)).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("The last HttpFilter must be a terminal filter: envoy.filter.bar");
ClientXdsClient.parseHttpConnectionManager(hcm, new HashSet<String>(), filterRegistry, true, /* parseHttpFilter */
true);
}
use of io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager 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);
}
use of io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseHttpConnectionManager_OriginalIpDetectionExtensionsMustEmpty.
@Test
public void parseHttpConnectionManager_OriginalIpDetectionExtensionsMustEmpty() throws ResourceInvalidException {
@SuppressWarnings("deprecation") HttpConnectionManager hcm = HttpConnectionManager.newBuilder().addOriginalIpDetectionExtensions(TypedExtensionConfig.newBuilder().build()).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("HttpConnectionManager with original_ip_detection_extensions unsupported");
ClientXdsClient.parseHttpConnectionManager(hcm, new HashSet<String>(), filterRegistry, false, /* does not matter */
false);
}
Aggregations