@@ -192,6 +192,45 @@ describe("gateway-status command", () => {
192192 expect ( targets . some ( ( t ) => t . kind === "sshTunnel" ) ) . toBe ( true ) ;
193193 } ) ;
194194
195+ it ( "skips invalid ssh-auto discovery targets" , async ( ) => {
196+ const runtimeLogs : string [ ] = [ ] ;
197+ const runtime = {
198+ log : ( msg : string ) => runtimeLogs . push ( msg ) ,
199+ error : ( _msg : string ) => { } ,
200+ exit : ( code : number ) => {
201+ throw new Error ( `__exit__:${ code } ` ) ;
202+ } ,
203+ } ;
204+
205+ const originalUser = process . env . USER ;
206+ try {
207+ process . env . USER = "steipete" ;
208+ loadConfig . mockReturnValueOnce ( {
209+ gateway : {
210+ mode : "remote" ,
211+ remote : { } ,
212+ } ,
213+ } ) ;
214+ discoverGatewayBeacons . mockResolvedValueOnce ( [
215+ { tailnetDns : "-V" } ,
216+ { tailnetDns : "goodhost" } ,
217+ ] ) ;
218+
219+ startSshPortForward . mockClear ( ) ;
220+ const { gatewayStatusCommand } = await import ( "./gateway-status.js" ) ;
221+ await gatewayStatusCommand (
222+ { timeout : "1000" , json : true , sshAuto : true } ,
223+ runtime as unknown as import ( "../runtime.js" ) . RuntimeEnv ,
224+ ) ;
225+
226+ expect ( startSshPortForward ) . toHaveBeenCalledTimes ( 1 ) ;
227+ const call = startSshPortForward . mock . calls [ 0 ] ?. [ 0 ] as { target : string } ;
228+ expect ( call . target ) . toBe ( "steipete@goodhost" ) ;
229+ } finally {
230+ process . env . USER = originalUser ;
231+ }
232+ } ) ;
233+
195234 it ( "infers SSH target from gateway.remote.url and ssh config" , async ( ) => {
196235 const runtimeLogs : string [ ] = [ ] ;
197236 const runtime = {
0 commit comments