From ee1131f254661a7977cbbdf5b9cd09256935d221 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Tue, 30 Jun 2020 23:25:25 +0200 Subject: [PATCH] enable SCP test cases on Windows --- sftpd/sftpd_test.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sftpd/sftpd_test.go b/sftpd/sftpd_test.go index 53b98e55..a76461ec 100644 --- a/sftpd/sftpd_test.go +++ b/sftpd/sftpd_test.go @@ -6546,13 +6546,14 @@ func TestSCPPermsSubDirs(t *testing.T) { assert.NoError(t, err) err = scpDownload(localPath, remoteDownPath, false, false) assert.NoError(t, err) - err = os.Chmod(subPath, 0001) - assert.NoError(t, err) - err = scpDownload(localPath, remoteDownPath, false, false) - assert.Error(t, err, "download a file with no system permissions must fail") - - err = os.Chmod(subPath, 0755) - assert.NoError(t, err) + if runtime.GOOS != osWindows { + err = os.Chmod(subPath, 0001) + assert.NoError(t, err) + err = scpDownload(localPath, remoteDownPath, false, false) + assert.Error(t, err, "download a file with no system permissions must fail") + err = os.Chmod(subPath, 0755) + assert.NoError(t, err) + } err = os.Remove(localPath) assert.NoError(t, err) err = os.RemoveAll(user.GetHomeDir()) @@ -6838,6 +6839,9 @@ func TestSCPRemoteToRemote(t *testing.T) { if len(scpPath) == 0 { t.Skip("scp command not found, unable to execute this test") } + if runtime.GOOS == osWindows { + t.Skip("scp between remote hosts is not supported on Windows") + } usePubKey := true user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK) assert.NoError(t, err) @@ -7381,15 +7385,11 @@ func checkSystemCommands() { logger.Warn(logSender, "", "unable to get hook command: %v", err) logger.WarnToConsole("unable to get hook command: %v", err) } - if runtime.GOOS == osWindows { + scpPath, err = exec.LookPath("scp") + if err != nil { + logger.Warn(logSender, "", "unable to get scp command. SCP tests will be skipped, err: %v", err) + logger.WarnToConsole("unable to get scp command. SCP tests will be skipped, err: %v", err) scpPath = "" - } else { - scpPath, err = exec.LookPath("scp") - if err != nil { - logger.Warn(logSender, "", "unable to get scp command. SCP tests will be skipped, err: %v", err) - logger.WarnToConsole("unable to get scp command. SCP tests will be skipped, err: %v", err) - scpPath = "" - } } }