Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit24f8e6a

Browse files
committed
Add test for SSH env vars
1 parent7a015af commit24f8e6a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎agent/agent_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,30 @@ func TestAgent(t *testing.T) {
232232
require.Equal(t,expect,strings.TrimSpace(string(output)))
233233
})
234234

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+
ifruntime.GOOS=="windows" {
246+
ifkey=="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+
235259
t.Run("StartupScript",func(t*testing.T) {
236260
t.Parallel()
237261
tempPath:=filepath.Join(t.TempDir(),"content.txt")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp