Search in sources :

Example 6 with Listener

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);
}
Also used : DiscoveryResponse(io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse) Listener(io.envoyproxy.envoy.config.listener.v3.Listener) ApiListener(io.envoyproxy.envoy.config.listener.v3.ApiListener) Test(org.junit.Test)

Example 7 with Listener

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);
}
Also used : Listener(io.envoyproxy.envoy.config.listener.v3.Listener) Test(org.junit.Test)

Example 8 with Listener

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);
}
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 9 with Listener

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;
}
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 10 with 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);
}
Also used : Listener(io.envoyproxy.envoy.config.listener.v3.Listener) Test(org.junit.Test)

Aggregations

Listener (io.envoyproxy.envoy.config.listener.v3.Listener)9 Test (org.junit.Test)7 HttpFilter (io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter)5 Filter (io.envoyproxy.envoy.config.listener.v3.Filter)4 FilterChain (io.envoyproxy.envoy.config.listener.v3.FilterChain)4 FilterChainMatch (io.envoyproxy.envoy.config.listener.v3.FilterChainMatch)4 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)4 Engine (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Engine)4 Host (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Host)4 Listener (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener)4 Server (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server)4 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)4 ListenerFilter (io.envoyproxy.envoy.config.listener.v3.ListenerFilter)3 ApiListener (io.envoyproxy.envoy.config.listener.v3.ApiListener)2 ArrayList (java.util.ArrayList)2 Any (com.google.protobuf.Any)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 Listener (edu.mit.csail.sdg.alloy4.Listener)1 OurBorder (edu.mit.csail.sdg.alloy4.OurBorder)1 OurTree (edu.mit.csail.sdg.alloy4.OurTree)1