enable SCP test cases on Windows

This commit is contained in:
Nicola Murino
2020-06-30 23:25:25 +02:00
parent c5dc3ee3b6
commit ee1131f254

View File

@@ -6546,13 +6546,14 @@ func TestSCPPermsSubDirs(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
err = scpDownload(localPath, remoteDownPath, false, false) err = scpDownload(localPath, remoteDownPath, false, false)
assert.NoError(t, err) assert.NoError(t, err)
err = os.Chmod(subPath, 0001) if runtime.GOOS != osWindows {
assert.NoError(t, err) err = os.Chmod(subPath, 0001)
err = scpDownload(localPath, remoteDownPath, false, false) assert.NoError(t, err)
assert.Error(t, err, "download a file with no system permissions must fail") err = scpDownload(localPath, remoteDownPath, false, false)
assert.Error(t, err, "download a file with no system permissions must fail")
err = os.Chmod(subPath, 0755) err = os.Chmod(subPath, 0755)
assert.NoError(t, err) assert.NoError(t, err)
}
err = os.Remove(localPath) err = os.Remove(localPath)
assert.NoError(t, err) assert.NoError(t, err)
err = os.RemoveAll(user.GetHomeDir()) err = os.RemoveAll(user.GetHomeDir())
@@ -6838,6 +6839,9 @@ func TestSCPRemoteToRemote(t *testing.T) {
if len(scpPath) == 0 { if len(scpPath) == 0 {
t.Skip("scp command not found, unable to execute this test") 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 usePubKey := true
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK) user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
assert.NoError(t, err) assert.NoError(t, err)
@@ -7381,15 +7385,11 @@ func checkSystemCommands() {
logger.Warn(logSender, "", "unable to get hook command: %v", err) logger.Warn(logSender, "", "unable to get hook command: %v", err)
logger.WarnToConsole("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 = "" 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 = ""
}
} }
} }