diff --git a/src/Renci.SshNet.Tests/Classes/ScpClientTest_Upload_FileInfoAndPath_SendExecRequestReturnsFalse.cs b/src/Renci.SshNet.Tests/Classes/ScpClientTest_Upload_FileInfoAndPath_SendExecRequestReturnsFalse.cs index 8bb173c8..7d10b612 100644 --- a/src/Renci.SshNet.Tests/Classes/ScpClientTest_Upload_FileInfoAndPath_SendExecRequestReturnsFalse.cs +++ b/src/Renci.SshNet.Tests/Classes/ScpClientTest_Upload_FileInfoAndPath_SendExecRequestReturnsFalse.cs @@ -20,6 +20,7 @@ namespace Renci.SshNet.Tests.Classes private ScpClient _scpClient; private FileInfo _fileInfo; private string _path; + private string _quotedPath; private string _fileName; private IList _uploadingRegister; private SshException _actualException; @@ -48,6 +49,7 @@ namespace Renci.SshNet.Tests.Classes _connectionInfo = new ConnectionInfo("host", 22, "user", new PasswordAuthenticationMethod("user", "pwd")); _fileInfo = new FileInfo(_fileName); _path = random.Next().ToString(CultureInfo.InvariantCulture); + _quotedPath = _path.ShellQuote(); _uploadingRegister = new List(); _serviceFactoryMock = new Mock(MockBehavior.Strict); @@ -64,8 +66,7 @@ namespace Renci.SshNet.Tests.Classes _sessionMock.InSequence(sequence).Setup(p => p.CreateChannelSession()).Returns(_channelSessionMock.Object); _channelSessionMock.InSequence(sequence).Setup(p => p.Open()); _channelSessionMock.InSequence(sequence) - .Setup( - p => p.SendExecRequest(string.Format("scp -t \"{0}\"", _path))).Returns(false); + .Setup(p => p.SendExecRequest(string.Format("scp -t {0}", _quotedPath))).Returns(false); _channelSessionMock.InSequence(sequence).Setup(p => p.Dispose()); _pipeStreamMock.As().InSequence(sequence).Setup(p => p.Dispose()); @@ -98,7 +99,7 @@ namespace Renci.SshNet.Tests.Classes [TestMethod] public void SendExecREquestOnChannelSessionShouldBeInvokedOnce() { - _channelSessionMock.Verify(p => p.SendExecRequest(string.Format("scp -t \"{0}\"", _path)), Times.Once); + _channelSessionMock.Verify(p => p.SendExecRequest(string.Format("scp -t {0}", _quotedPath)), Times.Once); } [TestMethod] diff --git a/src/Renci.SshNet.Tests/Classes/ScpClientTest_Upload_FileInfoAndPath_Success.cs b/src/Renci.SshNet.Tests/Classes/ScpClientTest_Upload_FileInfoAndPath_Success.cs index e71aea03..484b4eea 100644 --- a/src/Renci.SshNet.Tests/Classes/ScpClientTest_Upload_FileInfoAndPath_Success.cs +++ b/src/Renci.SshNet.Tests/Classes/ScpClientTest_Upload_FileInfoAndPath_Success.cs @@ -22,6 +22,7 @@ namespace Renci.SshNet.Tests.Classes private ScpClient _scpClient; private FileInfo _fileInfo; private string _path; + private string _quotedPath; private int _bufferSize; private byte[] _fileContent; private string _fileName; @@ -56,6 +57,7 @@ namespace Renci.SshNet.Tests.Classes _connectionInfo = new ConnectionInfo("host", 22, "user", new PasswordAuthenticationMethod("user", "pwd")); _fileInfo = new FileInfo(_fileName); _path = random.Next().ToString(CultureInfo.InvariantCulture); + _quotedPath = _path.ShellQuote(); _uploadingRegister = new List(); } @@ -78,8 +80,7 @@ namespace Renci.SshNet.Tests.Classes _sessionMock.InSequence(sequence).Setup(p => p.CreateChannelSession()).Returns(_channelSessionMock.Object); _channelSessionMock.InSequence(sequence).Setup(p => p.Open()); _channelSessionMock.InSequence(sequence) - .Setup( - p => p.SendExecRequest(string.Format("scp -t \"{0}\"", _path))).Returns(true); + .Setup(p => p.SendExecRequest(string.Format("scp -t {0}", _quotedPath))).Returns(true); _pipeStreamMock.InSequence(sequence).Setup(p => p.ReadByte()).Returns(0); _channelSessionMock.InSequence(sequence).Setup(p => p.SendData(It.IsAny())); _pipeStreamMock.InSequence(sequence).Setup(p => p.ReadByte()).Returns(0); @@ -127,7 +128,7 @@ namespace Renci.SshNet.Tests.Classes [TestMethod] public void SendExecRequestOnChannelSessionShouldBeInvokedOnce() { - _channelSessionMock.Verify(p => p.SendExecRequest(string.Format("scp -t \"{0}\"", _path)), Times.Once); + _channelSessionMock.Verify(p => p.SendExecRequest(string.Format("scp -t {0}", _quotedPath)), Times.Once); } [TestMethod]