@@ -748,8 +748,9 @@ public void run() {
748748 EnvoyServerProtoData .FilterChain filterChain = EnvoyServerProtoData .FilterChain .create (
749749 "filter-chain-foo" , createMatch (), httpConnectionManager , createTls (),
750750 mock (TlsContextManager .class ));
751+ // A wildcard port must not make a mismatched listener address valid.
751752 LdsUpdate listenerUpdate = LdsUpdate .forTcpListener (
752- Listener .create ("listener" , "20.3.4.5:1 " ,
753+ Listener .create ("listener" , "20.3.4.5:0 " ,
753754 ImmutableList .copyOf (Collections .singletonList (filterChain )), null , Protocol .TCP ));
754755
755756 xdsClient .deliverLdsUpdate (listenerUpdate );
@@ -795,6 +796,44 @@ public void run() {
795796 verify (listener , timeout (10000 )).onNotServing (any ());
796797 }
797798
799+ @ Test
800+ public void onChanged_listenerAddressWildcardPort ()
801+ throws ExecutionException , InterruptedException , TimeoutException {
802+ xdsServerWrapper = new XdsServerWrapper ("10.1.2.3:1" , mockBuilder , listener ,
803+ selectorManager , new FakeXdsClientPoolFactory (xdsClient ),
804+ XdsServerTestHelper .RAW_BOOTSTRAP ,
805+ filterRegistry , executor .getScheduledExecutorService ());
806+ final SettableFuture <Server > start = SettableFuture .create ();
807+ Executors .newSingleThreadExecutor ().execute (new Runnable () {
808+ @ Override
809+ public void run () {
810+ try {
811+ start .set (xdsServerWrapper .start ());
812+ } catch (Exception ex ) {
813+ start .setException (ex );
814+ }
815+ }
816+ });
817+ String ldsResource = xdsClient .ldsResource .get (5 , TimeUnit .SECONDS );
818+ assertThat (ldsResource ).isEqualTo ("grpc/server?udpa.resource.listening_address=10.1.2.3:1" );
819+ VirtualHost virtualHost =
820+ VirtualHost .create (
821+ "virtual-host" , Collections .singletonList ("auth" ), new ArrayList <Route >(),
822+ ImmutableMap .<String , FilterConfig >of ());
823+ HttpConnectionManager httpConnectionManager = HttpConnectionManager .forVirtualHosts (
824+ 0L , Collections .singletonList (virtualHost ), new ArrayList <NamedFilterConfig >());
825+ EnvoyServerProtoData .FilterChain filterChain = EnvoyServerProtoData .FilterChain .create (
826+ "filter-chain-foo" , createMatch (), httpConnectionManager , createTls (),
827+ mock (TlsContextManager .class ));
828+ LdsUpdate listenerUpdate = LdsUpdate .forTcpListener (
829+ Listener .create ("listener" , "10.1.2.3:0" ,
830+ ImmutableList .copyOf (Collections .singletonList (filterChain )), null , Protocol .TCP ));
831+
832+ xdsClient .deliverLdsUpdate (listenerUpdate );
833+
834+ verify (listener , timeout (10000 )).onServing ();
835+ }
836+
798837 @ Test
799838 public void discoverState_rds () throws Exception {
800839 final SettableFuture <Server > start = SettableFuture .create ();
0 commit comments