Skip to content

Commit 2d840aa

Browse files
committed
Update tests after quoting fixes.
1 parent 6184a0e commit 2d840aa

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Renci.SshNet.Tests/Classes/ScpClientTest_Upload_FileInfoAndPath_SendExecRequestReturnsFalse.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class ScpClientTest_Upload_FileInfoAndPath_SendExecRequestReturnsFalse
2020
private ScpClient _scpClient;
2121
private FileInfo _fileInfo;
2222
private string _path;
23+
private string _quotedPath;
2324
private string _fileName;
2425
private IList<ScpUploadEventArgs> _uploadingRegister;
2526
private SshException _actualException;
@@ -48,6 +49,7 @@ protected void Arrange()
4849
_connectionInfo = new ConnectionInfo("host", 22, "user", new PasswordAuthenticationMethod("user", "pwd"));
4950
_fileInfo = new FileInfo(_fileName);
5051
_path = random.Next().ToString(CultureInfo.InvariantCulture);
52+
_quotedPath = _path.ShellQuote();
5153
_uploadingRegister = new List<ScpUploadEventArgs>();
5254

5355
_serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
@@ -64,8 +66,7 @@ protected void Arrange()
6466
_sessionMock.InSequence(sequence).Setup(p => p.CreateChannelSession()).Returns(_channelSessionMock.Object);
6567
_channelSessionMock.InSequence(sequence).Setup(p => p.Open());
6668
_channelSessionMock.InSequence(sequence)
67-
.Setup(
68-
p => p.SendExecRequest(string.Format("scp -t \"{0}\"", _path))).Returns(false);
69+
.Setup(p => p.SendExecRequest(string.Format("scp -t {0}", _quotedPath))).Returns(false);
6970
_channelSessionMock.InSequence(sequence).Setup(p => p.Dispose());
7071
_pipeStreamMock.As<IDisposable>().InSequence(sequence).Setup(p => p.Dispose());
7172

@@ -98,7 +99,7 @@ public void UploadShouldHaveThrownSshException()
9899
[TestMethod]
99100
public void SendExecREquestOnChannelSessionShouldBeInvokedOnce()
100101
{
101-
_channelSessionMock.Verify(p => p.SendExecRequest(string.Format("scp -t \"{0}\"", _path)), Times.Once);
102+
_channelSessionMock.Verify(p => p.SendExecRequest(string.Format("scp -t {0}", _quotedPath)), Times.Once);
102103
}
103104

104105
[TestMethod]

src/Renci.SshNet.Tests/Classes/ScpClientTest_Upload_FileInfoAndPath_Success.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class ScpClientTest_Upload_FileInfoAndPath_Success
2222
private ScpClient _scpClient;
2323
private FileInfo _fileInfo;
2424
private string _path;
25+
private string _quotedPath;
2526
private int _bufferSize;
2627
private byte[] _fileContent;
2728
private string _fileName;
@@ -56,6 +57,7 @@ private void SetupData()
5657
_connectionInfo = new ConnectionInfo("host", 22, "user", new PasswordAuthenticationMethod("user", "pwd"));
5758
_fileInfo = new FileInfo(_fileName);
5859
_path = random.Next().ToString(CultureInfo.InvariantCulture);
60+
_quotedPath = _path.ShellQuote();
5961
_uploadingRegister = new List<ScpUploadEventArgs>();
6062
}
6163

@@ -78,8 +80,7 @@ private void SetupMocks()
7880
_sessionMock.InSequence(sequence).Setup(p => p.CreateChannelSession()).Returns(_channelSessionMock.Object);
7981
_channelSessionMock.InSequence(sequence).Setup(p => p.Open());
8082
_channelSessionMock.InSequence(sequence)
81-
.Setup(
82-
p => p.SendExecRequest(string.Format("scp -t \"{0}\"", _path))).Returns(true);
83+
.Setup(p => p.SendExecRequest(string.Format("scp -t {0}", _quotedPath))).Returns(true);
8384
_pipeStreamMock.InSequence(sequence).Setup(p => p.ReadByte()).Returns(0);
8485
_channelSessionMock.InSequence(sequence).Setup(p => p.SendData(It.IsAny<byte[]>()));
8586
_pipeStreamMock.InSequence(sequence).Setup(p => p.ReadByte()).Returns(0);
@@ -127,7 +128,7 @@ protected virtual void Act()
127128
[TestMethod]
128129
public void SendExecRequestOnChannelSessionShouldBeInvokedOnce()
129130
{
130-
_channelSessionMock.Verify(p => p.SendExecRequest(string.Format("scp -t \"{0}\"", _path)), Times.Once);
131+
_channelSessionMock.Verify(p => p.SendExecRequest(string.Format("scp -t {0}", _quotedPath)), Times.Once);
131132
}
132133

133134
[TestMethod]

0 commit comments

Comments
 (0)