use of io.envoyproxy.envoy.config.listener.v3.Listener 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.Listener in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseServerSideListener_invalidTrafficDirection.
@Test
public void parseServerSideListener_invalidTrafficDirection() throws ResourceInvalidException {
Listener listener = Listener.newBuilder().setName("listener1").setTrafficDirection(TrafficDirection.OUTBOUND).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("Listener listener1 with invalid traffic direction: OUTBOUND");
ClientXdsClient.parseServerSideListener(listener, new HashSet<String>(), null, filterRegistry, null, true);
}
use of io.envoyproxy.envoy.config.listener.v3.Listener 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.Listener 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;
}
use of io.envoyproxy.envoy.config.listener.v3.Listener in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseServerSideListener_useOriginalDst.
@Test
public void parseServerSideListener_useOriginalDst() throws ResourceInvalidException {
Listener listener = Listener.newBuilder().setName("listener1").setTrafficDirection(TrafficDirection.INBOUND).setUseOriginalDst(BoolValue.of(true)).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("Listener listener1 cannot have use_original_dst set to true");
ClientXdsClient.parseServerSideListener(listener, new HashSet<String>(), null, filterRegistry, null, true);
}
Aggregations