use of io.envoyproxy.envoy.config.listener.v3.ApiListener in project grpc-java by grpc.
the class MessagePrinterTest method printLdsResponse_v3.
@Test
public void printLdsResponse_v3() {
Listener listener = Listener.newBuilder().setName("foo.googleapis.com:8080").setAddress(Address.newBuilder().setSocketAddress(SocketAddress.newBuilder().setAddress("10.0.0.1").setPortValue(8080))).addFilterChains(FilterChain.newBuilder().addFilters(Filter.getDefaultInstance()).setTransportSocket(TransportSocket.newBuilder().setName("envoy.transport_sockets.tls").setTypedConfig(Any.pack(DownstreamTlsContext.newBuilder().setCommonTlsContext(CommonTlsContext.newBuilder().addTlsCertificateSdsSecretConfigs(SdsSecretConfig.getDefaultInstance())).build())))).setApiListener(ApiListener.newBuilder().setApiListener(Any.pack(HttpConnectionManager.newBuilder().setRds(Rds.newBuilder().setRouteConfigName("route-foo.googleapis.com").setConfigSource(ConfigSource.newBuilder().setAds(AggregatedConfigSource.getDefaultInstance()))).build()))).build();
DiscoveryResponse response = DiscoveryResponse.newBuilder().setTypeUrl("type.googleapis.com/envoy.config.listener.v3.Listener").setVersionInfo("0").addResources(Any.pack(listener)).setNonce("0000").build();
String expectedString = "{\n" + " \"versionInfo\": \"0\",\n" + " \"resources\": [{\n" + " \"@type\": \"type.googleapis.com/envoy.config.listener.v3.Listener\",\n" + " \"name\": \"foo.googleapis.com:8080\",\n" + " \"address\": {\n" + " \"socketAddress\": {\n" + " \"address\": \"10.0.0.1\",\n" + " \"portValue\": 8080\n" + " }\n" + " },\n" + " \"filterChains\": [{\n" + " \"filters\": [{\n" + " }],\n" + " \"transportSocket\": {\n" + " \"name\": \"envoy.transport_sockets.tls\",\n" + " \"typedConfig\": {\n" + " \"@type\": \"type.googleapis.com/envoy.extensions.transport_sockets" + ".tls.v3.DownstreamTlsContext\",\n" + " \"commonTlsContext\": {\n" + " \"tlsCertificateSdsSecretConfigs\": [{\n" + " }]\n" + " }\n" + " }\n" + " }\n" + " }],\n" + " \"apiListener\": {\n" + " \"apiListener\": {\n" + " \"@type\": \"type.googleapis.com/envoy.extensions.filters.network" + ".http_connection_manager.v3.HttpConnectionManager\",\n" + " \"rds\": {\n" + " \"configSource\": {\n" + " \"ads\": {\n" + " }\n" + " },\n" + " \"routeConfigName\": \"route-foo.googleapis.com\"\n" + " }\n" + " }\n" + " }\n" + " }],\n" + " \"typeUrl\": \"type.googleapis.com/envoy.config.listener.v3.Listener\",\n" + " \"nonce\": \"0000\"\n" + "}";
String res = MessagePrinter.print(response);
assertThat(res).isEqualTo(expectedString);
}
use of io.envoyproxy.envoy.config.listener.v3.ApiListener 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;
}
Aggregations