File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030
3131use std:: fmt:: Write as _;
3232use std:: io:: Write as _;
33+ use std:: net:: { Ipv4Addr , SocketAddrV4 , TcpListener } ;
3334use std:: path:: PathBuf ;
3435use std:: time:: Duration ;
3536
3637use openshell_e2e:: harness:: cli:: wait_for_healthy;
3738use openshell_e2e:: harness:: gateway:: ManagedGateway ;
3839use openshell_e2e:: harness:: host_process:: HostPythonFixture ;
39- use openshell_e2e:: harness:: port:: find_free_port;
4040use openshell_e2e:: harness:: sandbox:: SandboxGuard ;
4141use serial_test:: serial;
4242use tempfile:: NamedTempFile ;
@@ -63,11 +63,29 @@ struct FixturePorts {
6363
6464impl FixturePorts {
6565 fn pick ( ) -> Self {
66+ // Keep all four listeners bound while allocating ports. Calling the
67+ // single-port helper repeatedly can return the same released port,
68+ // making an allowed CONNECT look like one to the denied fixture.
69+ let listeners: Vec < _ > = ( 0 ..4 )
70+ . map ( |_| {
71+ TcpListener :: bind ( SocketAddrV4 :: new ( Ipv4Addr :: LOCALHOST , 0 ) )
72+ . expect ( "reserve corporate proxy fixture port" )
73+ } )
74+ . collect ( ) ;
75+ let ports: Vec < _ > = listeners
76+ . iter ( )
77+ . map ( |listener| {
78+ listener
79+ . local_addr ( )
80+ . expect ( "fixture listener address" )
81+ . port ( )
82+ } )
83+ . collect ( ) ;
6684 Self {
67- proxy : find_free_port ( ) ,
68- allowed : find_free_port ( ) ,
69- denied : find_free_port ( ) ,
70- bypass : find_free_port ( ) ,
85+ proxy : ports [ 0 ] ,
86+ allowed : ports [ 1 ] ,
87+ denied : ports [ 2 ] ,
88+ bypass : ports [ 3 ] ,
7189 }
7290 }
7391}
You can’t perform that action at this time.
0 commit comments