use of io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseHttpConnectionManager_validateRdsConfigSource.
@Test
public void parseHttpConnectionManager_validateRdsConfigSource() throws Exception {
ClientXdsClient.enableRouteLookup = true;
Set<String> rdsResources = new HashSet<>();
HttpConnectionManager hcm1 = HttpConnectionManager.newBuilder().setRds(Rds.newBuilder().setRouteConfigName("rds-config-foo").setConfigSource(ConfigSource.newBuilder().setAds(AggregatedConfigSource.getDefaultInstance()))).build();
ClientXdsClient.parseHttpConnectionManager(hcm1, rdsResources, filterRegistry, false, /* parseHttpFilter */
true);
HttpConnectionManager hcm2 = HttpConnectionManager.newBuilder().setRds(Rds.newBuilder().setRouteConfigName("rds-config-foo").setConfigSource(ConfigSource.newBuilder().setSelf(SelfConfigSource.getDefaultInstance()))).build();
ClientXdsClient.parseHttpConnectionManager(hcm2, rdsResources, filterRegistry, false, /* parseHttpFilter */
true);
HttpConnectionManager hcm3 = HttpConnectionManager.newBuilder().setRds(Rds.newBuilder().setRouteConfigName("rds-config-foo").setConfigSource(ConfigSource.newBuilder().setPath("foo-path"))).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("HttpConnectionManager contains invalid RDS: must specify ADS or self ConfigSource");
ClientXdsClient.parseHttpConnectionManager(hcm3, rdsResources, filterRegistry, false, /* 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_duplicateHttpFilters.
@Test
public void parseHttpConnectionManager_duplicateHttpFilters() throws ResourceInvalidException {
HttpConnectionManager hcm = HttpConnectionManager.newBuilder().addHttpFilters(HttpFilter.newBuilder().setName("envoy.filter.foo").setIsOptional(true)).addHttpFilters(HttpFilter.newBuilder().setName("envoy.filter.foo").setIsOptional(true)).addHttpFilters(HttpFilter.newBuilder().setName("terminal").setTypedConfig(Any.pack(Router.newBuilder().build())).setIsOptional(true)).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("HttpConnectionManager contains duplicate HttpFilter: envoy.filter.foo");
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_terminalNotLast.
@Test
public void parseHttpConnectionManager_terminalNotLast() throws ResourceInvalidException {
filterRegistry.register(RouterFilter.INSTANCE);
HttpConnectionManager hcm = HttpConnectionManager.newBuilder().addHttpFilters(HttpFilter.newBuilder().setName("terminal").setTypedConfig(Any.pack(Router.newBuilder().build())).setIsOptional(true)).addHttpFilters(HttpFilter.newBuilder().setName("envoy.filter.foo").setIsOptional(true)).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("A terminal HttpFilter must be the last filter: terminal");
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_missingRdsAndInlinedRouteConfiguration.
@Test
public void parseHttpConnectionManager_missingRdsAndInlinedRouteConfiguration() throws ResourceInvalidException {
HttpConnectionManager hcm = HttpConnectionManager.newBuilder().setCommonHttpProtocolOptions(HttpProtocolOptions.newBuilder().setMaxStreamDuration(Durations.fromNanos(1000L))).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("HttpConnectionManager neither has inlined route_config nor RDS");
ClientXdsClient.parseHttpConnectionManager(hcm, new HashSet<String>(), filterRegistry, false, /* does not matter */
true);
}
use of io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager in project grpc-java by grpc.
the class ClientXdsClient method parseFilterChain.
@VisibleForTesting
static FilterChain parseFilterChain(io.envoyproxy.envoy.config.listener.v3.FilterChain proto, Set<String> rdsResources, TlsContextManager tlsContextManager, FilterRegistry filterRegistry, Set<FilterChainMatch> uniqueSet, Set<String> certProviderInstances, boolean parseHttpFilters) throws ResourceInvalidException {
if (proto.getFiltersCount() != 1) {
throw new ResourceInvalidException("FilterChain " + proto.getName() + " should contain exact one HttpConnectionManager filter");
}
io.envoyproxy.envoy.config.listener.v3.Filter filter = proto.getFiltersList().get(0);
if (!filter.hasTypedConfig()) {
throw new ResourceInvalidException("FilterChain " + proto.getName() + " contains filter " + filter.getName() + " without typed_config");
}
Any any = filter.getTypedConfig();
// HttpConnectionManager is the only supported network filter at the moment.
if (!any.getTypeUrl().equals(TYPE_URL_HTTP_CONNECTION_MANAGER)) {
throw new ResourceInvalidException("FilterChain " + proto.getName() + " contains filter " + filter.getName() + " with unsupported typed_config type " + any.getTypeUrl());
}
HttpConnectionManager hcmProto;
try {
hcmProto = any.unpack(HttpConnectionManager.class);
} catch (InvalidProtocolBufferException e) {
throw new ResourceInvalidException("FilterChain " + proto.getName() + " with filter " + filter.getName() + " failed to unpack message", e);
}
io.grpc.xds.HttpConnectionManager httpConnectionManager = parseHttpConnectionManager(hcmProto, rdsResources, filterRegistry, parseHttpFilters, false);
EnvoyServerProtoData.DownstreamTlsContext downstreamTlsContext = null;
if (proto.hasTransportSocket()) {
if (!TRANSPORT_SOCKET_NAME_TLS.equals(proto.getTransportSocket().getName())) {
throw new ResourceInvalidException("transport-socket with name " + proto.getTransportSocket().getName() + " not supported.");
}
DownstreamTlsContext downstreamTlsContextProto;
try {
downstreamTlsContextProto = proto.getTransportSocket().getTypedConfig().unpack(DownstreamTlsContext.class);
} catch (InvalidProtocolBufferException e) {
throw new ResourceInvalidException("FilterChain " + proto.getName() + " failed to unpack message", e);
}
downstreamTlsContext = EnvoyServerProtoData.DownstreamTlsContext.fromEnvoyProtoDownstreamTlsContext(validateDownstreamTlsContext(downstreamTlsContextProto, certProviderInstances));
}
FilterChainMatch filterChainMatch = parseFilterChainMatch(proto.getFilterChainMatch());
checkForUniqueness(uniqueSet, filterChainMatch);
return FilterChain.create(proto.getName(), filterChainMatch, httpConnectionManager, downstreamTlsContext, tlsContextManager);
}
Aggregations