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 @@ -210,6 +210,30 @@ func TestAgent(t *testing.T) {
210
210
require .Equal (t , value , strings .TrimSpace (string (output )))
211
211
})
212
212
213
+ t .Run ("SSH connection env vars" , func (t * testing.T ) {
214
+ t .Parallel ()
215
+
216
+ // Note: the SSH_TTY environment variable should only be set for TTYs.
217
+ for _ , key := range []string {"SSH_CONNECTION" , "SSH_CLIENT" , "SSH_TTY" } {
218
+ key := key
219
+ t .Run (key , func (t * testing.T ) {
220
+ t .Parallel ()
221
+
222
+ command := "sh -c 'echo $" + key + "'"
223
+ if runtime .GOOS == "windows" {
224
+ if key == "SSH_TTY" {
225
+ t .Skip ("The SSH_PTY environment variable is not set on Windows" )
226
+ }
227
+ command = "cmd.exe /c echo %" + key + "%"
228
+ }
229
+ session := setupSSHSession (t , agent.Metadata {})
230
+ output , err := session .Output (command )
231
+ require .NoError (t , err )
232
+ require .NotEmpty (t , strings .TrimSpace (string (output )))
233
+ })
234
+ }
235
+ })
236
+
213
237
t .Run ("EnvironmentVariableExpansion" , func (t * testing.T ) {
214
238
t .Parallel ()
215
239
key := "EXAMPLE"
You can’t perform that action at this time.
0 commit comments