MCPcopy
hub / github.com/netbirdio/netbird / TestSSHServer_WindowsShellHandling

Function TestSSHServer_WindowsShellHandling

client/ssh/server/server_test.go:388–417  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

386}
387
388func TestSSHServer_WindowsShellHandling(t *testing.T) {
389 if testing.Short() {
390 t.Skip("Skipping Windows shell test in short mode")
391 }
392
393 server := &Server{}
394
395 if runtime.GOOS == "windows" {
396 // Test Windows cmd.exe shell behavior
397 args := server.getShellCommandArgs("cmd.exe", "echo test")
398 assert.Equal(t, "cmd.exe", args[0])
399 assert.Equal(t, "-Command", args[1])
400 assert.Equal(t, "echo test", args[2])
401
402 // Test PowerShell behavior
403 args = server.getShellCommandArgs("powershell.exe", "echo test")
404 assert.Equal(t, "powershell.exe", args[0])
405 assert.Equal(t, "-Command", args[1])
406 assert.Equal(t, "echo test", args[2])
407 } else {
408 args := server.getShellCommandArgs("/bin/sh", "echo test")
409 assert.Equal(t, "/bin/sh", args[0])
410 assert.Equal(t, "-c", args[1])
411 assert.Equal(t, "echo test", args[2])
412
413 args = server.getShellCommandArgs("/bin/sh", "")
414 assert.Equal(t, "/bin/sh", args[0])
415 assert.Len(t, args, 1)
416 }
417}
418
419func TestSSHServer_PortForwardingConfiguration(t *testing.T) {
420 hostKey, err := nbssh.GeneratePrivateKey(nbssh.ED25519)

Callers

nothing calls this directly

Calls 3

getShellCommandArgsMethod · 0.95
LenMethod · 0.80
EqualMethod · 0.65

Tested by

no test coverage detected