@@ -527,12 +527,9 @@ public void Ssh_LocalPortForwardingCloseChannels()
527527 {
528528 client . Connect ( ) ;
529529
530- var localEndPoint = new IPEndPoint ( IPAddress . Loopback , 1225 ) ;
531-
532530 for ( var i = 0 ; i < ( connectionInfo . MaxSessions + 1 ) ; i ++ )
533531 {
534- var forwardedPort = new ForwardedPortLocal ( localEndPoint . Address . ToString ( ) ,
535- ( uint ) localEndPoint . Port ,
532+ var forwardedPort = new ForwardedPortLocal ( IPAddress . Loopback . ToString ( ) ,
536533 hostNameAlias ,
537534 80 ) ;
538535 client . AddForwardedPort ( forwardedPort ) ;
@@ -547,7 +544,8 @@ public void Ssh_LocalPortForwardingCloseChannels()
547544
548545 using HttpClient httpClient = new ( handler ) ;
549546
550- using HttpResponseMessage httpResponse = httpClient . GetAsync ( "http://" + localEndPoint ) . Result ;
547+ using HttpResponseMessage httpResponse = httpClient . GetAsync (
548+ $ "http://{ forwardedPort . BoundHost } :{ forwardedPort . BoundPort } ") . Result ;
551549
552550 Assert . AreEqual ( HttpStatusCode . MovedPermanently , httpResponse . StatusCode ) ;
553551 }
@@ -583,10 +581,7 @@ public void Ssh_LocalPortForwarding()
583581 {
584582 client . Connect ( ) ;
585583
586- var localEndPoint = new IPEndPoint ( IPAddress . Loopback , 1225 ) ;
587-
588- var forwardedPort = new ForwardedPortLocal ( localEndPoint . Address . ToString ( ) ,
589- ( uint ) localEndPoint . Port ,
584+ var forwardedPort = new ForwardedPortLocal ( IPAddress . Loopback . ToString ( ) ,
590585 hostNameAlias ,
591586 80 ) ;
592587 forwardedPort . Exception +=
@@ -603,7 +598,8 @@ public void Ssh_LocalPortForwarding()
603598
604599 using HttpClient httpClient = new ( handler ) ;
605600
606- using HttpResponseMessage httpResponse = httpClient . GetAsync ( "http://" + localEndPoint ) . Result ;
601+ using HttpResponseMessage httpResponse = httpClient . GetAsync (
602+ $ "http://{ forwardedPort . BoundHost } :{ forwardedPort . BoundPort } ") . Result ;
607603
608604 Assert . AreEqual ( HttpStatusCode . MovedPermanently , httpResponse . StatusCode ) ;
609605 }
0 commit comments