fix test cases on Windows
SysProcAttr.Credential is not available on Windows we need to move the WrapCmd test in a separate file to be able to build test cases on Windows, skipping the test is not enough
This commit is contained in:
parent
ae812e55af
commit
f49c280a7f
2 changed files with 19 additions and 15 deletions
|
@ -7,7 +7,6 @@ import (
|
|||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -1213,17 +1212,3 @@ func TestSFTPExtensions(t *testing.T) {
|
|||
}
|
||||
sftpExtensions = initialSFTPExtensions
|
||||
}
|
||||
|
||||
func TestWrapCmd(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("executing a command as another uid/gid is not supported on Windows")
|
||||
}
|
||||
cmd := exec.Command("ls")
|
||||
cmd = wrapCmd(cmd, 1000, 1001)
|
||||
if cmd.SysProcAttr.Credential.Uid != 1000 {
|
||||
t.Errorf("unexpected uid")
|
||||
}
|
||||
if cmd.SysProcAttr.Credential.Gid != 1001 {
|
||||
t.Errorf("unexpected gid")
|
||||
}
|
||||
}
|
||||
|
|
19
sftpd/internal_unix_test.go
Normal file
19
sftpd/internal_unix_test.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
// +build !windows
|
||||
|
||||
package sftpd
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWrapCmd(t *testing.T) {
|
||||
cmd := exec.Command("ls")
|
||||
cmd = wrapCmd(cmd, 1000, 1001)
|
||||
if cmd.SysProcAttr.Credential.Uid != 1000 {
|
||||
t.Errorf("unexpected uid")
|
||||
}
|
||||
if cmd.SysProcAttr.Credential.Gid != 1001 {
|
||||
t.Errorf("unexpected gid")
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue