File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,30 @@ func TestAgent(t *testing.T) {
232
232
require .Equal (t , expect , strings .TrimSpace (string (output )))
233
233
})
234
234
235
+ t .Run ("SSH connection env vars" , func (t * testing.T ) {
236
+ t .Parallel ()
237
+
238
+ // Note: the SSH_TTY environment variable should only be set for TTYs.
239
+ for _ , key := range []string {"SSH_CONNECTION" , "SSH_CLIENT" , "SSH_TTY" } {
240
+ key := key
241
+ t .Run (key , func (t * testing.T ) {
242
+ t .Parallel ()
243
+
244
+ command := "sh -c 'echo $" + key + "'"
245
+ if runtime .GOOS == "windows" {
246
+ if key == "SSH_TTY" {
247
+ t .Skip ("The SSH_PTY environment variable is not set on Windows" )
248
+ }
249
+ command = "cmd.exe /c echo %" + key + "%"
250
+ }
251
+ session := setupSSHSession (t , agent.Metadata {})
252
+ output , err := session .Output (command )
253
+ require .NoError (t , err )
254
+ require .NotEmpty (t , strings .TrimSpace (string (output )))
255
+ })
256
+ }
257
+ })
258
+
235
259
t .Run ("StartupScript" , func (t * testing.T ) {
236
260
t .Parallel ()
237
261
tempPath := filepath .Join (t .TempDir (), "content.txt" )
You can’t perform that action at this time.
0 commit comments