@@ -87,7 +87,7 @@ describe("ssh command", () => {
8787 it . effect ( "keeps a discovered SSH URI valid after resolving its user" , ( ) =>
8888 Effect . gen ( function * ( ) {
8989 for ( const [ alias , hostname , expected ] of [
90- [ "ssh://host.example:2222" , "host.example" , "ssh:// [email protected] :2222 " ] , 90+ [ "ssh://host.example:2222" , "host.example" , "[email protected] " ] , 9191 [ "ssh://[::1]:2222" , "::1" , "alice@::1" ] ,
9292 ] ) {
9393 const resolved = parseSshResolveOutput (
@@ -101,27 +101,32 @@ describe("ssh command", () => {
101101 ) ;
102102
103103 it . effect . skipIf ( HostProcessPlatform . defaultValue ( ) === "win32" ) (
104- "passes discovered IPv6 destinations to OpenSSH without losing the user or port" ,
104+ "passes SSH URI destinations to OpenSSH with their exact user and port" ,
105105 ( ) =>
106106 Effect . gen ( function * ( ) {
107107 const spawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
108- for ( const username of [ null , "developer" ] ) {
109- const target = {
110- alias : "ssh://[2001:db8::1]:2222" ,
111- hostname : "2001:db8::1" ,
112- username,
113- port : null ,
114- } ;
115- const hostSpec = yield * buildSshHostSpecEffect ( target ) ;
116- const child = yield * spawner . spawn (
117- ChildProcess . make ( "ssh" , [ "-F" , "/dev/null" , "-G" , ...baseSshArgs ( target ) , hostSpec ] ) ,
118- ) ;
119- const stdout = yield * collectProcessOutput ( child . stdout ) ;
120- assert . equal ( Number ( yield * child . exitCode ) , 0 ) ;
121- assert . include ( stdout , "port 2222\n" ) ;
122- assert . include ( stdout , "hostname 2001:db8::1\n" ) ;
123- if ( username ) assert . include ( stdout , `user ${ username } \n` ) ;
108+ for ( const hostname of [ "host.example" , "2001:db8::1" , "fe80::1%fixture0" ] ) {
109+ for ( const username of [ null , "developer+ops" , "developer%ops" ] ) {
110+ const alias = `ssh://${ hostname . includes ( ":" ) ? `[${ hostname } ]` : hostname } :2222` ;
111+ const target = { alias, hostname, username, port : null } ;
112+ const hostSpec = yield * buildSshHostSpecEffect ( target ) ;
113+ const child = yield * spawner . spawn (
114+ ChildProcess . make ( "ssh" , [ "-F" , "/dev/null" , "-G" , ...baseSshArgs ( target ) , hostSpec ] ) ,
115+ ) ;
116+ const stdout = yield * collectProcessOutput ( child . stdout ) ;
117+ assert . equal ( Number ( yield * child . exitCode ) , 0 ) ;
118+ assert . include ( stdout , "port 2222\n" ) ;
119+ assert . include ( stdout , `hostname ${ hostname } \n` ) ;
120+ if ( username ) assert . include ( stdout , `user ${ username } \n` ) ;
121+ }
124122 }
123+ const encoded = {
124+ alias :
"ssh://developer%2Bops%[email protected] :2222" , 125+ hostname : "host.example" ,
126+ username : null ,
127+ port : null ,
128+ } ;
129+ assert . equal ( yield * buildSshHostSpecEffect ( encoded ) , "developer+ops%@host.example" ) ;
125130 } ) . pipe ( Effect . provide ( NodeServices . layer ) ) ,
126131 ) ;
127132
0 commit comments