diff --git a/src/Renci.SshNet.Tests/Classes/PrivateKeyAuthenticationMethodTest.cs b/src/Renci.SshNet.Tests/Classes/PrivateKeyAuthenticationMethodTest.cs
index 6634c0ef..6ea7a33f 100644
--- a/src/Renci.SshNet.Tests/Classes/PrivateKeyAuthenticationMethodTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/PrivateKeyAuthenticationMethodTest.cs
@@ -1,106 +1,106 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Tests.Common;
-using System;
-
-namespace Renci.SshNet.Tests.Classes
-{
- ///
- /// Provides functionality to perform private key authentication.
- ///
- [TestClass]
- public class PrivateKeyAuthenticationMethodTest : TestBase
- {
- [TestMethod]
- [TestCategory("AuthenticationMethod")]
- [TestCategory("PrivateKeyAuthenticationMethod")]
- [Owner("Kenneth_aa")]
- [Description("PrivateKeyAuthenticationMethod: Pass null as username, null as password.")]
- [ExpectedException(typeof(ArgumentException))]
- public void PrivateKey_Test_Pass_Null()
- {
- new PrivateKeyAuthenticationMethod(null, null);
- }
-
- [TestMethod]
- [TestCategory("AuthenticationMethod")]
- [TestCategory("PrivateKeyAuthenticationMethod")]
- [Owner("olegkap")]
- [Description("PrivateKeyAuthenticationMethod: Pass valid username, null as password.")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void PrivateKey_Test_Pass_PrivateKey_Null()
- {
- new PrivateKeyAuthenticationMethod("username", null);
- }
-
- [TestMethod]
- [TestCategory("AuthenticationMethod")]
- [TestCategory("PrivateKeyAuthenticationMethod")]
- [Owner("Kenneth_aa")]
- [Description("PrivateKeyAuthenticationMethod: Pass String.Empty as username, null as password.")]
- [ExpectedException(typeof(ArgumentException))]
- public void PrivateKey_Test_Pass_Whitespace()
- {
- new PrivateKeyAuthenticationMethod(string.Empty, null);
- }
-
- ///
- ///A test for Name
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void NameTest()
- {
- string username = string.Empty; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyAuthenticationMethod target = new PrivateKeyAuthenticationMethod(username, keyFiles); // TODO: Initialize to an appropriate value
- string actual;
- actual = target.Name;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Dispose
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DisposeTest()
- {
- string username = string.Empty; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyAuthenticationMethod target = new PrivateKeyAuthenticationMethod(username, keyFiles); // TODO: Initialize to an appropriate value
- target.Dispose();
- Assert.Inconclusive("A method that does not return a value cannot be verified.");
- }
-
- ///
- ///A test for Authenticate
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void AuthenticateTest()
- {
- string username = string.Empty; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyAuthenticationMethod target = new PrivateKeyAuthenticationMethod(username, keyFiles); // TODO: Initialize to an appropriate value
- Session session = null; // TODO: Initialize to an appropriate value
- AuthenticationResult expected = new AuthenticationResult(); // TODO: Initialize to an appropriate value
- AuthenticationResult actual;
- actual = target.Authenticate(session);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for PrivateKeyAuthenticationMethod Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PrivateKeyAuthenticationMethodConstructorTest()
- {
- string username = string.Empty; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyAuthenticationMethod target = new PrivateKeyAuthenticationMethod(username, keyFiles);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Tests.Common;
+using System;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ ///
+ /// Provides functionality to perform private key authentication.
+ ///
+ [TestClass]
+ public class PrivateKeyAuthenticationMethodTest : TestBase
+ {
+ [TestMethod]
+ [TestCategory("AuthenticationMethod")]
+ [TestCategory("PrivateKeyAuthenticationMethod")]
+ [Owner("Kenneth_aa")]
+ [Description("PrivateKeyAuthenticationMethod: Pass null as username, null as password.")]
+ [ExpectedException(typeof(ArgumentException))]
+ public void PrivateKey_Test_Pass_Null()
+ {
+ new PrivateKeyAuthenticationMethod(null, null);
+ }
+
+ [TestMethod]
+ [TestCategory("AuthenticationMethod")]
+ [TestCategory("PrivateKeyAuthenticationMethod")]
+ [Owner("olegkap")]
+ [Description("PrivateKeyAuthenticationMethod: Pass valid username, null as password.")]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void PrivateKey_Test_Pass_PrivateKey_Null()
+ {
+ new PrivateKeyAuthenticationMethod("username", null);
+ }
+
+ [TestMethod]
+ [TestCategory("AuthenticationMethod")]
+ [TestCategory("PrivateKeyAuthenticationMethod")]
+ [Owner("Kenneth_aa")]
+ [Description("PrivateKeyAuthenticationMethod: Pass String.Empty as username, null as password.")]
+ [ExpectedException(typeof(ArgumentException))]
+ public void PrivateKey_Test_Pass_Whitespace()
+ {
+ new PrivateKeyAuthenticationMethod(string.Empty, null);
+ }
+
+ ///
+ ///A test for Name
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void NameTest()
+ {
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyAuthenticationMethod target = new PrivateKeyAuthenticationMethod(username, keyFiles); // TODO: Initialize to an appropriate value
+ string actual;
+ actual = target.Name;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Dispose
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DisposeTest()
+ {
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyAuthenticationMethod target = new PrivateKeyAuthenticationMethod(username, keyFiles); // TODO: Initialize to an appropriate value
+ target.Dispose();
+ Assert.Inconclusive("A method that does not return a value cannot be verified.");
+ }
+
+ ///
+ ///A test for Authenticate
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void AuthenticateTest()
+ {
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyAuthenticationMethod target = new PrivateKeyAuthenticationMethod(username, keyFiles); // TODO: Initialize to an appropriate value
+ Session session = null; // TODO: Initialize to an appropriate value
+ AuthenticationResult expected = new AuthenticationResult(); // TODO: Initialize to an appropriate value
+ AuthenticationResult actual;
+ actual = target.Authenticate(session);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for PrivateKeyAuthenticationMethod Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PrivateKeyAuthenticationMethodConstructorTest()
+ {
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyAuthenticationMethod target = new PrivateKeyAuthenticationMethod(username, keyFiles);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/PrivateKeyConnectionInfoTest.cs b/src/Renci.SshNet.Tests/Classes/PrivateKeyConnectionInfoTest.cs
index cee67e17..f8c863ba 100644
--- a/src/Renci.SshNet.Tests/Classes/PrivateKeyConnectionInfoTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/PrivateKeyConnectionInfoTest.cs
@@ -1,217 +1,217 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Tests.Common;
-using Renci.SshNet.Tests.Properties;
-using System.IO;
-using System.Text;
-
-namespace Renci.SshNet.Tests.Classes
-{
- ///
- /// Provides connection information when private key authentication method is used
- ///
- [TestClass]
- public class PrivateKeyConnectionInfoTest : TestBase
- {
- [TestMethod]
- [TestCategory("PrivateKeyConnectionInfo")]
- [TestCategory("integration")]
- public void Test_PrivateKeyConnectionInfo()
- {
- var host = Resources.HOST;
- var username = Resources.USERNAME;
- MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITHOUT_PASS));
-
- #region Example PrivateKeyConnectionInfo PrivateKeyFile
- var connectionInfo = new PrivateKeyConnectionInfo(host, username, new PrivateKeyFile(keyFileStream));
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- #endregion
-
- Assert.AreEqual(connectionInfo.Host, Resources.HOST);
- Assert.AreEqual(connectionInfo.Username, Resources.USERNAME);
- }
-
- [TestMethod]
- [TestCategory("PrivateKeyConnectionInfo")]
- [TestCategory("integration")]
- public void Test_PrivateKeyConnectionInfo_MultiplePrivateKey()
- {
- var host = Resources.HOST;
- var username = Resources.USERNAME;
- MemoryStream keyFileStream1 = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITHOUT_PASS));
- MemoryStream keyFileStream2 = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITHOUT_PASS));
-
- #region Example PrivateKeyConnectionInfo PrivateKeyFile Multiple
- var connectionInfo = new PrivateKeyConnectionInfo(host, username,
- new PrivateKeyFile(keyFileStream1),
- new PrivateKeyFile(keyFileStream2));
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- #endregion
-
- Assert.AreEqual(connectionInfo.Host, Resources.HOST);
- Assert.AreEqual(connectionInfo.Username, Resources.USERNAME);
- }
-
- ///
- ///A test for Dispose
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DisposeTest()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, keyFiles); // TODO: Initialize to an appropriate value
- target.Dispose();
- Assert.Inconclusive("A method that does not return a value cannot be verified.");
- }
-
- ///
- ///A test for PrivateKeyConnectionInfo Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PrivateKeyConnectionInfoConstructorTest()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- int port = 0; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
- string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, keyFiles);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for PrivateKeyConnectionInfo Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PrivateKeyConnectionInfoConstructorTest1()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
- string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, keyFiles);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for PrivateKeyConnectionInfo Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PrivateKeyConnectionInfoConstructorTest2()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, proxyType, proxyHost, proxyPort, proxyUsername, keyFiles);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for PrivateKeyConnectionInfo Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PrivateKeyConnectionInfoConstructorTest3()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, proxyType, proxyHost, proxyPort, keyFiles);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for PrivateKeyConnectionInfo Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PrivateKeyConnectionInfoConstructorTest4()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- int port = 0; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, keyFiles);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for PrivateKeyConnectionInfo Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PrivateKeyConnectionInfoConstructorTest5()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- int port = 0; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, proxyType, proxyHost, proxyPort, keyFiles);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for PrivateKeyConnectionInfo Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PrivateKeyConnectionInfoConstructorTest6()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- int port = 0; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, keyFiles);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for PrivateKeyConnectionInfo Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PrivateKeyConnectionInfoConstructorTest7()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
- PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, keyFiles);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Tests.Common;
+using Renci.SshNet.Tests.Properties;
+using System.IO;
+using System.Text;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ ///
+ /// Provides connection information when private key authentication method is used
+ ///
+ [TestClass]
+ public class PrivateKeyConnectionInfoTest : TestBase
+ {
+ [TestMethod]
+ [TestCategory("PrivateKeyConnectionInfo")]
+ [TestCategory("integration")]
+ public void Test_PrivateKeyConnectionInfo()
+ {
+ var host = Resources.HOST;
+ var username = Resources.USERNAME;
+ MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITHOUT_PASS));
+
+ #region Example PrivateKeyConnectionInfo PrivateKeyFile
+ var connectionInfo = new PrivateKeyConnectionInfo(host, username, new PrivateKeyFile(keyFileStream));
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ #endregion
+
+ Assert.AreEqual(connectionInfo.Host, Resources.HOST);
+ Assert.AreEqual(connectionInfo.Username, Resources.USERNAME);
+ }
+
+ [TestMethod]
+ [TestCategory("PrivateKeyConnectionInfo")]
+ [TestCategory("integration")]
+ public void Test_PrivateKeyConnectionInfo_MultiplePrivateKey()
+ {
+ var host = Resources.HOST;
+ var username = Resources.USERNAME;
+ MemoryStream keyFileStream1 = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITHOUT_PASS));
+ MemoryStream keyFileStream2 = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITHOUT_PASS));
+
+ #region Example PrivateKeyConnectionInfo PrivateKeyFile Multiple
+ var connectionInfo = new PrivateKeyConnectionInfo(host, username,
+ new PrivateKeyFile(keyFileStream1),
+ new PrivateKeyFile(keyFileStream2));
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ #endregion
+
+ Assert.AreEqual(connectionInfo.Host, Resources.HOST);
+ Assert.AreEqual(connectionInfo.Username, Resources.USERNAME);
+ }
+
+ ///
+ ///A test for Dispose
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DisposeTest()
+ {
+ string host = string.Empty; // TODO: Initialize to an appropriate value
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, keyFiles); // TODO: Initialize to an appropriate value
+ target.Dispose();
+ Assert.Inconclusive("A method that does not return a value cannot be verified.");
+ }
+
+ ///
+ ///A test for PrivateKeyConnectionInfo Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PrivateKeyConnectionInfoConstructorTest()
+ {
+ string host = string.Empty; // TODO: Initialize to an appropriate value
+ int port = 0; // TODO: Initialize to an appropriate value
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
+ string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
+ int proxyPort = 0; // TODO: Initialize to an appropriate value
+ string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
+ string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, keyFiles);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for PrivateKeyConnectionInfo Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PrivateKeyConnectionInfoConstructorTest1()
+ {
+ string host = string.Empty; // TODO: Initialize to an appropriate value
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
+ string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
+ int proxyPort = 0; // TODO: Initialize to an appropriate value
+ string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
+ string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, keyFiles);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for PrivateKeyConnectionInfo Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PrivateKeyConnectionInfoConstructorTest2()
+ {
+ string host = string.Empty; // TODO: Initialize to an appropriate value
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
+ string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
+ int proxyPort = 0; // TODO: Initialize to an appropriate value
+ string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, proxyType, proxyHost, proxyPort, proxyUsername, keyFiles);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for PrivateKeyConnectionInfo Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PrivateKeyConnectionInfoConstructorTest3()
+ {
+ string host = string.Empty; // TODO: Initialize to an appropriate value
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
+ string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
+ int proxyPort = 0; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, proxyType, proxyHost, proxyPort, keyFiles);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for PrivateKeyConnectionInfo Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PrivateKeyConnectionInfoConstructorTest4()
+ {
+ string host = string.Empty; // TODO: Initialize to an appropriate value
+ int port = 0; // TODO: Initialize to an appropriate value
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
+ string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
+ int proxyPort = 0; // TODO: Initialize to an appropriate value
+ string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, keyFiles);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for PrivateKeyConnectionInfo Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PrivateKeyConnectionInfoConstructorTest5()
+ {
+ string host = string.Empty; // TODO: Initialize to an appropriate value
+ int port = 0; // TODO: Initialize to an appropriate value
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
+ string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
+ int proxyPort = 0; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, proxyType, proxyHost, proxyPort, keyFiles);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for PrivateKeyConnectionInfo Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PrivateKeyConnectionInfoConstructorTest6()
+ {
+ string host = string.Empty; // TODO: Initialize to an appropriate value
+ int port = 0; // TODO: Initialize to an appropriate value
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, keyFiles);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for PrivateKeyConnectionInfo Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PrivateKeyConnectionInfoConstructorTest7()
+ {
+ string host = string.Empty; // TODO: Initialize to an appropriate value
+ string username = string.Empty; // TODO: Initialize to an appropriate value
+ PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
+ PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, keyFiles);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs b/src/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs
index 8c979848..77efff4a 100644
--- a/src/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs
@@ -1,504 +1,504 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Tests.Common;
-using System;
-using System.IO;
-
-namespace Renci.SshNet.Tests.Classes
-{
- ///
- /// old private key information/
- ///
- [TestClass]
- public class PrivateKeyFileTest : TestBase
- {
- private string _temporaryFile;
-
- [TestInitialize]
- public void SetUp()
- {
- _temporaryFile = GetTempFileName();
- }
-
- [TestCleanup]
- public void TearDown()
- {
- if (_temporaryFile != null)
- File.Delete(_temporaryFile);
- }
-
- ///
- /// A test for ctor.
- ///
- [WorkItem(703), TestMethod]
- public void ConstructorWithFileNameShouldThrowArgumentNullExceptionWhenFileNameIsEmpty()
- {
- var fileName = string.Empty;
- try
- {
- new PrivateKeyFile(fileName);
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("fileName", ex.ParamName);
- }
- }
-
- ///
- /// A test for ctor.
- ///
- [WorkItem(703), TestMethod]
- public void ConstructorWithFileNameShouldThrowArgumentNullExceptionWhenFileNameIsNull()
- {
- var fileName = string.Empty;
- try
- {
- new PrivateKeyFile(fileName);
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("fileName", ex.ParamName);
- }
- }
-
- ///
- /// A test for ctor.
- ///
- [WorkItem(703), TestMethod]
- public void ConstructorWithFileNameAndPassphraseShouldThrowArgumentNullExceptionWhenFileNameIsEmpty()
- {
- var fileName = string.Empty;
- try
- {
- new PrivateKeyFile(fileName, "12345");
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("fileName", ex.ParamName);
- }
- }
-
- ///
- /// A test for ctor.
- ///
- [WorkItem(703), TestMethod]
- public void ConstructorWithFileNameAndPassphraseShouldThrowArgumentNullExceptionWhenFileNameIsNull()
- {
- var fileName = string.Empty;
- try
- {
- new PrivateKeyFile(fileName, "12345");
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("fileName", ex.ParamName);
- }
- }
-
- [WorkItem(703), TestMethod]
- public void ConstructorWithPrivateKeyShouldThrowArgumentNullExceptionWhenPrivateKeyIsNull()
- {
- Stream privateKey = null;
- try
- {
- new PrivateKeyFile(privateKey);
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("privateKey", ex.ParamName);
- }
- }
-
- [WorkItem(703), TestMethod]
- public void ConstructorWithPrivateKeyAndPassphraseShouldThrowArgumentNullExceptionWhenPrivateKeyIsNull()
- {
- Stream privateKey = null;
- try
- {
- new PrivateKeyFile(privateKey, "12345");
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("privateKey", ex.ParamName);
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_RSA()
- {
- using (var stream = this.GetData("Key.RSA.txt"))
- {
- new PrivateKeyFile(stream);
- }
- }
-
- [TestMethod]
- [Owner("drieseng")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_SSH2_DSA()
- {
- using (var stream = this.GetData("Key.SSH2.DSA.txt"))
- {
- new PrivateKeyFile(stream);
- }
- }
-
- [TestMethod]
- [Owner("drieseng")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_SSH2_RSA()
- {
- using (var stream = this.GetData("Key.SSH2.RSA.txt"))
- {
- new PrivateKeyFile(stream);
- }
- }
-
- [TestMethod]
- [Owner("drieseng")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_SSH2_Encrypted_DSA_DES_CBC()
- {
- using (var stream = this.GetData("Key.SSH2.DSA.Encrypted.Des.CBC.12345.txt"))
- {
- new PrivateKeyFile(stream, "12345");
- }
- }
-
- [TestMethod]
- [Owner("drieseng")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_SSH2_Encrypted_RSA_DES_CBC()
- {
- using (var stream = this.GetData("Key.SSH2.RSA.Encrypted.Des.CBC.12345.txt"))
- {
- new PrivateKeyFile(stream, "12345");
- }
- }
-
- [TestMethod]
- [Owner("drieseng")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_SSH2_Encrypted_ShouldThrowSshExceptionWhenPassphraseIsWrong()
- {
- using (var stream = this.GetData("Key.SSH2.RSA.Encrypted.Des.CBC.12345.txt"))
- {
- try
- {
- new PrivateKeyFile(stream, "34567");
- Assert.Fail();
- }
- catch (SshException ex)
- {
- Assert.IsInstanceOfType(ex, typeof(SshException));
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Invalid passphrase.", ex.Message);
- }
- }
- }
-
- [TestMethod]
- [Owner("drieseng")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_SSH2_Encrypted_ShouldThrowSshPassPhraseNullOrEmptyExceptionWhenPassphraseIsNull()
- {
- using (var stream = this.GetData("Key.SSH2.RSA.Encrypted.Des.CBC.12345.txt"))
- {
- try
- {
- new PrivateKeyFile(stream, null);
- Assert.Fail();
- }
- catch (SshPassPhraseNullOrEmptyException ex)
- {
- Assert.IsInstanceOfType(ex, typeof(SshPassPhraseNullOrEmptyException));
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Private key is encrypted but passphrase is empty.", ex.Message);
- }
- }
- }
-
- [TestMethod]
- [Owner("drieseng")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_SSH2_Encrypted_ShouldThrowSshPassPhraseNullOrEmptyExceptionWhenPassphraseIsEmpty()
- {
- using (var stream = this.GetData("Key.SSH2.RSA.Encrypted.Des.CBC.12345.txt"))
- {
- try
- {
- new PrivateKeyFile(stream, string.Empty);
- Assert.Fail();
- }
- catch (SshPassPhraseNullOrEmptyException ex)
- {
- Assert.IsInstanceOfType(ex, typeof(SshPassPhraseNullOrEmptyException));
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Private key is encrypted but passphrase is empty.", ex.Message);
- }
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_RSA_DES_CBC()
- {
- using (var stream = this.GetData("Key.RSA.Encrypted.Des.CBC.12345.txt"))
- {
- new PrivateKeyFile(stream, "12345");
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_RSA_DES_EDE3_CBC()
- {
- using (var stream = this.GetData("Key.RSA.Encrypted.Des.Ede3.CBC.12345.txt"))
- {
- new PrivateKeyFile(stream, "12345");
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_RSA_AES_128_CBC()
- {
- using (var stream = this.GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
- {
- new PrivateKeyFile(stream, "12345");
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_RSA_AES_192_CBC()
- {
- using (var stream = this.GetData("Key.RSA.Encrypted.Aes.192.CBC.12345.txt"))
- {
- new PrivateKeyFile(stream, "12345");
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_RSA_AES_256_CBC()
- {
- using (var stream = this.GetData("Key.RSA.Encrypted.Aes.256.CBC.12345.txt"))
- {
- new PrivateKeyFile(stream, "12345");
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("PrivateKey")]
- public void Test_PrivateKey_RSA_DES_EDE3_CFB()
- {
- using (var stream = this.GetData("Key.RSA.Encrypted.Des.Ede3.CFB.1234567890.txt"))
- {
- new PrivateKeyFile(stream, "1234567890");
- }
- }
-
- ///
- ///A test for Dispose
- ///
- [TestMethod()]
- public void DisposeTest()
- {
- using (var privateKeyStream = GetData("Key.RSA.txt"))
- {
- var target = new PrivateKeyFile(privateKeyStream);
- target.Dispose();
- }
- }
-
- ///
- /// A test for ctor.
- ///
- [TestMethod()]
- public void ConstructorWithStreamAndPassphrase()
- {
- using (var stream = GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
- {
- var privateKeyFile = new PrivateKeyFile(stream, "12345");
- Assert.IsNotNull(privateKeyFile.HostKey);
- }
- }
-
- ///
- /// A test for ctor.
- ///
- [TestMethod()]
- public void ConstructorWithFileNameAndPassphrase()
- {
- using (var stream = GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
- {
- SaveStreamToFile(stream, _temporaryFile);
- }
-
- using (var fs = File.Open(_temporaryFile, FileMode.Open, FileAccess.Read, FileShare.Read))
- {
- var privateKeyFile = new PrivateKeyFile(_temporaryFile, "12345");
- Assert.IsNotNull(privateKeyFile.HostKey);
-
- fs.Close();
- }
- }
-
- ///
- /// A test for ctor.
- ///
- [TestMethod()]
- public void ConstructorWithFileNameAndPassphraseShouldThrowSshPassPhraseNullOrEmptyExceptionWhenPrivateKeyIsEncryptedAndPassphraseIsEmpty()
- {
- var passphrase = string.Empty;
-
- using (var stream = GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
- {
- SaveStreamToFile(stream, _temporaryFile);
- }
-
- try
- {
- new PrivateKeyFile(_temporaryFile, passphrase);
- Assert.Fail();
- }
- catch (SshPassPhraseNullOrEmptyException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Private key is encrypted but passphrase is empty.", ex.Message);
- }
- }
-
- ///
- /// A test for ctor.
- ///
- [TestMethod()]
- public void ConstructorWithFileNameAndPassphraseShouldThrowSshPassPhraseNullOrEmptyExceptionWhenPrivateKeyIsEncryptedAndPassphraseIsNull()
- {
- string passphrase = null;
-
- using (var stream = GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
- {
- SaveStreamToFile(stream, _temporaryFile);
- }
-
- try
- {
- new PrivateKeyFile(_temporaryFile, passphrase);
- Assert.Fail();
- }
- catch (SshPassPhraseNullOrEmptyException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Private key is encrypted but passphrase is empty.", ex.Message);
- }
- }
-
- ///
- /// A test for ctor.
- ///
- [TestMethod()]
- public void ConstructorWithFileName()
- {
- using (var stream = GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
- {
- SaveStreamToFile(stream, _temporaryFile);
- }
-
- var privateKeyFile = new PrivateKeyFile(_temporaryFile, "12345");
- Assert.IsNotNull(privateKeyFile.HostKey);
- }
-
- ///
- /// A test for ctor.
- ///
- [TestMethod()]
- public void ConstructorWithStream()
- {
- using (var stream = GetData("Key.RSA.txt"))
- {
- var privateKeyFile = new PrivateKeyFile(stream);
- Assert.IsNotNull(privateKeyFile.HostKey);
- }
- }
-
- [TestMethod]
- [TestCategory("PrivateKey")]
- public void ConstructorWithFileNameShouldBeAbleToReadFileThatIsSharedForReadAccess()
- {
- using (var stream = GetData("Key.RSA.txt"))
- {
- SaveStreamToFile(stream, _temporaryFile);
- }
-
- using (var fs = File.Open(_temporaryFile, FileMode.Open, FileAccess.Read, FileShare.Read))
- {
- var privateKeyFile = new PrivateKeyFile(_temporaryFile);
- Assert.IsNotNull(privateKeyFile.HostKey);
-
- fs.Close();
- }
- }
-
- [TestMethod]
- [TestCategory("PrivateKey")]
- public void ConstructorWithFileNameAndPassPhraseShouldBeAbleToReadFileThatIsSharedForReadAccess()
- {
- using (var stream = GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
- {
- SaveStreamToFile(stream, _temporaryFile);
- }
-
- using (var fs = File.Open(_temporaryFile, FileMode.Open, FileAccess.Read, FileShare.Read))
- {
- var privateKeyFile = new PrivateKeyFile(_temporaryFile, "12345");
- Assert.IsNotNull(privateKeyFile.HostKey);
-
- fs.Close();
- }
- }
-
- private void SaveStreamToFile(Stream stream, string fileName)
- {
- var buffer = new byte[4000];
-
- using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
- {
- var bytesRead = stream.Read(buffer, 0, buffer.Length);
- while (bytesRead > 0)
- {
- fs.Write(buffer, 0, bytesRead);
- bytesRead = stream.Read(buffer, 0, buffer.Length);
- }
- }
- }
-
- private string GetTempFileName()
- {
- var tempFile = Path.GetTempFileName();
- File.Delete(tempFile);
- return tempFile;
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Tests.Common;
+using System;
+using System.IO;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ ///
+ /// old private key information/
+ ///
+ [TestClass]
+ public class PrivateKeyFileTest : TestBase
+ {
+ private string _temporaryFile;
+
+ [TestInitialize]
+ public void SetUp()
+ {
+ _temporaryFile = GetTempFileName();
+ }
+
+ [TestCleanup]
+ public void TearDown()
+ {
+ if (_temporaryFile != null)
+ File.Delete(_temporaryFile);
+ }
+
+ ///
+ /// A test for ctor.
+ ///
+ [WorkItem(703), TestMethod]
+ public void ConstructorWithFileNameShouldThrowArgumentNullExceptionWhenFileNameIsEmpty()
+ {
+ var fileName = string.Empty;
+ try
+ {
+ new PrivateKeyFile(fileName);
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("fileName", ex.ParamName);
+ }
+ }
+
+ ///
+ /// A test for ctor.
+ ///
+ [WorkItem(703), TestMethod]
+ public void ConstructorWithFileNameShouldThrowArgumentNullExceptionWhenFileNameIsNull()
+ {
+ var fileName = string.Empty;
+ try
+ {
+ new PrivateKeyFile(fileName);
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("fileName", ex.ParamName);
+ }
+ }
+
+ ///
+ /// A test for ctor.
+ ///
+ [WorkItem(703), TestMethod]
+ public void ConstructorWithFileNameAndPassphraseShouldThrowArgumentNullExceptionWhenFileNameIsEmpty()
+ {
+ var fileName = string.Empty;
+ try
+ {
+ new PrivateKeyFile(fileName, "12345");
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("fileName", ex.ParamName);
+ }
+ }
+
+ ///
+ /// A test for ctor.
+ ///
+ [WorkItem(703), TestMethod]
+ public void ConstructorWithFileNameAndPassphraseShouldThrowArgumentNullExceptionWhenFileNameIsNull()
+ {
+ var fileName = string.Empty;
+ try
+ {
+ new PrivateKeyFile(fileName, "12345");
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("fileName", ex.ParamName);
+ }
+ }
+
+ [WorkItem(703), TestMethod]
+ public void ConstructorWithPrivateKeyShouldThrowArgumentNullExceptionWhenPrivateKeyIsNull()
+ {
+ Stream privateKey = null;
+ try
+ {
+ new PrivateKeyFile(privateKey);
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("privateKey", ex.ParamName);
+ }
+ }
+
+ [WorkItem(703), TestMethod]
+ public void ConstructorWithPrivateKeyAndPassphraseShouldThrowArgumentNullExceptionWhenPrivateKeyIsNull()
+ {
+ Stream privateKey = null;
+ try
+ {
+ new PrivateKeyFile(privateKey, "12345");
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("privateKey", ex.ParamName);
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_RSA()
+ {
+ using (var stream = this.GetData("Key.RSA.txt"))
+ {
+ new PrivateKeyFile(stream);
+ }
+ }
+
+ [TestMethod]
+ [Owner("drieseng")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_SSH2_DSA()
+ {
+ using (var stream = this.GetData("Key.SSH2.DSA.txt"))
+ {
+ new PrivateKeyFile(stream);
+ }
+ }
+
+ [TestMethod]
+ [Owner("drieseng")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_SSH2_RSA()
+ {
+ using (var stream = this.GetData("Key.SSH2.RSA.txt"))
+ {
+ new PrivateKeyFile(stream);
+ }
+ }
+
+ [TestMethod]
+ [Owner("drieseng")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_SSH2_Encrypted_DSA_DES_CBC()
+ {
+ using (var stream = this.GetData("Key.SSH2.DSA.Encrypted.Des.CBC.12345.txt"))
+ {
+ new PrivateKeyFile(stream, "12345");
+ }
+ }
+
+ [TestMethod]
+ [Owner("drieseng")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_SSH2_Encrypted_RSA_DES_CBC()
+ {
+ using (var stream = this.GetData("Key.SSH2.RSA.Encrypted.Des.CBC.12345.txt"))
+ {
+ new PrivateKeyFile(stream, "12345");
+ }
+ }
+
+ [TestMethod]
+ [Owner("drieseng")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_SSH2_Encrypted_ShouldThrowSshExceptionWhenPassphraseIsWrong()
+ {
+ using (var stream = this.GetData("Key.SSH2.RSA.Encrypted.Des.CBC.12345.txt"))
+ {
+ try
+ {
+ new PrivateKeyFile(stream, "34567");
+ Assert.Fail();
+ }
+ catch (SshException ex)
+ {
+ Assert.IsInstanceOfType(ex, typeof(SshException));
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Invalid passphrase.", ex.Message);
+ }
+ }
+ }
+
+ [TestMethod]
+ [Owner("drieseng")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_SSH2_Encrypted_ShouldThrowSshPassPhraseNullOrEmptyExceptionWhenPassphraseIsNull()
+ {
+ using (var stream = this.GetData("Key.SSH2.RSA.Encrypted.Des.CBC.12345.txt"))
+ {
+ try
+ {
+ new PrivateKeyFile(stream, null);
+ Assert.Fail();
+ }
+ catch (SshPassPhraseNullOrEmptyException ex)
+ {
+ Assert.IsInstanceOfType(ex, typeof(SshPassPhraseNullOrEmptyException));
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Private key is encrypted but passphrase is empty.", ex.Message);
+ }
+ }
+ }
+
+ [TestMethod]
+ [Owner("drieseng")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_SSH2_Encrypted_ShouldThrowSshPassPhraseNullOrEmptyExceptionWhenPassphraseIsEmpty()
+ {
+ using (var stream = this.GetData("Key.SSH2.RSA.Encrypted.Des.CBC.12345.txt"))
+ {
+ try
+ {
+ new PrivateKeyFile(stream, string.Empty);
+ Assert.Fail();
+ }
+ catch (SshPassPhraseNullOrEmptyException ex)
+ {
+ Assert.IsInstanceOfType(ex, typeof(SshPassPhraseNullOrEmptyException));
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Private key is encrypted but passphrase is empty.", ex.Message);
+ }
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_RSA_DES_CBC()
+ {
+ using (var stream = this.GetData("Key.RSA.Encrypted.Des.CBC.12345.txt"))
+ {
+ new PrivateKeyFile(stream, "12345");
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_RSA_DES_EDE3_CBC()
+ {
+ using (var stream = this.GetData("Key.RSA.Encrypted.Des.Ede3.CBC.12345.txt"))
+ {
+ new PrivateKeyFile(stream, "12345");
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_RSA_AES_128_CBC()
+ {
+ using (var stream = this.GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
+ {
+ new PrivateKeyFile(stream, "12345");
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_RSA_AES_192_CBC()
+ {
+ using (var stream = this.GetData("Key.RSA.Encrypted.Aes.192.CBC.12345.txt"))
+ {
+ new PrivateKeyFile(stream, "12345");
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_RSA_AES_256_CBC()
+ {
+ using (var stream = this.GetData("Key.RSA.Encrypted.Aes.256.CBC.12345.txt"))
+ {
+ new PrivateKeyFile(stream, "12345");
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("PrivateKey")]
+ public void Test_PrivateKey_RSA_DES_EDE3_CFB()
+ {
+ using (var stream = this.GetData("Key.RSA.Encrypted.Des.Ede3.CFB.1234567890.txt"))
+ {
+ new PrivateKeyFile(stream, "1234567890");
+ }
+ }
+
+ ///
+ ///A test for Dispose
+ ///
+ [TestMethod()]
+ public void DisposeTest()
+ {
+ using (var privateKeyStream = GetData("Key.RSA.txt"))
+ {
+ var target = new PrivateKeyFile(privateKeyStream);
+ target.Dispose();
+ }
+ }
+
+ ///
+ /// A test for ctor.
+ ///
+ [TestMethod()]
+ public void ConstructorWithStreamAndPassphrase()
+ {
+ using (var stream = GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
+ {
+ var privateKeyFile = new PrivateKeyFile(stream, "12345");
+ Assert.IsNotNull(privateKeyFile.HostKey);
+ }
+ }
+
+ ///
+ /// A test for ctor.
+ ///
+ [TestMethod()]
+ public void ConstructorWithFileNameAndPassphrase()
+ {
+ using (var stream = GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
+ {
+ SaveStreamToFile(stream, _temporaryFile);
+ }
+
+ using (var fs = File.Open(_temporaryFile, FileMode.Open, FileAccess.Read, FileShare.Read))
+ {
+ var privateKeyFile = new PrivateKeyFile(_temporaryFile, "12345");
+ Assert.IsNotNull(privateKeyFile.HostKey);
+
+ fs.Close();
+ }
+ }
+
+ ///
+ /// A test for ctor.
+ ///
+ [TestMethod()]
+ public void ConstructorWithFileNameAndPassphraseShouldThrowSshPassPhraseNullOrEmptyExceptionWhenPrivateKeyIsEncryptedAndPassphraseIsEmpty()
+ {
+ var passphrase = string.Empty;
+
+ using (var stream = GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
+ {
+ SaveStreamToFile(stream, _temporaryFile);
+ }
+
+ try
+ {
+ new PrivateKeyFile(_temporaryFile, passphrase);
+ Assert.Fail();
+ }
+ catch (SshPassPhraseNullOrEmptyException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Private key is encrypted but passphrase is empty.", ex.Message);
+ }
+ }
+
+ ///
+ /// A test for ctor.
+ ///
+ [TestMethod()]
+ public void ConstructorWithFileNameAndPassphraseShouldThrowSshPassPhraseNullOrEmptyExceptionWhenPrivateKeyIsEncryptedAndPassphraseIsNull()
+ {
+ string passphrase = null;
+
+ using (var stream = GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
+ {
+ SaveStreamToFile(stream, _temporaryFile);
+ }
+
+ try
+ {
+ new PrivateKeyFile(_temporaryFile, passphrase);
+ Assert.Fail();
+ }
+ catch (SshPassPhraseNullOrEmptyException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Private key is encrypted but passphrase is empty.", ex.Message);
+ }
+ }
+
+ ///
+ /// A test for ctor.
+ ///
+ [TestMethod()]
+ public void ConstructorWithFileName()
+ {
+ using (var stream = GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
+ {
+ SaveStreamToFile(stream, _temporaryFile);
+ }
+
+ var privateKeyFile = new PrivateKeyFile(_temporaryFile, "12345");
+ Assert.IsNotNull(privateKeyFile.HostKey);
+ }
+
+ ///
+ /// A test for ctor.
+ ///
+ [TestMethod()]
+ public void ConstructorWithStream()
+ {
+ using (var stream = GetData("Key.RSA.txt"))
+ {
+ var privateKeyFile = new PrivateKeyFile(stream);
+ Assert.IsNotNull(privateKeyFile.HostKey);
+ }
+ }
+
+ [TestMethod]
+ [TestCategory("PrivateKey")]
+ public void ConstructorWithFileNameShouldBeAbleToReadFileThatIsSharedForReadAccess()
+ {
+ using (var stream = GetData("Key.RSA.txt"))
+ {
+ SaveStreamToFile(stream, _temporaryFile);
+ }
+
+ using (var fs = File.Open(_temporaryFile, FileMode.Open, FileAccess.Read, FileShare.Read))
+ {
+ var privateKeyFile = new PrivateKeyFile(_temporaryFile);
+ Assert.IsNotNull(privateKeyFile.HostKey);
+
+ fs.Close();
+ }
+ }
+
+ [TestMethod]
+ [TestCategory("PrivateKey")]
+ public void ConstructorWithFileNameAndPassPhraseShouldBeAbleToReadFileThatIsSharedForReadAccess()
+ {
+ using (var stream = GetData("Key.RSA.Encrypted.Aes.128.CBC.12345.txt"))
+ {
+ SaveStreamToFile(stream, _temporaryFile);
+ }
+
+ using (var fs = File.Open(_temporaryFile, FileMode.Open, FileAccess.Read, FileShare.Read))
+ {
+ var privateKeyFile = new PrivateKeyFile(_temporaryFile, "12345");
+ Assert.IsNotNull(privateKeyFile.HostKey);
+
+ fs.Close();
+ }
+ }
+
+ private void SaveStreamToFile(Stream stream, string fileName)
+ {
+ var buffer = new byte[4000];
+
+ using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
+ {
+ var bytesRead = stream.Read(buffer, 0, buffer.Length);
+ while (bytesRead > 0)
+ {
+ fs.Write(buffer, 0, bytesRead);
+ bytesRead = stream.Read(buffer, 0, buffer.Length);
+ }
+ }
+ }
+
+ private string GetTempFileName()
+ {
+ var tempFile = Path.GetTempFileName();
+ File.Delete(tempFile);
+ return tempFile;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/AlgorithmTest.cs b/src/Renci.SshNet.Tests/Classes/Security/AlgorithmTest.cs
index 26c9c134..00c9d5d2 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/AlgorithmTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/AlgorithmTest.cs
@@ -1,34 +1,34 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security
-{
- ///
- ///This is a test class for AlgorithmTest and is intended
- ///to contain all AlgorithmTest Unit Tests
- ///
- [TestClass()]
- public class AlgorithmTest : TestBase
- {
- internal virtual Algorithm CreateAlgorithm()
- {
- // TODO: Instantiate an appropriate concrete class.
- Algorithm target = null;
- return target;
- }
-
- ///
- ///A test for Name
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void NameTest()
- {
- Algorithm target = CreateAlgorithm(); // TODO: Initialize to an appropriate value
- string actual;
- actual = target.Name;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security
+{
+ ///
+ ///This is a test class for AlgorithmTest and is intended
+ ///to contain all AlgorithmTest Unit Tests
+ ///
+ [TestClass()]
+ public class AlgorithmTest : TestBase
+ {
+ internal virtual Algorithm CreateAlgorithm()
+ {
+ // TODO: Instantiate an appropriate concrete class.
+ Algorithm target = null;
+ return target;
+ }
+
+ ///
+ ///A test for Name
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void NameTest()
+ {
+ Algorithm target = CreateAlgorithm(); // TODO: Initialize to an appropriate value
+ string actual;
+ actual = target.Name;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs b/src/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs
index 049a31ff..813fec59 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs
@@ -1,74 +1,74 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security
-{
- ///
- ///This is a test class for CertificateHostAlgorithmTest and is intended
- ///to contain all CertificateHostAlgorithmTest Unit Tests
- ///
- [TestClass()]
- public class CertificateHostAlgorithmTest : TestBase
- {
- ///
- ///A test for CertificateHostAlgorithm Constructor
- ///
- [TestMethod]
- public void CertificateHostAlgorithmConstructorTest()
- {
- string name = string.Empty; // TODO: Initialize to an appropriate value
- CertificateHostAlgorithm target = new CertificateHostAlgorithm(name);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for Sign
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void SignTest()
- {
- string name = string.Empty; // TODO: Initialize to an appropriate value
- CertificateHostAlgorithm target = new CertificateHostAlgorithm(name); // TODO: Initialize to an appropriate value
- byte[] data = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Sign(data);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for VerifySignature
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void VerifySignatureTest()
- {
- string name = string.Empty; // TODO: Initialize to an appropriate value
- CertificateHostAlgorithm target = new CertificateHostAlgorithm(name); // TODO: Initialize to an appropriate value
- byte[] data = null; // TODO: Initialize to an appropriate value
- byte[] signature = null; // TODO: Initialize to an appropriate value
- bool expected = false; // TODO: Initialize to an appropriate value
- bool actual;
- actual = target.VerifySignature(data, signature);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Data
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DataTest()
- {
- string name = string.Empty; // TODO: Initialize to an appropriate value
- CertificateHostAlgorithm target = new CertificateHostAlgorithm(name); // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Data;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security
+{
+ ///
+ ///This is a test class for CertificateHostAlgorithmTest and is intended
+ ///to contain all CertificateHostAlgorithmTest Unit Tests
+ ///
+ [TestClass()]
+ public class CertificateHostAlgorithmTest : TestBase
+ {
+ ///
+ ///A test for CertificateHostAlgorithm Constructor
+ ///
+ [TestMethod]
+ public void CertificateHostAlgorithmConstructorTest()
+ {
+ string name = string.Empty; // TODO: Initialize to an appropriate value
+ CertificateHostAlgorithm target = new CertificateHostAlgorithm(name);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for Sign
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void SignTest()
+ {
+ string name = string.Empty; // TODO: Initialize to an appropriate value
+ CertificateHostAlgorithm target = new CertificateHostAlgorithm(name); // TODO: Initialize to an appropriate value
+ byte[] data = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Sign(data);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for VerifySignature
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void VerifySignatureTest()
+ {
+ string name = string.Empty; // TODO: Initialize to an appropriate value
+ CertificateHostAlgorithm target = new CertificateHostAlgorithm(name); // TODO: Initialize to an appropriate value
+ byte[] data = null; // TODO: Initialize to an appropriate value
+ byte[] signature = null; // TODO: Initialize to an appropriate value
+ bool expected = false; // TODO: Initialize to an appropriate value
+ bool actual;
+ actual = target.VerifySignature(data, signature);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Data
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DataTest()
+ {
+ string name = string.Empty; // TODO: Initialize to an appropriate value
+ CertificateHostAlgorithm target = new CertificateHostAlgorithm(name); // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Data;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/BlockCipherTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/BlockCipherTest.cs
index 6442b4ea..49546d61 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/BlockCipherTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/BlockCipherTest.cs
@@ -1,77 +1,77 @@
-using System;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography;
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Renci.SshNet.Security.Cryptography.Ciphers.Paddings;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography
-{
- [TestClass]
- public class BlockCipherTest : TestBase
- {
- [TestMethod]
- public void EncryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToEncryptBlock()
- {
- var input = new byte[] { 0x2c, 0x1a, 0x05, 0x00, 0x68 };
- var output = new byte[] { 0x0a, 0x00, 0x03, 0x02, 0x06, 0x08, 0x07, 0x05 };
- var key = new byte[] { 0x17, 0x78, 0x56, 0xe1, 0x3e, 0xbd, 0x3e, 0x50, 0x1d, 0x79, 0x3f, 0x0f, 0x55, 0x37, 0x45, 0x54 };
- var blockCipher = new BlockCipherStub(key, 8, null, new PKCS5Padding())
- {
- EncryptBlockDelegate = (inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset) =>
- {
- Assert.AreEqual(8, outputBuffer.Length);
- Buffer.BlockCopy(output, 0, outputBuffer, 0, output.Length);
- return inputBuffer.Length;
- }
- };
-
- var actual = blockCipher.Encrypt(input);
-
- Assert.IsTrue(output.SequenceEqual(actual));
- }
-
- [TestMethod]
- public void DecryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToDecryptBlock()
- {
- var input = new byte[] { 0x2c, 0x1a, 0x05, 0x00, 0x68 };
- var output = new byte[] { 0x0a, 0x00, 0x03, 0x02, 0x06, 0x08, 0x07, 0x05 };
- var key = new byte[] { 0x17, 0x78, 0x56, 0xe1, 0x3e, 0xbd, 0x3e, 0x50, 0x1d, 0x79, 0x3f, 0x0f, 0x55, 0x37, 0x45, 0x54 };
- var blockCipher = new BlockCipherStub(key, 8, null, new PKCS5Padding())
- {
- DecryptBlockDelegate = (inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset) =>
- {
- Assert.AreEqual(8, outputBuffer.Length);
- Buffer.BlockCopy(output, 0, outputBuffer, 0, output.Length);
- return inputBuffer.Length;
- }
- };
-
- var actual = blockCipher.Decrypt(input);
-
- Assert.IsTrue(output.SequenceEqual(actual));
- }
-
-
- private class BlockCipherStub : BlockCipher
- {
- public Func EncryptBlockDelegate;
- public Func DecryptBlockDelegate;
-
- public BlockCipherStub(byte[] key, byte blockSize, CipherMode mode, CipherPadding padding) : base(key, blockSize, mode, padding)
- {
- }
-
- public override int EncryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
- {
- return EncryptBlockDelegate(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- }
-
- public override int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
- {
- return DecryptBlockDelegate(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- }
- }
- }
-}
+using System;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography;
+using Renci.SshNet.Security.Cryptography.Ciphers;
+using Renci.SshNet.Security.Cryptography.Ciphers.Paddings;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography
+{
+ [TestClass]
+ public class BlockCipherTest : TestBase
+ {
+ [TestMethod]
+ public void EncryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToEncryptBlock()
+ {
+ var input = new byte[] { 0x2c, 0x1a, 0x05, 0x00, 0x68 };
+ var output = new byte[] { 0x0a, 0x00, 0x03, 0x02, 0x06, 0x08, 0x07, 0x05 };
+ var key = new byte[] { 0x17, 0x78, 0x56, 0xe1, 0x3e, 0xbd, 0x3e, 0x50, 0x1d, 0x79, 0x3f, 0x0f, 0x55, 0x37, 0x45, 0x54 };
+ var blockCipher = new BlockCipherStub(key, 8, null, new PKCS5Padding())
+ {
+ EncryptBlockDelegate = (inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset) =>
+ {
+ Assert.AreEqual(8, outputBuffer.Length);
+ Buffer.BlockCopy(output, 0, outputBuffer, 0, output.Length);
+ return inputBuffer.Length;
+ }
+ };
+
+ var actual = blockCipher.Encrypt(input);
+
+ Assert.IsTrue(output.SequenceEqual(actual));
+ }
+
+ [TestMethod]
+ public void DecryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToDecryptBlock()
+ {
+ var input = new byte[] { 0x2c, 0x1a, 0x05, 0x00, 0x68 };
+ var output = new byte[] { 0x0a, 0x00, 0x03, 0x02, 0x06, 0x08, 0x07, 0x05 };
+ var key = new byte[] { 0x17, 0x78, 0x56, 0xe1, 0x3e, 0xbd, 0x3e, 0x50, 0x1d, 0x79, 0x3f, 0x0f, 0x55, 0x37, 0x45, 0x54 };
+ var blockCipher = new BlockCipherStub(key, 8, null, new PKCS5Padding())
+ {
+ DecryptBlockDelegate = (inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset) =>
+ {
+ Assert.AreEqual(8, outputBuffer.Length);
+ Buffer.BlockCopy(output, 0, outputBuffer, 0, output.Length);
+ return inputBuffer.Length;
+ }
+ };
+
+ var actual = blockCipher.Decrypt(input);
+
+ Assert.IsTrue(output.SequenceEqual(actual));
+ }
+
+
+ private class BlockCipherStub : BlockCipher
+ {
+ public Func EncryptBlockDelegate;
+ public Func DecryptBlockDelegate;
+
+ public BlockCipherStub(byte[] key, byte blockSize, CipherMode mode, CipherPadding padding) : base(key, blockSize, mode, padding)
+ {
+ }
+
+ public override int EncryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
+ {
+ return EncryptBlockDelegate(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ }
+
+ public override int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
+ {
+ return DecryptBlockDelegate(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ }
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/CipherDigitalSignatureTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/CipherDigitalSignatureTest.cs
index cbc5a65a..2bdce8e1 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/CipherDigitalSignatureTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/CipherDigitalSignatureTest.cs
@@ -1,54 +1,54 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography
-{
- ///
- ///This is a test class for CipherDigitalSignatureTest and is intended
- ///to contain all CipherDigitalSignatureTest Unit Tests
- ///
- [TestClass()]
- public class CipherDigitalSignatureTest : TestBase
- {
- internal virtual CipherDigitalSignature CreateCipherDigitalSignature()
- {
- // TODO: Instantiate an appropriate concrete class.
- CipherDigitalSignature target = null;
- return target;
- }
-
- ///
- ///A test for Sign
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void SignTest()
- {
- CipherDigitalSignature target = CreateCipherDigitalSignature(); // TODO: Initialize to an appropriate value
- byte[] input = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Sign(input);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Verify
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void VerifyTest()
- {
- CipherDigitalSignature target = CreateCipherDigitalSignature(); // TODO: Initialize to an appropriate value
- byte[] input = null; // TODO: Initialize to an appropriate value
- byte[] signature = null; // TODO: Initialize to an appropriate value
- bool expected = false; // TODO: Initialize to an appropriate value
- bool actual;
- actual = target.Verify(input, signature);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography
+{
+ ///
+ ///This is a test class for CipherDigitalSignatureTest and is intended
+ ///to contain all CipherDigitalSignatureTest Unit Tests
+ ///
+ [TestClass()]
+ public class CipherDigitalSignatureTest : TestBase
+ {
+ internal virtual CipherDigitalSignature CreateCipherDigitalSignature()
+ {
+ // TODO: Instantiate an appropriate concrete class.
+ CipherDigitalSignature target = null;
+ return target;
+ }
+
+ ///
+ ///A test for Sign
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void SignTest()
+ {
+ CipherDigitalSignature target = CreateCipherDigitalSignature(); // TODO: Initialize to an appropriate value
+ byte[] input = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Sign(input);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Verify
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void VerifyTest()
+ {
+ CipherDigitalSignature target = CreateCipherDigitalSignature(); // TODO: Initialize to an appropriate value
+ byte[] input = null; // TODO: Initialize to an appropriate value
+ byte[] signature = null; // TODO: Initialize to an appropriate value
+ bool expected = false; // TODO: Initialize to an appropriate value
+ bool actual;
+ actual = target.Verify(input, signature);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/CipherTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/CipherTest.cs
index c5f4a2b5..8af4f653 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/CipherTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/CipherTest.cs
@@ -1,53 +1,53 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography
-{
- ///
- ///This is a test class for CipherTest and is intended
- ///to contain all CipherTest Unit Tests
- ///
- [TestClass()]
- public class CipherTest : TestBase
- {
- internal virtual Cipher CreateCipher()
- {
- // TODO: Instantiate an appropriate concrete class.
- Cipher target = null;
- return target;
- }
-
- ///
- ///A test for Decrypt
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptTest()
- {
- Cipher target = CreateCipher(); // TODO: Initialize to an appropriate value
- byte[] input = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Decrypt(input);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Encrypt
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptTest()
- {
- Cipher target = CreateCipher(); // TODO: Initialize to an appropriate value
- byte[] input = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Encrypt(input);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography
+{
+ ///
+ ///This is a test class for CipherTest and is intended
+ ///to contain all CipherTest Unit Tests
+ ///
+ [TestClass()]
+ public class CipherTest : TestBase
+ {
+ internal virtual Cipher CreateCipher()
+ {
+ // TODO: Instantiate an appropriate concrete class.
+ Cipher target = null;
+ return target;
+ }
+
+ ///
+ ///A test for Decrypt
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptTest()
+ {
+ Cipher target = CreateCipher(); // TODO: Initialize to an appropriate value
+ byte[] input = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Decrypt(input);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Encrypt
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptTest()
+ {
+ Cipher target = CreateCipher(); // TODO: Initialize to an appropriate value
+ byte[] input = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Encrypt(input);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/AesCipherTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/AesCipherTest.cs
index 5d16c7b9..deeb0cb5 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/AesCipherTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/AesCipherTest.cs
@@ -1,239 +1,239 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
-using Renci.SshNet.Tests.Common;
-using Renci.SshNet.Tests.Properties;
-using System.Linq;
-using Renci.SshNet.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
-{
- ///
- ///
- ///
- [TestClass]
- public class AesCipherTest : TestBase
- {
- [TestMethod]
- public void Test_Cipher_AES_128_CBC()
- {
- var input = new byte[] { 0x00, 0x00, 0x00, 0x2c, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0x30, 0x9e, 0xe0, 0x9c, 0x12, 0xee, 0x3a, 0x30, 0x03, 0x52, 0x1c, 0x1a, 0xe7, 0x3e, 0x0b, 0x9a, 0xcf, 0x9a, 0x57, 0x42, 0x0b, 0x4f, 0x4a, 0x15, 0xa0, 0xf5 };
- var key = new byte[] { 0xe4, 0x94, 0xf9, 0xb1, 0x00, 0x4f, 0x16, 0x2a, 0x80, 0x11, 0xea, 0x73, 0x0d, 0xb9, 0xbf, 0x64 };
- var iv = new byte[] { 0x74, 0x8b, 0x4f, 0xe6, 0xc1, 0x29, 0xb3, 0x54, 0xec, 0x77, 0x92, 0xf3, 0x15, 0xa0, 0x41, 0xa8 };
- var output = new byte[] { 0x19, 0x7f, 0x80, 0xd8, 0xc9, 0x89, 0xc4, 0xa7, 0xc6, 0xc6, 0x3f, 0x9f, 0x1e, 0x00, 0x1f, 0x72, 0xa7, 0x5e, 0xde, 0x40, 0x88, 0xa2, 0x72, 0xf2, 0xed, 0x3f, 0x81, 0x45, 0xb6, 0xbd, 0x45, 0x87, 0x15, 0xa5, 0x10, 0x92, 0x4a, 0x37, 0x9e, 0xa9, 0x80, 0x1c, 0x14, 0x83, 0xa3, 0x39, 0x45, 0x28 };
- var testCipher = new AesCipher(key, new CbcCipherMode(iv), null);
- var r = testCipher.Encrypt(input);
-
- if (!r.SequenceEqual(output))
- Assert.Fail("Invalid encryption");
- }
-
- [TestMethod]
- public void Test_Cipher_AES_128_CTR()
- {
- var input = new byte[] { 0x00, 0x00, 0x00, 0x2c, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0xb0, 0x74, 0x21, 0x87, 0x16, 0xb9, 0x69, 0x48, 0x33, 0xce, 0xb3, 0xe7, 0xdc, 0x3f, 0x50, 0xdc, 0xcc, 0xd5, 0x27, 0xb7, 0xfe, 0x7a, 0x78, 0x22, 0xae, 0xc8 };
- var key = new byte[] { 0x17, 0x78, 0x56, 0xe1, 0x3e, 0xbd, 0x3e, 0x50, 0x1d, 0x79, 0x3f, 0x0f, 0x55, 0x37, 0x45, 0x54 };
- var iv = new byte[] { 0xe6, 0x65, 0x36, 0x0d, 0xdd, 0xd7, 0x50, 0xc3, 0x48, 0xdb, 0x48, 0x07, 0xa1, 0x30, 0xd2, 0x38 };
- var expected = new byte[] { 0xca, 0xfb, 0x1c, 0x49, 0xbf, 0x82, 0x2a, 0xbb, 0x1c, 0x52, 0xc7, 0x86, 0x22, 0x8a, 0xe5, 0xa4, 0xf3, 0xda, 0x4e, 0x1c, 0x3a, 0x87, 0x41, 0x1c, 0xd2, 0x6e, 0x76, 0xdc, 0xc2, 0xe9, 0xc2, 0x0e, 0xf5, 0xc7, 0xbd, 0x12, 0x85, 0xfa, 0x0e, 0xda, 0xee, 0x50, 0xd7, 0xfd, 0x81, 0x34, 0x25, 0x6d };
- var testCipher = new AesCipher(key, new CtrCipherMode(iv), null);
-
- var actual = testCipher.Encrypt(input);
-
- Assert.IsTrue(actual.IsEqualTo(expected));
- }
-
- [TestMethod]
- public void Decrypt_AES_128_CTR()
- {
- var input = new byte[] { 0x00, 0x00, 0x00, 0x2c, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0xb0, 0x74, 0x21, 0x87, 0x16, 0xb9, 0x69, 0x48, 0x33, 0xce, 0xb3, 0xe7, 0xdc, 0x3f, 0x50, 0xdc, 0xcc, 0xd5, 0x27, 0xb7, 0xfe, 0x7a, 0x78, 0x22, 0xae, 0xc8 };
- var key = new byte[] { 0x17, 0x78, 0x56, 0xe1, 0x3e, 0xbd, 0x3e, 0x50, 0x1d, 0x79, 0x3f, 0x0f, 0x55, 0x37, 0x45, 0x54 };
- var iv = new byte[] { 0xe6, 0x65, 0x36, 0x0d, 0xdd, 0xd7, 0x50, 0xc3, 0x48, 0xdb, 0x48, 0x07, 0xa1, 0x30, 0xd2, 0x38 };
- var output = new byte[] { 0xca, 0xfb, 0x1c, 0x49, 0xbf, 0x82, 0x2a, 0xbb, 0x1c, 0x52, 0xc7, 0x86, 0x22, 0x8a, 0xe5, 0xa4, 0xf3, 0xda, 0x4e, 0x1c, 0x3a, 0x87, 0x41, 0x1c, 0xd2, 0x6e, 0x76, 0xdc, 0xc2, 0xe9, 0xc2, 0x0e, 0xf5, 0xc7, 0xbd, 0x12, 0x85, 0xfa, 0x0e, 0xda, 0xee, 0x50, 0xd7, 0xfd, 0x81, 0x34, 0x25, 0x6d };
- var testCipher = new AesCipher(key, new CtrCipherMode(iv), null);
-
- var actual = testCipher.Decrypt(output);
-
- Assert.IsTrue(input.IsEqualTo(actual));
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("Cipher")]
- [TestCategory("integration")]
- public void Test_Cipher_AEes128CBC_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.Encryptions.Clear();
- connectionInfo.Encryptions.Add("aes128-cbc", new CipherInfo(128, (key, iv) => { return new AesCipher(key, new CbcCipherMode(iv), null); }));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("Cipher")]
- [TestCategory("integration")]
- public void Test_Cipher_Aes192CBC_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.Encryptions.Clear();
- connectionInfo.Encryptions.Add("aes192-cbc", new CipherInfo(192, (key, iv) => { return new AesCipher(key, new CbcCipherMode(iv), null); }));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("Cipher")]
- [TestCategory("integration")]
- public void Test_Cipher_Aes256CBC_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.Encryptions.Clear();
- connectionInfo.Encryptions.Add("aes256-cbc", new CipherInfo(256, (key, iv) => { return new AesCipher(key, new CbcCipherMode(iv), null); }));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("Cipher")]
- [TestCategory("integration")]
- public void Test_Cipher_Aes128CTR_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.Encryptions.Clear();
- connectionInfo.Encryptions.Add("aes128-ctr", new CipherInfo(128, (key, iv) => { return new AesCipher(key, new CtrCipherMode(iv), null); }));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("Cipher")]
- [TestCategory("integration")]
- public void Test_Cipher_Aes192CTR_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.Encryptions.Clear();
- connectionInfo.Encryptions.Add("aes192-ctr", new CipherInfo(192, (key, iv) => { return new AesCipher(key, new CtrCipherMode(iv), null); }));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("Cipher")]
- [TestCategory("integration")]
- public void Test_Cipher_Aes256CTR_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.Encryptions.Clear();
- connectionInfo.Encryptions.Add("aes256-ctr", new CipherInfo(256, (key, iv) => { return new AesCipher(key, new CtrCipherMode(iv), null); }));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("Cipher")]
- [TestCategory("integration")]
- public void Test_Cipher_Arcfour_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.Encryptions.Clear();
- connectionInfo.Encryptions.Add("arcfour", new CipherInfo(128, (key, iv) => { return new Arc4Cipher(key, false); }));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- AesCipher target = new AesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for AesCipher Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void AesCipherConstructorTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- AesCipher target = new AesCipher(key, mode, padding);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- AesCipher target = new AesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
+using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers;
+using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
+using Renci.SshNet.Tests.Common;
+using Renci.SshNet.Tests.Properties;
+using System.Linq;
+using Renci.SshNet.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
+{
+ ///
+ ///
+ ///
+ [TestClass]
+ public class AesCipherTest : TestBase
+ {
+ [TestMethod]
+ public void Test_Cipher_AES_128_CBC()
+ {
+ var input = new byte[] { 0x00, 0x00, 0x00, 0x2c, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0x30, 0x9e, 0xe0, 0x9c, 0x12, 0xee, 0x3a, 0x30, 0x03, 0x52, 0x1c, 0x1a, 0xe7, 0x3e, 0x0b, 0x9a, 0xcf, 0x9a, 0x57, 0x42, 0x0b, 0x4f, 0x4a, 0x15, 0xa0, 0xf5 };
+ var key = new byte[] { 0xe4, 0x94, 0xf9, 0xb1, 0x00, 0x4f, 0x16, 0x2a, 0x80, 0x11, 0xea, 0x73, 0x0d, 0xb9, 0xbf, 0x64 };
+ var iv = new byte[] { 0x74, 0x8b, 0x4f, 0xe6, 0xc1, 0x29, 0xb3, 0x54, 0xec, 0x77, 0x92, 0xf3, 0x15, 0xa0, 0x41, 0xa8 };
+ var output = new byte[] { 0x19, 0x7f, 0x80, 0xd8, 0xc9, 0x89, 0xc4, 0xa7, 0xc6, 0xc6, 0x3f, 0x9f, 0x1e, 0x00, 0x1f, 0x72, 0xa7, 0x5e, 0xde, 0x40, 0x88, 0xa2, 0x72, 0xf2, 0xed, 0x3f, 0x81, 0x45, 0xb6, 0xbd, 0x45, 0x87, 0x15, 0xa5, 0x10, 0x92, 0x4a, 0x37, 0x9e, 0xa9, 0x80, 0x1c, 0x14, 0x83, 0xa3, 0x39, 0x45, 0x28 };
+ var testCipher = new AesCipher(key, new CbcCipherMode(iv), null);
+ var r = testCipher.Encrypt(input);
+
+ if (!r.SequenceEqual(output))
+ Assert.Fail("Invalid encryption");
+ }
+
+ [TestMethod]
+ public void Test_Cipher_AES_128_CTR()
+ {
+ var input = new byte[] { 0x00, 0x00, 0x00, 0x2c, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0xb0, 0x74, 0x21, 0x87, 0x16, 0xb9, 0x69, 0x48, 0x33, 0xce, 0xb3, 0xe7, 0xdc, 0x3f, 0x50, 0xdc, 0xcc, 0xd5, 0x27, 0xb7, 0xfe, 0x7a, 0x78, 0x22, 0xae, 0xc8 };
+ var key = new byte[] { 0x17, 0x78, 0x56, 0xe1, 0x3e, 0xbd, 0x3e, 0x50, 0x1d, 0x79, 0x3f, 0x0f, 0x55, 0x37, 0x45, 0x54 };
+ var iv = new byte[] { 0xe6, 0x65, 0x36, 0x0d, 0xdd, 0xd7, 0x50, 0xc3, 0x48, 0xdb, 0x48, 0x07, 0xa1, 0x30, 0xd2, 0x38 };
+ var expected = new byte[] { 0xca, 0xfb, 0x1c, 0x49, 0xbf, 0x82, 0x2a, 0xbb, 0x1c, 0x52, 0xc7, 0x86, 0x22, 0x8a, 0xe5, 0xa4, 0xf3, 0xda, 0x4e, 0x1c, 0x3a, 0x87, 0x41, 0x1c, 0xd2, 0x6e, 0x76, 0xdc, 0xc2, 0xe9, 0xc2, 0x0e, 0xf5, 0xc7, 0xbd, 0x12, 0x85, 0xfa, 0x0e, 0xda, 0xee, 0x50, 0xd7, 0xfd, 0x81, 0x34, 0x25, 0x6d };
+ var testCipher = new AesCipher(key, new CtrCipherMode(iv), null);
+
+ var actual = testCipher.Encrypt(input);
+
+ Assert.IsTrue(actual.IsEqualTo(expected));
+ }
+
+ [TestMethod]
+ public void Decrypt_AES_128_CTR()
+ {
+ var input = new byte[] { 0x00, 0x00, 0x00, 0x2c, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0xb0, 0x74, 0x21, 0x87, 0x16, 0xb9, 0x69, 0x48, 0x33, 0xce, 0xb3, 0xe7, 0xdc, 0x3f, 0x50, 0xdc, 0xcc, 0xd5, 0x27, 0xb7, 0xfe, 0x7a, 0x78, 0x22, 0xae, 0xc8 };
+ var key = new byte[] { 0x17, 0x78, 0x56, 0xe1, 0x3e, 0xbd, 0x3e, 0x50, 0x1d, 0x79, 0x3f, 0x0f, 0x55, 0x37, 0x45, 0x54 };
+ var iv = new byte[] { 0xe6, 0x65, 0x36, 0x0d, 0xdd, 0xd7, 0x50, 0xc3, 0x48, 0xdb, 0x48, 0x07, 0xa1, 0x30, 0xd2, 0x38 };
+ var output = new byte[] { 0xca, 0xfb, 0x1c, 0x49, 0xbf, 0x82, 0x2a, 0xbb, 0x1c, 0x52, 0xc7, 0x86, 0x22, 0x8a, 0xe5, 0xa4, 0xf3, 0xda, 0x4e, 0x1c, 0x3a, 0x87, 0x41, 0x1c, 0xd2, 0x6e, 0x76, 0xdc, 0xc2, 0xe9, 0xc2, 0x0e, 0xf5, 0xc7, 0xbd, 0x12, 0x85, 0xfa, 0x0e, 0xda, 0xee, 0x50, 0xd7, 0xfd, 0x81, 0x34, 0x25, 0x6d };
+ var testCipher = new AesCipher(key, new CtrCipherMode(iv), null);
+
+ var actual = testCipher.Decrypt(output);
+
+ Assert.IsTrue(input.IsEqualTo(actual));
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("Cipher")]
+ [TestCategory("integration")]
+ public void Test_Cipher_AEes128CBC_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.Encryptions.Clear();
+ connectionInfo.Encryptions.Add("aes128-cbc", new CipherInfo(128, (key, iv) => { return new AesCipher(key, new CbcCipherMode(iv), null); }));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("Cipher")]
+ [TestCategory("integration")]
+ public void Test_Cipher_Aes192CBC_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.Encryptions.Clear();
+ connectionInfo.Encryptions.Add("aes192-cbc", new CipherInfo(192, (key, iv) => { return new AesCipher(key, new CbcCipherMode(iv), null); }));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("Cipher")]
+ [TestCategory("integration")]
+ public void Test_Cipher_Aes256CBC_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.Encryptions.Clear();
+ connectionInfo.Encryptions.Add("aes256-cbc", new CipherInfo(256, (key, iv) => { return new AesCipher(key, new CbcCipherMode(iv), null); }));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("Cipher")]
+ [TestCategory("integration")]
+ public void Test_Cipher_Aes128CTR_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.Encryptions.Clear();
+ connectionInfo.Encryptions.Add("aes128-ctr", new CipherInfo(128, (key, iv) => { return new AesCipher(key, new CtrCipherMode(iv), null); }));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("Cipher")]
+ [TestCategory("integration")]
+ public void Test_Cipher_Aes192CTR_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.Encryptions.Clear();
+ connectionInfo.Encryptions.Add("aes192-ctr", new CipherInfo(192, (key, iv) => { return new AesCipher(key, new CtrCipherMode(iv), null); }));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("Cipher")]
+ [TestCategory("integration")]
+ public void Test_Cipher_Aes256CTR_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.Encryptions.Clear();
+ connectionInfo.Encryptions.Add("aes256-ctr", new CipherInfo(256, (key, iv) => { return new AesCipher(key, new CtrCipherMode(iv), null); }));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("Cipher")]
+ [TestCategory("integration")]
+ public void Test_Cipher_Arcfour_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.Encryptions.Clear();
+ connectionInfo.Encryptions.Add("arcfour", new CipherInfo(128, (key, iv) => { return new Arc4Cipher(key, false); }));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ AesCipher target = new AesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for AesCipher Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void AesCipherConstructorTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ AesCipher target = new AesCipher(key, mode, padding);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ AesCipher target = new AesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Arc4CipherTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Arc4CipherTest.cs
index addbfbf5..1bdcf837 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Arc4CipherTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Arc4CipherTest.cs
@@ -1,177 +1,177 @@
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Renci.SshNet.Tests.Common;
-using Renci.SshNet.Tests.Properties;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
-{
- ///
- /// Implements ARCH4 cipher algorithm
- ///
- [TestClass]
- public class Arc4CipherTest : TestBase
- {
- ///
- ///A test for Arc4Cipher Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void Arc4CipherConstructorTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- Arc4Cipher target = new Arc4Cipher(key, true);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- [TestMethod]
- public void Decrypt_DischargeFirstBytes_False1()
- {
- const string key = "Key";
- const string expectedPlainText = "Plaintext";
- var encoding = Encoding.ASCII;
- var cipher = new Arc4Cipher(encoding.GetBytes(key), false);
- var cipherText = new byte[] { 0xBB, 0xF3, 0x16, 0xE8, 0xD9, 0x40, 0xAF, 0x0A, 0xD3 };
-
- var actualPlainText = cipher.Decrypt(cipherText);
-
- Assert.AreEqual(expectedPlainText, encoding.GetString(actualPlainText));
- }
-
- [TestMethod]
- public void Decrypt_DischargeFirstBytes_False2()
- {
- const string key = "Wiki";
- const string expectedPlainText = "pedia";
- var encoding = Encoding.ASCII;
- var cipher = new Arc4Cipher(encoding.GetBytes(key), false);
- var cipherText = new byte[] { 0x10, 0X21, 0xBF, 0x04, 0x20 };
-
- var actualPlainText = cipher.Decrypt(cipherText);
-
- Assert.AreEqual(expectedPlainText, encoding.GetString(actualPlainText));
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- Arc4Cipher target = new Arc4Cipher(key, true); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- [TestMethod]
- public void Encrypt_DischargeFirstBytes_False1()
- {
- const string key = "Key";
- const string plainText = "Plaintext";
- var encoding = Encoding.ASCII;
- var cipher = new Arc4Cipher(encoding.GetBytes(key), false);
- var expectedCipherText = new byte[] { 0xBB, 0xF3, 0x16, 0xE8, 0xD9, 0x40, 0xAF, 0x0A, 0xD3 };
-
- var actualCipherText = cipher.Encrypt(encoding.GetBytes(plainText));
-
- Assert.IsNotNull(actualCipherText);
- Assert.AreEqual(expectedCipherText.Length, actualCipherText.Length);
- Assert.AreEqual(expectedCipherText[0], actualCipherText[0]);
- Assert.AreEqual(expectedCipherText[1], actualCipherText[1]);
- Assert.AreEqual(expectedCipherText[2], actualCipherText[2]);
- Assert.AreEqual(expectedCipherText[3], actualCipherText[3]);
- Assert.AreEqual(expectedCipherText[4], actualCipherText[4]);
- Assert.AreEqual(expectedCipherText[5], actualCipherText[5]);
- Assert.AreEqual(expectedCipherText[6], actualCipherText[6]);
- Assert.AreEqual(expectedCipherText[7], actualCipherText[7]);
- Assert.AreEqual(expectedCipherText[8], actualCipherText[8]);
- }
-
- [TestMethod]
- public void Encrypt_DischargeFirstBytes_False2()
- {
- const string key = "Wiki";
- const string plainText = "pedia";
- var encoding = Encoding.ASCII;
- var cipher = new Arc4Cipher(encoding.GetBytes(key), false);
- var expectedCipherText = new byte[] { 0x10, 0X21, 0xBF, 0x04, 0x20 };
-
- var actualCipherText = cipher.Encrypt(encoding.GetBytes(plainText));
-
- Assert.IsNotNull(actualCipherText);
- Assert.AreEqual(expectedCipherText.Length, actualCipherText.Length);
- Assert.AreEqual(expectedCipherText[0], actualCipherText[0]);
- Assert.AreEqual(expectedCipherText[1], actualCipherText[1]);
- Assert.AreEqual(expectedCipherText[2], actualCipherText[2]);
- Assert.AreEqual(expectedCipherText[3], actualCipherText[3]);
- Assert.AreEqual(expectedCipherText[4], actualCipherText[4]);
- }
-
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- Arc4Cipher target = new Arc4Cipher(key, true); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("Cipher")]
- [TestCategory("integration")]
- public void Test_Cipher_Arcfour128_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.Encryptions.Clear();
- connectionInfo.Encryptions.Add("arcfour128", new CipherInfo(128, (key, iv) => { return new Arc4Cipher(key, true); }));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("Cipher")]
- [TestCategory("integration")]
- public void Test_Cipher_Arcfour256_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.Encryptions.Clear();
- connectionInfo.Encryptions.Add("arcfour256", new CipherInfo(256, (key, iv) => { return new Arc4Cipher(key, true); }));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- }
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Security.Cryptography.Ciphers;
+using Renci.SshNet.Tests.Common;
+using Renci.SshNet.Tests.Properties;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
+{
+ ///
+ /// Implements ARCH4 cipher algorithm
+ ///
+ [TestClass]
+ public class Arc4CipherTest : TestBase
+ {
+ ///
+ ///A test for Arc4Cipher Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void Arc4CipherConstructorTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ Arc4Cipher target = new Arc4Cipher(key, true);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ [TestMethod]
+ public void Decrypt_DischargeFirstBytes_False1()
+ {
+ const string key = "Key";
+ const string expectedPlainText = "Plaintext";
+ var encoding = Encoding.ASCII;
+ var cipher = new Arc4Cipher(encoding.GetBytes(key), false);
+ var cipherText = new byte[] { 0xBB, 0xF3, 0x16, 0xE8, 0xD9, 0x40, 0xAF, 0x0A, 0xD3 };
+
+ var actualPlainText = cipher.Decrypt(cipherText);
+
+ Assert.AreEqual(expectedPlainText, encoding.GetString(actualPlainText));
+ }
+
+ [TestMethod]
+ public void Decrypt_DischargeFirstBytes_False2()
+ {
+ const string key = "Wiki";
+ const string expectedPlainText = "pedia";
+ var encoding = Encoding.ASCII;
+ var cipher = new Arc4Cipher(encoding.GetBytes(key), false);
+ var cipherText = new byte[] { 0x10, 0X21, 0xBF, 0x04, 0x20 };
+
+ var actualPlainText = cipher.Decrypt(cipherText);
+
+ Assert.AreEqual(expectedPlainText, encoding.GetString(actualPlainText));
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ Arc4Cipher target = new Arc4Cipher(key, true); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ [TestMethod]
+ public void Encrypt_DischargeFirstBytes_False1()
+ {
+ const string key = "Key";
+ const string plainText = "Plaintext";
+ var encoding = Encoding.ASCII;
+ var cipher = new Arc4Cipher(encoding.GetBytes(key), false);
+ var expectedCipherText = new byte[] { 0xBB, 0xF3, 0x16, 0xE8, 0xD9, 0x40, 0xAF, 0x0A, 0xD3 };
+
+ var actualCipherText = cipher.Encrypt(encoding.GetBytes(plainText));
+
+ Assert.IsNotNull(actualCipherText);
+ Assert.AreEqual(expectedCipherText.Length, actualCipherText.Length);
+ Assert.AreEqual(expectedCipherText[0], actualCipherText[0]);
+ Assert.AreEqual(expectedCipherText[1], actualCipherText[1]);
+ Assert.AreEqual(expectedCipherText[2], actualCipherText[2]);
+ Assert.AreEqual(expectedCipherText[3], actualCipherText[3]);
+ Assert.AreEqual(expectedCipherText[4], actualCipherText[4]);
+ Assert.AreEqual(expectedCipherText[5], actualCipherText[5]);
+ Assert.AreEqual(expectedCipherText[6], actualCipherText[6]);
+ Assert.AreEqual(expectedCipherText[7], actualCipherText[7]);
+ Assert.AreEqual(expectedCipherText[8], actualCipherText[8]);
+ }
+
+ [TestMethod]
+ public void Encrypt_DischargeFirstBytes_False2()
+ {
+ const string key = "Wiki";
+ const string plainText = "pedia";
+ var encoding = Encoding.ASCII;
+ var cipher = new Arc4Cipher(encoding.GetBytes(key), false);
+ var expectedCipherText = new byte[] { 0x10, 0X21, 0xBF, 0x04, 0x20 };
+
+ var actualCipherText = cipher.Encrypt(encoding.GetBytes(plainText));
+
+ Assert.IsNotNull(actualCipherText);
+ Assert.AreEqual(expectedCipherText.Length, actualCipherText.Length);
+ Assert.AreEqual(expectedCipherText[0], actualCipherText[0]);
+ Assert.AreEqual(expectedCipherText[1], actualCipherText[1]);
+ Assert.AreEqual(expectedCipherText[2], actualCipherText[2]);
+ Assert.AreEqual(expectedCipherText[3], actualCipherText[3]);
+ Assert.AreEqual(expectedCipherText[4], actualCipherText[4]);
+ }
+
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ Arc4Cipher target = new Arc4Cipher(key, true); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("Cipher")]
+ [TestCategory("integration")]
+ public void Test_Cipher_Arcfour128_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.Encryptions.Clear();
+ connectionInfo.Encryptions.Add("arcfour128", new CipherInfo(128, (key, iv) => { return new Arc4Cipher(key, true); }));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("Cipher")]
+ [TestCategory("integration")]
+ public void Test_Cipher_Arcfour256_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.Encryptions.Clear();
+ connectionInfo.Encryptions.Add("arcfour256", new CipherInfo(256, (key, iv) => { return new Arc4Cipher(key, true); }));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/BlowfishCipherTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/BlowfishCipherTest.cs
index 780a697b..1fd7b7d1 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/BlowfishCipherTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/BlowfishCipherTest.cs
@@ -1,108 +1,108 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
-using Renci.SshNet.Tests.Common;
-using Renci.SshNet.Tests.Properties;
-using System.Linq;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
-{
- ///
- ///
- ///
- [TestClass]
- public class BlowfishCipherTest : TestBase
- {
- [TestMethod]
- public void Test_Cipher_Blowfish_128_CBC()
- {
- var input = new byte[] { 0x00, 0x00, 0x00, 0x2c, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0x30, 0x9e, 0xe0, 0x9c, 0x12, 0xee, 0x3a, 0x30, 0x03, 0x52, 0x1c, 0x1a, 0xe7, 0x3e, 0x0b, 0x9a, 0xcf, 0x9a, 0x57, 0x42, 0x0b, 0x4f, 0x4a, 0x15, 0xa0, 0xf5 };
- var key = new byte[] { 0xe4, 0x94, 0xf9, 0xb1, 0x00, 0x4f, 0x16, 0x2a, 0x80, 0x11, 0xea, 0x73, 0x0d, 0xb9, 0xbf, 0x64 };
- var iv = new byte[] { 0x74, 0x8b, 0x4f, 0xe6, 0xc1, 0x29, 0xb3, 0x54, 0xec, 0x77, 0x92, 0xf3, 0x15, 0xa0, 0x41, 0xa8 };
- var output = new byte[] { 0x50, 0x49, 0xe0, 0xce, 0x98, 0x93, 0x8b, 0xec, 0x82, 0x7d, 0x14, 0x1b, 0x3e, 0xdc, 0xca, 0x63, 0xef, 0x36, 0x20, 0x67, 0x58, 0x63, 0x1f, 0x9c, 0xd2, 0x12, 0x6b, 0xca, 0xea, 0xd0, 0x78, 0x8b, 0x61, 0x50, 0x4f, 0xc4, 0x5b, 0x32, 0x91, 0xd6, 0x65, 0xcb, 0x74, 0xe5, 0x6e, 0xf5, 0xde, 0x14 };
- var testCipher = new Renci.SshNet.Security.Cryptography.Ciphers.BlowfishCipher(key, new Renci.SshNet.Security.Cryptography.Ciphers.Modes.CbcCipherMode(iv), null);
- var r = testCipher.Encrypt(input);
-
- if (!r.SequenceEqual(output))
- Assert.Fail("Invalid encryption");
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("Cipher")]
- [TestCategory("integration")]
- public void Test_Cipher_BlowfishCBC_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.Encryptions.Clear();
- connectionInfo.Encryptions.Add("blowfish-cbc", new CipherInfo(128, (key, iv) => { return new BlowfishCipher(key, new CbcCipherMode(iv), null); }));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- ///
- ///A test for BlowfishCipher Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void BlowfishCipherConstructorTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- BlowfishCipher target = new BlowfishCipher(key, mode, padding);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- BlowfishCipher target = new BlowfishCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- BlowfishCipher target = new BlowfishCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers;
+using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
+using Renci.SshNet.Tests.Common;
+using Renci.SshNet.Tests.Properties;
+using System.Linq;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
+{
+ ///
+ ///
+ ///
+ [TestClass]
+ public class BlowfishCipherTest : TestBase
+ {
+ [TestMethod]
+ public void Test_Cipher_Blowfish_128_CBC()
+ {
+ var input = new byte[] { 0x00, 0x00, 0x00, 0x2c, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0x30, 0x9e, 0xe0, 0x9c, 0x12, 0xee, 0x3a, 0x30, 0x03, 0x52, 0x1c, 0x1a, 0xe7, 0x3e, 0x0b, 0x9a, 0xcf, 0x9a, 0x57, 0x42, 0x0b, 0x4f, 0x4a, 0x15, 0xa0, 0xf5 };
+ var key = new byte[] { 0xe4, 0x94, 0xf9, 0xb1, 0x00, 0x4f, 0x16, 0x2a, 0x80, 0x11, 0xea, 0x73, 0x0d, 0xb9, 0xbf, 0x64 };
+ var iv = new byte[] { 0x74, 0x8b, 0x4f, 0xe6, 0xc1, 0x29, 0xb3, 0x54, 0xec, 0x77, 0x92, 0xf3, 0x15, 0xa0, 0x41, 0xa8 };
+ var output = new byte[] { 0x50, 0x49, 0xe0, 0xce, 0x98, 0x93, 0x8b, 0xec, 0x82, 0x7d, 0x14, 0x1b, 0x3e, 0xdc, 0xca, 0x63, 0xef, 0x36, 0x20, 0x67, 0x58, 0x63, 0x1f, 0x9c, 0xd2, 0x12, 0x6b, 0xca, 0xea, 0xd0, 0x78, 0x8b, 0x61, 0x50, 0x4f, 0xc4, 0x5b, 0x32, 0x91, 0xd6, 0x65, 0xcb, 0x74, 0xe5, 0x6e, 0xf5, 0xde, 0x14 };
+ var testCipher = new Renci.SshNet.Security.Cryptography.Ciphers.BlowfishCipher(key, new Renci.SshNet.Security.Cryptography.Ciphers.Modes.CbcCipherMode(iv), null);
+ var r = testCipher.Encrypt(input);
+
+ if (!r.SequenceEqual(output))
+ Assert.Fail("Invalid encryption");
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("Cipher")]
+ [TestCategory("integration")]
+ public void Test_Cipher_BlowfishCBC_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.Encryptions.Clear();
+ connectionInfo.Encryptions.Add("blowfish-cbc", new CipherInfo(128, (key, iv) => { return new BlowfishCipher(key, new CbcCipherMode(iv), null); }));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ ///
+ ///A test for BlowfishCipher Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void BlowfishCipherConstructorTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ BlowfishCipher target = new BlowfishCipher(key, mode, padding);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ BlowfishCipher target = new BlowfishCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ BlowfishCipher target = new BlowfishCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CastCipherTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CastCipherTest.cs
index f0cc6313..d65d9673 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CastCipherTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CastCipherTest.cs
@@ -1,106 +1,106 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
-using Renci.SshNet.Tests.Common;
-using Renci.SshNet.Tests.Properties;
-using System.Linq;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
-{
- ///
- /// Implements CAST cipher algorithm
- ///
- [TestClass]
- public class CastCipherTest : TestBase
- {
- [TestMethod]
- public void Test_Cipher_CastCipher_128_CBC()
- {
- var input = new byte[] { 0x00, 0x00, 0x00, 0x2c, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0x30, 0x9e, 0xe0, 0x9c, 0x12, 0xee, 0x3a, 0x30, 0x03, 0x52, 0x1c, 0x1a, 0xe7, 0x3e, 0x0b, 0x9a, 0xcf, 0x9a, 0x57, 0x42, 0x0b, 0x4f, 0x4a, 0x15, 0xa0, 0xf5 };
- var key = new byte[] { 0xe4, 0x94, 0xf9, 0xb1, 0x00, 0x4f, 0x16, 0x2a, 0x80, 0x11, 0xea, 0x73, 0x0d, 0xb9, 0xbf, 0x64 };
- var iv = new byte[] { 0x74, 0x8b, 0x4f, 0xe6, 0xc1, 0x29, 0xb3, 0x54, 0xec, 0x77, 0x92, 0xf3, 0x15, 0xa0, 0x41, 0xa8 };
- var output = new byte[] { 0x32, 0xef, 0xbd, 0xac, 0xb6, 0xfd, 0x1f, 0xae, 0x1b, 0x13, 0x5f, 0x31, 0x6d, 0x38, 0xcd, 0xb0, 0xe3, 0xca, 0xe1, 0xbc, 0xf8, 0xa7, 0xc2, 0x31, 0x62, 0x14, 0x3a, 0x9a, 0xda, 0xe3, 0xf8, 0xc8, 0x70, 0x87, 0x53, 0x21, 0x5d, 0xb7, 0x94, 0xb7, 0xe8, 0xc6, 0x9d, 0x46, 0x0c, 0x6d, 0x64, 0x6d };
- var testCipher = new Renci.SshNet.Security.Cryptography.Ciphers.CastCipher(key, new Renci.SshNet.Security.Cryptography.Ciphers.Modes.CbcCipherMode(iv), null);
- var r = testCipher.Encrypt(input);
-
- if (!r.SequenceEqual(output))
- Assert.Fail("Invalid encryption");
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("Cipher")]
- [TestCategory("integration")]
- public void Test_Cipher_Cast128CBC_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.Encryptions.Clear();
- connectionInfo.Encryptions.Add("cast128-cbc", new CipherInfo(128, (key, iv) => { return new CastCipher(key, new CbcCipherMode(iv), null); }));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
- ///
- ///A test for CastCipher Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void CastCipherConstructorTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- CastCipher target = new CastCipher(key, mode, padding);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- CastCipher target = new CastCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- CastCipher target = new CastCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers;
+using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
+using Renci.SshNet.Tests.Common;
+using Renci.SshNet.Tests.Properties;
+using System.Linq;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
+{
+ ///
+ /// Implements CAST cipher algorithm
+ ///
+ [TestClass]
+ public class CastCipherTest : TestBase
+ {
+ [TestMethod]
+ public void Test_Cipher_CastCipher_128_CBC()
+ {
+ var input = new byte[] { 0x00, 0x00, 0x00, 0x2c, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0x30, 0x9e, 0xe0, 0x9c, 0x12, 0xee, 0x3a, 0x30, 0x03, 0x52, 0x1c, 0x1a, 0xe7, 0x3e, 0x0b, 0x9a, 0xcf, 0x9a, 0x57, 0x42, 0x0b, 0x4f, 0x4a, 0x15, 0xa0, 0xf5 };
+ var key = new byte[] { 0xe4, 0x94, 0xf9, 0xb1, 0x00, 0x4f, 0x16, 0x2a, 0x80, 0x11, 0xea, 0x73, 0x0d, 0xb9, 0xbf, 0x64 };
+ var iv = new byte[] { 0x74, 0x8b, 0x4f, 0xe6, 0xc1, 0x29, 0xb3, 0x54, 0xec, 0x77, 0x92, 0xf3, 0x15, 0xa0, 0x41, 0xa8 };
+ var output = new byte[] { 0x32, 0xef, 0xbd, 0xac, 0xb6, 0xfd, 0x1f, 0xae, 0x1b, 0x13, 0x5f, 0x31, 0x6d, 0x38, 0xcd, 0xb0, 0xe3, 0xca, 0xe1, 0xbc, 0xf8, 0xa7, 0xc2, 0x31, 0x62, 0x14, 0x3a, 0x9a, 0xda, 0xe3, 0xf8, 0xc8, 0x70, 0x87, 0x53, 0x21, 0x5d, 0xb7, 0x94, 0xb7, 0xe8, 0xc6, 0x9d, 0x46, 0x0c, 0x6d, 0x64, 0x6d };
+ var testCipher = new Renci.SshNet.Security.Cryptography.Ciphers.CastCipher(key, new Renci.SshNet.Security.Cryptography.Ciphers.Modes.CbcCipherMode(iv), null);
+ var r = testCipher.Encrypt(input);
+
+ if (!r.SequenceEqual(output))
+ Assert.Fail("Invalid encryption");
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("Cipher")]
+ [TestCategory("integration")]
+ public void Test_Cipher_Cast128CBC_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.Encryptions.Clear();
+ connectionInfo.Encryptions.Add("cast128-cbc", new CipherInfo(128, (key, iv) => { return new CastCipher(key, new CbcCipherMode(iv), null); }));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+ ///
+ ///A test for CastCipher Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void CastCipherConstructorTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ CastCipher target = new CastCipher(key, mode, padding);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ CastCipher target = new CastCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ CastCipher target = new CastCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CipherModeTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CipherModeTest.cs
index 23a0ff0c..d3b4c0ad 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CipherModeTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CipherModeTest.cs
@@ -1,61 +1,61 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
-{
- ///
- ///This is a test class for CipherModeTest and is intended
- ///to contain all CipherModeTest Unit Tests
- ///
- [TestClass()]
- public class CipherModeTest : TestBase
- {
- internal virtual CipherMode CreateCipherMode()
- {
- // TODO: Instantiate an appropriate concrete class.
- CipherMode target = null;
- return target;
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- CipherMode target = CreateCipherMode(); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- CipherMode target = CreateCipherMode(); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
+{
+ ///
+ ///This is a test class for CipherModeTest and is intended
+ ///to contain all CipherModeTest Unit Tests
+ ///
+ [TestClass()]
+ public class CipherModeTest : TestBase
+ {
+ internal virtual CipherMode CreateCipherMode()
+ {
+ // TODO: Instantiate an appropriate concrete class.
+ CipherMode target = null;
+ return target;
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ CipherMode target = CreateCipherMode(); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ CipherMode target = CreateCipherMode(); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CipherPaddingTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CipherPaddingTest.cs
index de720376..c923584a 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CipherPaddingTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CipherPaddingTest.cs
@@ -1,38 +1,38 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
-{
- ///
- ///This is a test class for CipherPaddingTest and is intended
- ///to contain all CipherPaddingTest Unit Tests
- ///
- [TestClass()]
- public class CipherPaddingTest : TestBase
- {
- internal virtual CipherPadding CreateCipherPadding()
- {
- // TODO: Instantiate an appropriate concrete class.
- CipherPadding target = null;
- return target;
- }
-
- ///
- ///A test for Pad
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PadTest()
- {
- CipherPadding target = CreateCipherPadding(); // TODO: Initialize to an appropriate value
- int blockSize = 0; // TODO: Initialize to an appropriate value
- byte[] input = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Pad(blockSize, input);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
+{
+ ///
+ ///This is a test class for CipherPaddingTest and is intended
+ ///to contain all CipherPaddingTest Unit Tests
+ ///
+ [TestClass()]
+ public class CipherPaddingTest : TestBase
+ {
+ internal virtual CipherPadding CreateCipherPadding()
+ {
+ // TODO: Instantiate an appropriate concrete class.
+ CipherPadding target = null;
+ return target;
+ }
+
+ ///
+ ///A test for Pad
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PadTest()
+ {
+ CipherPadding target = CreateCipherPadding(); // TODO: Initialize to an appropriate value
+ int blockSize = 0; // TODO: Initialize to an appropriate value
+ byte[] input = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Pad(blockSize, input);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/DesCipherTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/DesCipherTest.cs
index 6511d3fc..cff5b9db 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/DesCipherTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/DesCipherTest.cs
@@ -1,73 +1,73 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
-{
- ///
- /// Implements DES cipher algorithm.
- ///
- [TestClass]
- public class DesCipherTest : TestBase
- {
- ///
- ///A test for DesCipher Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DesCipherConstructorTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- DesCipher target = new DesCipher(key, mode, padding);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- DesCipher target = new DesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- DesCipher target = new DesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
+{
+ ///
+ /// Implements DES cipher algorithm.
+ ///
+ [TestClass]
+ public class DesCipherTest : TestBase
+ {
+ ///
+ ///A test for DesCipher Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DesCipherConstructorTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ DesCipher target = new DesCipher(key, mode, padding);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ DesCipher target = new DesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ DesCipher target = new DesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CbcCipherModeTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CbcCipherModeTest.cs
index 230dce65..c43191c2 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CbcCipherModeTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CbcCipherModeTest.cs
@@ -1,67 +1,67 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Modes
-{
- ///
- ///This is a test class for CbcCipherModeTest and is intended
- ///to contain all CbcCipherModeTest Unit Tests
- ///
- [TestClass()]
- public class CbcCipherModeTest : TestBase
- {
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- byte[] iv = null; // TODO: Initialize to an appropriate value
- CbcCipherMode target = new CbcCipherMode(iv); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- byte[] iv = null; // TODO: Initialize to an appropriate value
- CbcCipherMode target = new CbcCipherMode(iv); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for CbcCipherMode Constructor
- ///
- [TestMethod()]
- public void CbcCipherModeConstructorTest()
- {
- byte[] iv = null; // TODO: Initialize to an appropriate value
- CbcCipherMode target = new CbcCipherMode(iv);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Modes
+{
+ ///
+ ///This is a test class for CbcCipherModeTest and is intended
+ ///to contain all CbcCipherModeTest Unit Tests
+ ///
+ [TestClass()]
+ public class CbcCipherModeTest : TestBase
+ {
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ byte[] iv = null; // TODO: Initialize to an appropriate value
+ CbcCipherMode target = new CbcCipherMode(iv); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ byte[] iv = null; // TODO: Initialize to an appropriate value
+ CbcCipherMode target = new CbcCipherMode(iv); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for CbcCipherMode Constructor
+ ///
+ [TestMethod()]
+ public void CbcCipherModeConstructorTest()
+ {
+ byte[] iv = null; // TODO: Initialize to an appropriate value
+ CbcCipherMode target = new CbcCipherMode(iv);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CfbCipherModeTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CfbCipherModeTest.cs
index 8a4a2b27..f7dd046d 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CfbCipherModeTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CfbCipherModeTest.cs
@@ -1,68 +1,68 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Modes
-{
- ///
- ///This is a test class for CfbCipherModeTest and is intended
- ///to contain all CfbCipherModeTest Unit Tests
- ///
- [TestClass()]
- public class CfbCipherModeTest : TestBase
- {
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- byte[] iv = null; // TODO: Initialize to an appropriate value
- CfbCipherMode target = new CfbCipherMode(iv); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- byte[] iv = null; // TODO: Initialize to an appropriate value
- CfbCipherMode target = new CfbCipherMode(iv); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for CfbCipherMode Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void CfbCipherModeConstructorTest()
- {
- byte[] iv = null; // TODO: Initialize to an appropriate value
- CfbCipherMode target = new CfbCipherMode(iv);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Modes
+{
+ ///
+ ///This is a test class for CfbCipherModeTest and is intended
+ ///to contain all CfbCipherModeTest Unit Tests
+ ///
+ [TestClass()]
+ public class CfbCipherModeTest : TestBase
+ {
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ byte[] iv = null; // TODO: Initialize to an appropriate value
+ CfbCipherMode target = new CfbCipherMode(iv); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ byte[] iv = null; // TODO: Initialize to an appropriate value
+ CfbCipherMode target = new CfbCipherMode(iv); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for CfbCipherMode Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void CfbCipherModeConstructorTest()
+ {
+ byte[] iv = null; // TODO: Initialize to an appropriate value
+ CfbCipherMode target = new CfbCipherMode(iv);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CtrCipherModeTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CtrCipherModeTest.cs
index 76e6bae9..23e0391e 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CtrCipherModeTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CtrCipherModeTest.cs
@@ -1,68 +1,68 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Modes
-{
- ///
- ///This is a test class for CtrCipherModeTest and is intended
- ///to contain all CtrCipherModeTest Unit Tests
- ///
- [TestClass()]
- public class CtrCipherModeTest : TestBase
- {
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- byte[] iv = null; // TODO: Initialize to an appropriate value
- CtrCipherMode target = new CtrCipherMode(iv); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- byte[] iv = null; // TODO: Initialize to an appropriate value
- CtrCipherMode target = new CtrCipherMode(iv); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for CtrCipherMode Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void CtrCipherModeConstructorTest()
- {
- byte[] iv = null; // TODO: Initialize to an appropriate value
- CtrCipherMode target = new CtrCipherMode(iv);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Modes
+{
+ ///
+ ///This is a test class for CtrCipherModeTest and is intended
+ ///to contain all CtrCipherModeTest Unit Tests
+ ///
+ [TestClass()]
+ public class CtrCipherModeTest : TestBase
+ {
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ byte[] iv = null; // TODO: Initialize to an appropriate value
+ CtrCipherMode target = new CtrCipherMode(iv); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ byte[] iv = null; // TODO: Initialize to an appropriate value
+ CtrCipherMode target = new CtrCipherMode(iv); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for CtrCipherMode Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void CtrCipherModeConstructorTest()
+ {
+ byte[] iv = null; // TODO: Initialize to an appropriate value
+ CtrCipherMode target = new CtrCipherMode(iv);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/OfbCipherModeTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/OfbCipherModeTest.cs
index 5444be0d..d4719e25 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/OfbCipherModeTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/OfbCipherModeTest.cs
@@ -1,68 +1,68 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Modes
-{
- ///
- ///This is a test class for OfbCipherModeTest and is intended
- ///to contain all OfbCipherModeTest Unit Tests
- ///
- [TestClass()]
- public class OfbCipherModeTest : TestBase
- {
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- byte[] iv = null; // TODO: Initialize to an appropriate value
- OfbCipherMode target = new OfbCipherMode(iv); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- byte[] iv = null; // TODO: Initialize to an appropriate value
- OfbCipherMode target = new OfbCipherMode(iv); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for OfbCipherMode Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void OfbCipherModeConstructorTest()
- {
- byte[] iv = null; // TODO: Initialize to an appropriate value
- OfbCipherMode target = new OfbCipherMode(iv);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Modes
+{
+ ///
+ ///This is a test class for OfbCipherModeTest and is intended
+ ///to contain all OfbCipherModeTest Unit Tests
+ ///
+ [TestClass()]
+ public class OfbCipherModeTest : TestBase
+ {
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ byte[] iv = null; // TODO: Initialize to an appropriate value
+ OfbCipherMode target = new OfbCipherMode(iv); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ byte[] iv = null; // TODO: Initialize to an appropriate value
+ OfbCipherMode target = new OfbCipherMode(iv); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for OfbCipherMode Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void OfbCipherModeConstructorTest()
+ {
+ byte[] iv = null; // TODO: Initialize to an appropriate value
+ OfbCipherMode target = new OfbCipherMode(iv);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Paddings/PKCS5PaddingTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Paddings/PKCS5PaddingTest.cs
index 205feb4e..554d4b6a 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Paddings/PKCS5PaddingTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Paddings/PKCS5PaddingTest.cs
@@ -1,41 +1,41 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers.Paddings;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Paddings
-{
- ///
- ///This is a test class for PKCS5PaddingTest and is intended
- ///to contain all PKCS5PaddingTest Unit Tests
- ///
- [TestClass()]
- public class PKCS5PaddingTest : TestBase
- {
- ///
- ///A test for Pad
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PadTest()
- {
- PKCS5Padding target = new PKCS5Padding(); // TODO: Initialize to an appropriate value
- int blockSize = 0; // TODO: Initialize to an appropriate value
- byte[] input = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Pad(blockSize, input);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for PKCS5Padding Constructor
- ///
- [TestMethod()]
- public void PKCS5PaddingConstructorTest()
- {
- PKCS5Padding target = new PKCS5Padding();
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers.Paddings;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Paddings
+{
+ ///
+ ///This is a test class for PKCS5PaddingTest and is intended
+ ///to contain all PKCS5PaddingTest Unit Tests
+ ///
+ [TestClass()]
+ public class PKCS5PaddingTest : TestBase
+ {
+ ///
+ ///A test for Pad
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PadTest()
+ {
+ PKCS5Padding target = new PKCS5Padding(); // TODO: Initialize to an appropriate value
+ int blockSize = 0; // TODO: Initialize to an appropriate value
+ byte[] input = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Pad(blockSize, input);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for PKCS5Padding Constructor
+ ///
+ [TestMethod()]
+ public void PKCS5PaddingConstructorTest()
+ {
+ PKCS5Padding target = new PKCS5Padding();
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Paddings/PKCS7PaddingTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Paddings/PKCS7PaddingTest.cs
index e20be109..e39ec7a7 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Paddings/PKCS7PaddingTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Paddings/PKCS7PaddingTest.cs
@@ -1,41 +1,41 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers.Paddings;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Paddings
-{
- ///
- ///This is a test class for PKCS7PaddingTest and is intended
- ///to contain all PKCS7PaddingTest Unit Tests
- ///
- [TestClass()]
- public class PKCS7PaddingTest : TestBase
- {
- ///
- ///A test for Pad
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PadTest()
- {
- PKCS7Padding target = new PKCS7Padding(); // TODO: Initialize to an appropriate value
- int blockSize = 0; // TODO: Initialize to an appropriate value
- byte[] input = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Pad(blockSize, input);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for PKCS7Padding Constructor
- ///
- [TestMethod()]
- public void PKCS7PaddingConstructorTest()
- {
- PKCS7Padding target = new PKCS7Padding();
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers.Paddings;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Paddings
+{
+ ///
+ ///This is a test class for PKCS7PaddingTest and is intended
+ ///to contain all PKCS7PaddingTest Unit Tests
+ ///
+ [TestClass()]
+ public class PKCS7PaddingTest : TestBase
+ {
+ ///
+ ///A test for Pad
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PadTest()
+ {
+ PKCS7Padding target = new PKCS7Padding(); // TODO: Initialize to an appropriate value
+ int blockSize = 0; // TODO: Initialize to an appropriate value
+ byte[] input = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Pad(blockSize, input);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for PKCS7Padding Constructor
+ ///
+ [TestMethod()]
+ public void PKCS7PaddingConstructorTest()
+ {
+ PKCS7Padding target = new PKCS7Padding();
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/RsaCipherTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/RsaCipherTest.cs
index 423288b2..2de87cdd 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/RsaCipherTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/RsaCipherTest.cs
@@ -1,60 +1,60 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security;
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
-{
- ///
- /// Implements RSA cipher algorithm.
- ///
- [TestClass]
- public class RsaCipherTest : TestBase
- {
- ///
- ///A test for RsaCipher Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void RsaCipherConstructorTest()
- {
- RsaKey key = null; // TODO: Initialize to an appropriate value
- RsaCipher target = new RsaCipher(key);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for Decrypt
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptTest()
- {
- RsaKey key = null; // TODO: Initialize to an appropriate value
- RsaCipher target = new RsaCipher(key); // TODO: Initialize to an appropriate value
- byte[] data = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Decrypt(data);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Encrypt
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptTest()
- {
- RsaKey key = null; // TODO: Initialize to an appropriate value
- RsaCipher target = new RsaCipher(key); // TODO: Initialize to an appropriate value
- byte[] data = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Encrypt(data);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security;
+using Renci.SshNet.Security.Cryptography.Ciphers;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
+{
+ ///
+ /// Implements RSA cipher algorithm.
+ ///
+ [TestClass]
+ public class RsaCipherTest : TestBase
+ {
+ ///
+ ///A test for RsaCipher Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void RsaCipherConstructorTest()
+ {
+ RsaKey key = null; // TODO: Initialize to an appropriate value
+ RsaCipher target = new RsaCipher(key);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for Decrypt
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptTest()
+ {
+ RsaKey key = null; // TODO: Initialize to an appropriate value
+ RsaCipher target = new RsaCipher(key); // TODO: Initialize to an appropriate value
+ byte[] data = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Decrypt(data);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Encrypt
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptTest()
+ {
+ RsaKey key = null; // TODO: Initialize to an appropriate value
+ RsaCipher target = new RsaCipher(key); // TODO: Initialize to an appropriate value
+ byte[] data = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Encrypt(data);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/SerpentCipherTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/SerpentCipherTest.cs
index ac79b452..f604f5dc 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/SerpentCipherTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/SerpentCipherTest.cs
@@ -1,73 +1,73 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
-{
- ///
- /// Implements Serpent cipher algorithm.
- ///
- [TestClass]
- public class SerpentCipherTest : TestBase
- {
- ///
- ///A test for SerpentCipher Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void SerpentCipherConstructorTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- SerpentCipher target = new SerpentCipher(key, mode, padding);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- SerpentCipher target = new SerpentCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- SerpentCipher target = new SerpentCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
+{
+ ///
+ /// Implements Serpent cipher algorithm.
+ ///
+ [TestClass]
+ public class SerpentCipherTest : TestBase
+ {
+ ///
+ ///A test for SerpentCipher Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void SerpentCipherConstructorTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ SerpentCipher target = new SerpentCipher(key, mode, padding);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ SerpentCipher target = new SerpentCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ SerpentCipher target = new SerpentCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/TripleDesCipherTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/TripleDesCipherTest.cs
index 9ba70c14..3a410514 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/TripleDesCipherTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/TripleDesCipherTest.cs
@@ -1,106 +1,106 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
-using Renci.SshNet.Tests.Common;
-using Renci.SshNet.Tests.Properties;
-using System.Linq;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
-{
- ///
- /// Implements 3DES cipher algorithm.
- ///
- [TestClass]
- public class TripleDesCipherTest : TestBase
- {
- [TestMethod]
- public void Test_Cipher_3DES_CBC()
- {
- var input = new byte[] { 0x00, 0x00, 0x00, 0x1c, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0x72, 0x4e, 0x06, 0x08, 0x28, 0x2d, 0xaa, 0xe2, 0xb3, 0xd9 };
- var key = new byte[] { 0x78, 0xf6, 0xc6, 0xbb, 0x57, 0x03, 0x69, 0xca, 0xba, 0x31, 0x18, 0x2f, 0x2f, 0x4c, 0x35, 0x34, 0x64, 0x06, 0x85, 0x30, 0xbe, 0x78, 0x60, 0xb3 };
- var iv = new byte[] { 0xc0, 0x75, 0xf2, 0x26, 0x0a, 0x2a, 0x42, 0x96 };
- var output = new byte[] { 0x28, 0x77, 0x2f, 0x07, 0x3e, 0xc2, 0x27, 0xa6, 0xdb, 0x36, 0x4d, 0xc6, 0x7a, 0x26, 0x7a, 0x38, 0xe6, 0x54, 0x0b, 0xab, 0x07, 0x87, 0xf0, 0xa4, 0x73, 0x1f, 0xde, 0xe6, 0x81, 0x1d, 0x4b, 0x4b };
- var testCipher = new Renci.SshNet.Security.Cryptography.Ciphers.TripleDesCipher(key, new Renci.SshNet.Security.Cryptography.Ciphers.Modes.CbcCipherMode(iv), null);
- var r = testCipher.Encrypt(input);
-
- if (!r.SequenceEqual(output))
- Assert.Fail("Invalid encryption");
- }
-
- [TestMethod]
- [Owner("olegkap")]
- [TestCategory("Cipher")]
- [TestCategory("integration")]
- public void Test_Cipher_TripleDESCBC_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.Encryptions.Clear();
- connectionInfo.Encryptions.Add("3des-cbc", new CipherInfo(192, (key, iv) => { return new TripleDesCipher(key, new CbcCipherMode(iv), null); }));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
- ///
- ///A test for TripleDesCipher Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void TripleDesCipherConstructorTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- TripleDesCipher target = new TripleDesCipher(key, mode, padding);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- TripleDesCipher target = new TripleDesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- TripleDesCipher target = new TripleDesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers;
+using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
+using Renci.SshNet.Tests.Common;
+using Renci.SshNet.Tests.Properties;
+using System.Linq;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
+{
+ ///
+ /// Implements 3DES cipher algorithm.
+ ///
+ [TestClass]
+ public class TripleDesCipherTest : TestBase
+ {
+ [TestMethod]
+ public void Test_Cipher_3DES_CBC()
+ {
+ var input = new byte[] { 0x00, 0x00, 0x00, 0x1c, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0x72, 0x4e, 0x06, 0x08, 0x28, 0x2d, 0xaa, 0xe2, 0xb3, 0xd9 };
+ var key = new byte[] { 0x78, 0xf6, 0xc6, 0xbb, 0x57, 0x03, 0x69, 0xca, 0xba, 0x31, 0x18, 0x2f, 0x2f, 0x4c, 0x35, 0x34, 0x64, 0x06, 0x85, 0x30, 0xbe, 0x78, 0x60, 0xb3 };
+ var iv = new byte[] { 0xc0, 0x75, 0xf2, 0x26, 0x0a, 0x2a, 0x42, 0x96 };
+ var output = new byte[] { 0x28, 0x77, 0x2f, 0x07, 0x3e, 0xc2, 0x27, 0xa6, 0xdb, 0x36, 0x4d, 0xc6, 0x7a, 0x26, 0x7a, 0x38, 0xe6, 0x54, 0x0b, 0xab, 0x07, 0x87, 0xf0, 0xa4, 0x73, 0x1f, 0xde, 0xe6, 0x81, 0x1d, 0x4b, 0x4b };
+ var testCipher = new Renci.SshNet.Security.Cryptography.Ciphers.TripleDesCipher(key, new Renci.SshNet.Security.Cryptography.Ciphers.Modes.CbcCipherMode(iv), null);
+ var r = testCipher.Encrypt(input);
+
+ if (!r.SequenceEqual(output))
+ Assert.Fail("Invalid encryption");
+ }
+
+ [TestMethod]
+ [Owner("olegkap")]
+ [TestCategory("Cipher")]
+ [TestCategory("integration")]
+ public void Test_Cipher_TripleDESCBC_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.Encryptions.Clear();
+ connectionInfo.Encryptions.Add("3des-cbc", new CipherInfo(192, (key, iv) => { return new TripleDesCipher(key, new CbcCipherMode(iv), null); }));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+ ///
+ ///A test for TripleDesCipher Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void TripleDesCipherConstructorTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ TripleDesCipher target = new TripleDesCipher(key, mode, padding);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ TripleDesCipher target = new TripleDesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ TripleDesCipher target = new TripleDesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/TwofishCipherTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/TwofishCipherTest.cs
index abb2b35d..e0693e97 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/TwofishCipherTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/TwofishCipherTest.cs
@@ -1,73 +1,73 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
-{
- ///
- /// Implements Twofish cipher algorithm
- ///
- [TestClass]
- public class TwofishCipherTest : TestBase
- {
- ///
- ///A test for TwofishCipher Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void TwofishCipherConstructorTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- TwofishCipher target = new TwofishCipher(key, mode, padding);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- TwofishCipher target = new TwofishCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- byte[] key = null; // TODO: Initialize to an appropriate value
- CipherMode mode = null; // TODO: Initialize to an appropriate value
- CipherPadding padding = null; // TODO: Initialize to an appropriate value
- TwofishCipher target = new TwofishCipher(key, mode, padding); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
+{
+ ///
+ /// Implements Twofish cipher algorithm
+ ///
+ [TestClass]
+ public class TwofishCipherTest : TestBase
+ {
+ ///
+ ///A test for TwofishCipher Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void TwofishCipherConstructorTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ TwofishCipher target = new TwofishCipher(key, mode, padding);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ TwofishCipher target = new TwofishCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ byte[] key = null; // TODO: Initialize to an appropriate value
+ CipherMode mode = null; // TODO: Initialize to an appropriate value
+ CipherPadding padding = null; // TODO: Initialize to an appropriate value
+ TwofishCipher target = new TwofishCipher(key, mode, padding); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/DigitalSignatureTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/DigitalSignatureTest.cs
index a8733300..efe45c9c 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/DigitalSignatureTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/DigitalSignatureTest.cs
@@ -1,54 +1,54 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography
-{
- ///
- ///This is a test class for DigitalSignatureTest and is intended
- ///to contain all DigitalSignatureTest Unit Tests
- ///
- [TestClass()]
- public class DigitalSignatureTest : TestBase
- {
- internal virtual DigitalSignature CreateDigitalSignature()
- {
- // TODO: Instantiate an appropriate concrete class.
- DigitalSignature target = null;
- return target;
- }
-
- ///
- ///A test for Sign
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void SignTest()
- {
- DigitalSignature target = CreateDigitalSignature(); // TODO: Initialize to an appropriate value
- byte[] input = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Sign(input);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Verify
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void VerifyTest()
- {
- DigitalSignature target = CreateDigitalSignature(); // TODO: Initialize to an appropriate value
- byte[] input = null; // TODO: Initialize to an appropriate value
- byte[] signature = null; // TODO: Initialize to an appropriate value
- bool expected = false; // TODO: Initialize to an appropriate value
- bool actual;
- actual = target.Verify(input, signature);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography
+{
+ ///
+ ///This is a test class for DigitalSignatureTest and is intended
+ ///to contain all DigitalSignatureTest Unit Tests
+ ///
+ [TestClass()]
+ public class DigitalSignatureTest : TestBase
+ {
+ internal virtual DigitalSignature CreateDigitalSignature()
+ {
+ // TODO: Instantiate an appropriate concrete class.
+ DigitalSignature target = null;
+ return target;
+ }
+
+ ///
+ ///A test for Sign
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void SignTest()
+ {
+ DigitalSignature target = CreateDigitalSignature(); // TODO: Initialize to an appropriate value
+ byte[] input = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Sign(input);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Verify
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void VerifyTest()
+ {
+ DigitalSignature target = CreateDigitalSignature(); // TODO: Initialize to an appropriate value
+ byte[] input = null; // TODO: Initialize to an appropriate value
+ byte[] signature = null; // TODO: Initialize to an appropriate value
+ bool expected = false; // TODO: Initialize to an appropriate value
+ bool actual;
+ actual = target.Verify(input, signature);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/DsaDigitalSignatureTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/DsaDigitalSignatureTest.cs
index 93bc28c8..0d3423c9 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/DsaDigitalSignatureTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/DsaDigitalSignatureTest.cs
@@ -1,74 +1,74 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security;
-using Renci.SshNet.Security.Cryptography;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography
-{
- ///
- /// Implements DSA digital signature algorithm.
- ///
- [TestClass]
- public class DsaDigitalSignatureTest : TestBase
- {
- ///
- ///A test for DsaDigitalSignature Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DsaDigitalSignatureConstructorTest()
- {
- DsaKey key = null; // TODO: Initialize to an appropriate value
- DsaDigitalSignature target = new DsaDigitalSignature(key);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for Dispose
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DisposeTest()
- {
- DsaKey key = null; // TODO: Initialize to an appropriate value
- DsaDigitalSignature target = new DsaDigitalSignature(key); // TODO: Initialize to an appropriate value
- target.Dispose();
- Assert.Inconclusive("A method that does not return a value cannot be verified.");
- }
-
- ///
- ///A test for Sign
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void SignTest()
- {
- DsaKey key = null; // TODO: Initialize to an appropriate value
- DsaDigitalSignature target = new DsaDigitalSignature(key); // TODO: Initialize to an appropriate value
- byte[] input = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Sign(input);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Verify
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void VerifyTest()
- {
- DsaKey key = null; // TODO: Initialize to an appropriate value
- DsaDigitalSignature target = new DsaDigitalSignature(key); // TODO: Initialize to an appropriate value
- byte[] input = null; // TODO: Initialize to an appropriate value
- byte[] signature = null; // TODO: Initialize to an appropriate value
- bool expected = false; // TODO: Initialize to an appropriate value
- bool actual;
- actual = target.Verify(input, signature);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security;
+using Renci.SshNet.Security.Cryptography;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography
+{
+ ///
+ /// Implements DSA digital signature algorithm.
+ ///
+ [TestClass]
+ public class DsaDigitalSignatureTest : TestBase
+ {
+ ///
+ ///A test for DsaDigitalSignature Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DsaDigitalSignatureConstructorTest()
+ {
+ DsaKey key = null; // TODO: Initialize to an appropriate value
+ DsaDigitalSignature target = new DsaDigitalSignature(key);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for Dispose
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DisposeTest()
+ {
+ DsaKey key = null; // TODO: Initialize to an appropriate value
+ DsaDigitalSignature target = new DsaDigitalSignature(key); // TODO: Initialize to an appropriate value
+ target.Dispose();
+ Assert.Inconclusive("A method that does not return a value cannot be verified.");
+ }
+
+ ///
+ ///A test for Sign
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void SignTest()
+ {
+ DsaKey key = null; // TODO: Initialize to an appropriate value
+ DsaDigitalSignature target = new DsaDigitalSignature(key); // TODO: Initialize to an appropriate value
+ byte[] input = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Sign(input);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Verify
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void VerifyTest()
+ {
+ DsaKey key = null; // TODO: Initialize to an appropriate value
+ DsaDigitalSignature target = new DsaDigitalSignature(key); // TODO: Initialize to an appropriate value
+ byte[] input = null; // TODO: Initialize to an appropriate value
+ byte[] signature = null; // TODO: Initialize to an appropriate value
+ bool expected = false; // TODO: Initialize to an appropriate value
+ bool actual;
+ actual = target.Verify(input, signature);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/DsaKeyTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/DsaKeyTest.cs
index 033af1f7..2e4c22ee 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/DsaKeyTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/DsaKeyTest.cs
@@ -1,151 +1,151 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Security;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography
-{
- ///
- ///This is a test class for DsaKeyTest and is intended
- ///to contain all DsaKeyTest Unit Tests
- ///
- [TestClass()]
- public class DsaKeyTest : TestBase
- {
- ///
- ///A test for DsaKey Constructor
- ///
- [TestMethod()]
- public void DsaKeyConstructorTest()
- {
- DsaKey target = new DsaKey();
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for DsaKey Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DsaKeyConstructorTest1()
- {
- byte[] data = null; // TODO: Initialize to an appropriate value
- DsaKey target = new DsaKey(data);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for DsaKey Constructor
- ///
- [TestMethod()]
- public void DsaKeyConstructorTest2()
- {
- BigInteger p = new BigInteger(); // TODO: Initialize to an appropriate value
- BigInteger q = new BigInteger(); // TODO: Initialize to an appropriate value
- BigInteger g = new BigInteger(); // TODO: Initialize to an appropriate value
- BigInteger y = new BigInteger(); // TODO: Initialize to an appropriate value
- BigInteger x = new BigInteger(); // TODO: Initialize to an appropriate value
- DsaKey target = new DsaKey(p, q, g, y, x);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for Dispose
- ///
- [TestMethod()]
- public void DisposeTest()
- {
- DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
- target.Dispose();
- Assert.Inconclusive("A method that does not return a value cannot be verified.");
- }
-
- ///
- ///A test for G
- ///
- [TestMethod()]
- public void GTest()
- {
- DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
- BigInteger actual;
- actual = target.G;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for KeyLength
- ///
- [TestMethod()]
- public void KeyLengthTest()
- {
- DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
- int actual;
- actual = target.KeyLength;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for P
- ///
- [TestMethod()]
- public void PTest()
- {
- DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
- BigInteger actual;
- actual = target.P;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Public
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PublicTest()
- {
- DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
- BigInteger[] expected = null; // TODO: Initialize to an appropriate value
- BigInteger[] actual;
- target.Public = expected;
- actual = target.Public;
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Q
- ///
- [TestMethod()]
- public void QTest()
- {
- DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
- BigInteger actual;
- actual = target.Q;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for X
- ///
- [TestMethod()]
- public void XTest()
- {
- DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
- BigInteger actual;
- actual = target.X;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Y
- ///
- [TestMethod()]
- public void YTest()
- {
- DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
- BigInteger actual;
- actual = target.Y;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Security;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography
+{
+ ///
+ ///This is a test class for DsaKeyTest and is intended
+ ///to contain all DsaKeyTest Unit Tests
+ ///
+ [TestClass()]
+ public class DsaKeyTest : TestBase
+ {
+ ///
+ ///A test for DsaKey Constructor
+ ///
+ [TestMethod()]
+ public void DsaKeyConstructorTest()
+ {
+ DsaKey target = new DsaKey();
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for DsaKey Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DsaKeyConstructorTest1()
+ {
+ byte[] data = null; // TODO: Initialize to an appropriate value
+ DsaKey target = new DsaKey(data);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for DsaKey Constructor
+ ///
+ [TestMethod()]
+ public void DsaKeyConstructorTest2()
+ {
+ BigInteger p = new BigInteger(); // TODO: Initialize to an appropriate value
+ BigInteger q = new BigInteger(); // TODO: Initialize to an appropriate value
+ BigInteger g = new BigInteger(); // TODO: Initialize to an appropriate value
+ BigInteger y = new BigInteger(); // TODO: Initialize to an appropriate value
+ BigInteger x = new BigInteger(); // TODO: Initialize to an appropriate value
+ DsaKey target = new DsaKey(p, q, g, y, x);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for Dispose
+ ///
+ [TestMethod()]
+ public void DisposeTest()
+ {
+ DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+ target.Dispose();
+ Assert.Inconclusive("A method that does not return a value cannot be verified.");
+ }
+
+ ///
+ ///A test for G
+ ///
+ [TestMethod()]
+ public void GTest()
+ {
+ DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+ BigInteger actual;
+ actual = target.G;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for KeyLength
+ ///
+ [TestMethod()]
+ public void KeyLengthTest()
+ {
+ DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.KeyLength;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for P
+ ///
+ [TestMethod()]
+ public void PTest()
+ {
+ DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+ BigInteger actual;
+ actual = target.P;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Public
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PublicTest()
+ {
+ DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+ BigInteger[] expected = null; // TODO: Initialize to an appropriate value
+ BigInteger[] actual;
+ target.Public = expected;
+ actual = target.Public;
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Q
+ ///
+ [TestMethod()]
+ public void QTest()
+ {
+ DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+ BigInteger actual;
+ actual = target.Q;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for X
+ ///
+ [TestMethod()]
+ public void XTest()
+ {
+ DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+ BigInteger actual;
+ actual = target.X;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Y
+ ///
+ [TestMethod()]
+ public void YTest()
+ {
+ DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+ BigInteger actual;
+ actual = target.Y;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/HMacTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/HMacTest.cs
index 6c5311be..d36f9629 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/HMacTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/HMacTest.cs
@@ -1,136 +1,136 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security.Cryptography;
-using Renci.SshNet.Tests.Common;
-using Renci.SshNet.Tests.Properties;
-using System.Security.Cryptography;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography
-{
- ///
- /// Provides HMAC algorithm implementation.
- ///
- ///
- [TestClass]
- public class HMacTest : TestBase
- {
- [TestMethod]
- [TestCategory("integration")]
- public void Test_HMac_MD5_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.HmacAlgorithms.Clear();
- connectionInfo.HmacAlgorithms.Add("hmac-md5", new HashInfo(16 * 8, HashAlgorithmFactory.CreateHMACMD5));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [TestCategory("integration")]
- public void Test_HMac_Sha1_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.HmacAlgorithms.Clear();
- connectionInfo.HmacAlgorithms.Add("hmac-sha1", new HashInfo(20 * 8, HashAlgorithmFactory.CreateHMACSHA1));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [TestCategory("integration")]
- public void Test_HMac_MD5_96_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.HmacAlgorithms.Clear();
- connectionInfo.HmacAlgorithms.Add("hmac-md5", new HashInfo(16 * 8, key => HashAlgorithmFactory.CreateHMACMD5(key, 96)));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [TestCategory("integration")]
- public void Test_HMac_Sha1_96_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.HmacAlgorithms.Clear();
- connectionInfo.HmacAlgorithms.Add("hmac-sha1", new HashInfo(20 * 8, key => HashAlgorithmFactory.CreateHMACSHA1(key, 96)));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [TestCategory("integration")]
- public void Test_HMac_Sha256_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.HmacAlgorithms.Clear();
- connectionInfo.HmacAlgorithms.Add("hmac-sha2-256", new HashInfo(32 * 8, HashAlgorithmFactory.CreateHMACSHA256));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [TestCategory("integration")]
- public void Test_HMac_Sha256_96_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.HmacAlgorithms.Clear();
- connectionInfo.HmacAlgorithms.Add("hmac-sha2-256-96", new HashInfo(32 * 8, (key) => HashAlgorithmFactory.CreateHMACSHA256(key, 96)));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [TestCategory("integration")]
- public void Test_HMac_RIPEMD160_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.HmacAlgorithms.Clear();
- connectionInfo.HmacAlgorithms.Add("hmac-ripemd160", new HashInfo(160, HashAlgorithmFactory.CreateHMACRIPEMD160));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [TestCategory("integration")]
- public void Test_HMac_RIPEMD160_OPENSSH_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.HmacAlgorithms.Clear();
- connectionInfo.HmacAlgorithms.Add("hmac-ripemd160@openssh.com", new HashInfo(160, HashAlgorithmFactory.CreateHMACRIPEMD160));
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography;
+using Renci.SshNet.Tests.Common;
+using Renci.SshNet.Tests.Properties;
+using System.Security.Cryptography;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography
+{
+ ///
+ /// Provides HMAC algorithm implementation.
+ ///
+ ///
+ [TestClass]
+ public class HMacTest : TestBase
+ {
+ [TestMethod]
+ [TestCategory("integration")]
+ public void Test_HMac_MD5_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.HmacAlgorithms.Clear();
+ connectionInfo.HmacAlgorithms.Add("hmac-md5", new HashInfo(16 * 8, HashAlgorithmFactory.CreateHMACMD5));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [TestCategory("integration")]
+ public void Test_HMac_Sha1_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.HmacAlgorithms.Clear();
+ connectionInfo.HmacAlgorithms.Add("hmac-sha1", new HashInfo(20 * 8, HashAlgorithmFactory.CreateHMACSHA1));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [TestCategory("integration")]
+ public void Test_HMac_MD5_96_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.HmacAlgorithms.Clear();
+ connectionInfo.HmacAlgorithms.Add("hmac-md5", new HashInfo(16 * 8, key => HashAlgorithmFactory.CreateHMACMD5(key, 96)));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [TestCategory("integration")]
+ public void Test_HMac_Sha1_96_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.HmacAlgorithms.Clear();
+ connectionInfo.HmacAlgorithms.Add("hmac-sha1", new HashInfo(20 * 8, key => HashAlgorithmFactory.CreateHMACSHA1(key, 96)));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [TestCategory("integration")]
+ public void Test_HMac_Sha256_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.HmacAlgorithms.Clear();
+ connectionInfo.HmacAlgorithms.Add("hmac-sha2-256", new HashInfo(32 * 8, HashAlgorithmFactory.CreateHMACSHA256));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [TestCategory("integration")]
+ public void Test_HMac_Sha256_96_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.HmacAlgorithms.Clear();
+ connectionInfo.HmacAlgorithms.Add("hmac-sha2-256-96", new HashInfo(32 * 8, (key) => HashAlgorithmFactory.CreateHMACSHA256(key, 96)));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [TestCategory("integration")]
+ public void Test_HMac_RIPEMD160_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.HmacAlgorithms.Clear();
+ connectionInfo.HmacAlgorithms.Add("hmac-ripemd160", new HashInfo(160, HashAlgorithmFactory.CreateHMACRIPEMD160));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [TestCategory("integration")]
+ public void Test_HMac_RIPEMD160_OPENSSH_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.HmacAlgorithms.Clear();
+ connectionInfo.HmacAlgorithms.Add("hmac-ripemd160@openssh.com", new HashInfo(160, HashAlgorithmFactory.CreateHMACRIPEMD160));
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/RsaDigitalSignatureTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/RsaDigitalSignatureTest.cs
index 917ee730..93a76bbe 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/RsaDigitalSignatureTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/RsaDigitalSignatureTest.cs
@@ -1,40 +1,40 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security;
-using Renci.SshNet.Security.Cryptography;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security.Cryptography
-{
- ///
- /// Implements RSA digital signature algorithm.
- ///
- [TestClass]
- public class RsaDigitalSignatureTest : TestBase
- {
-
- ///
- ///A test for RsaDigitalSignature Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void RsaDigitalSignatureConstructorTest()
- {
- RsaKey rsaKey = null; // TODO: Initialize to an appropriate value
- RsaDigitalSignature target = new RsaDigitalSignature(rsaKey);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for Dispose
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DisposeTest()
- {
- RsaKey rsaKey = null; // TODO: Initialize to an appropriate value
- RsaDigitalSignature target = new RsaDigitalSignature(rsaKey); // TODO: Initialize to an appropriate value
- target.Dispose();
- Assert.Inconclusive("A method that does not return a value cannot be verified.");
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security;
+using Renci.SshNet.Security.Cryptography;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography
+{
+ ///
+ /// Implements RSA digital signature algorithm.
+ ///
+ [TestClass]
+ public class RsaDigitalSignatureTest : TestBase
+ {
+
+ ///
+ ///A test for RsaDigitalSignature Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void RsaDigitalSignatureConstructorTest()
+ {
+ RsaKey rsaKey = null; // TODO: Initialize to an appropriate value
+ RsaDigitalSignature target = new RsaDigitalSignature(rsaKey);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for Dispose
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DisposeTest()
+ {
+ RsaKey rsaKey = null; // TODO: Initialize to an appropriate value
+ RsaDigitalSignature target = new RsaDigitalSignature(rsaKey); // TODO: Initialize to an appropriate value
+ target.Dispose();
+ Assert.Inconclusive("A method that does not return a value cannot be verified.");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/RsaKeyTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/RsaKeyTest.cs
index 2725511c..89323337 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/RsaKeyTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/RsaKeyTest.cs
@@ -1,13 +1,13 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security
-{
- ///
- /// Contains RSA private and public key
- ///
- [TestClass]
- public class RsaKeyTest : TestBase
- {
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security
+{
+ ///
+ /// Contains RSA private and public key
+ ///
+ [TestClass]
+ public class RsaKeyTest : TestBase
+ {
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/SymmetricCipherTest.cs b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/SymmetricCipherTest.cs
index 45939e45..8dce8881 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/Cryptography/SymmetricCipherTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/Cryptography/SymmetricCipherTest.cs
@@ -1,62 +1,62 @@
-using Renci.SshNet.Security.Cryptography;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests
-{
- ///
- ///This is a test class for SymmetricCipherTest and is intended
- ///to contain all SymmetricCipherTest Unit Tests
- ///
- [TestClass()]
- public class SymmetricCipherTest : TestBase
- {
- internal virtual SymmetricCipher CreateSymmetricCipher()
- {
- // TODO: Instantiate an appropriate concrete class.
- SymmetricCipher target = null;
- return target;
- }
-
- ///
- ///A test for DecryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DecryptBlockTest()
- {
- SymmetricCipher target = CreateSymmetricCipher(); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for EncryptBlock
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void EncryptBlockTest()
- {
- SymmetricCipher target = CreateSymmetricCipher(); // TODO: Initialize to an appropriate value
- byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
- int inputOffset = 0; // TODO: Initialize to an appropriate value
- int inputCount = 0; // TODO: Initialize to an appropriate value
- byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
- int outputOffset = 0; // TODO: Initialize to an appropriate value
- int expected = 0; // TODO: Initialize to an appropriate value
- int actual;
- actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Renci.SshNet.Security.Cryptography;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests
+{
+ ///
+ ///This is a test class for SymmetricCipherTest and is intended
+ ///to contain all SymmetricCipherTest Unit Tests
+ ///
+ [TestClass()]
+ public class SymmetricCipherTest : TestBase
+ {
+ internal virtual SymmetricCipher CreateSymmetricCipher()
+ {
+ // TODO: Instantiate an appropriate concrete class.
+ SymmetricCipher target = null;
+ return target;
+ }
+
+ ///
+ ///A test for DecryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DecryptBlockTest()
+ {
+ SymmetricCipher target = CreateSymmetricCipher(); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for EncryptBlock
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void EncryptBlockTest()
+ {
+ SymmetricCipher target = CreateSymmetricCipher(); // TODO: Initialize to an appropriate value
+ byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
+ int inputOffset = 0; // TODO: Initialize to an appropriate value
+ int inputCount = 0; // TODO: Initialize to an appropriate value
+ byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
+ int outputOffset = 0; // TODO: Initialize to an appropriate value
+ int expected = 0; // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/HostAlgorithmTest.cs b/src/Renci.SshNet.Tests/Classes/Security/HostAlgorithmTest.cs
index 5e2825be..a9547a54 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/HostAlgorithmTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/HostAlgorithmTest.cs
@@ -1,67 +1,67 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security
-{
- ///
- ///This is a test class for HostAlgorithmTest and is intended
- ///to contain all HostAlgorithmTest Unit Tests
- ///
- [TestClass()]
- public class HostAlgorithmTest : TestBase
- {
- internal virtual HostAlgorithm CreateHostAlgorithm()
- {
- // TODO: Instantiate an appropriate concrete class.
- HostAlgorithm target = null;
- return target;
- }
-
- ///
- ///A test for Sign
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void SignTest()
- {
- HostAlgorithm target = CreateHostAlgorithm(); // TODO: Initialize to an appropriate value
- byte[] data = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Sign(data);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for VerifySignature
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void VerifySignatureTest()
- {
- HostAlgorithm target = CreateHostAlgorithm(); // TODO: Initialize to an appropriate value
- byte[] data = null; // TODO: Initialize to an appropriate value
- byte[] signature = null; // TODO: Initialize to an appropriate value
- bool expected = false; // TODO: Initialize to an appropriate value
- bool actual;
- actual = target.VerifySignature(data, signature);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Data
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DataTest()
- {
- HostAlgorithm target = CreateHostAlgorithm(); // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Data;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security
+{
+ ///
+ ///This is a test class for HostAlgorithmTest and is intended
+ ///to contain all HostAlgorithmTest Unit Tests
+ ///
+ [TestClass()]
+ public class HostAlgorithmTest : TestBase
+ {
+ internal virtual HostAlgorithm CreateHostAlgorithm()
+ {
+ // TODO: Instantiate an appropriate concrete class.
+ HostAlgorithm target = null;
+ return target;
+ }
+
+ ///
+ ///A test for Sign
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void SignTest()
+ {
+ HostAlgorithm target = CreateHostAlgorithm(); // TODO: Initialize to an appropriate value
+ byte[] data = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Sign(data);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for VerifySignature
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void VerifySignatureTest()
+ {
+ HostAlgorithm target = CreateHostAlgorithm(); // TODO: Initialize to an appropriate value
+ byte[] data = null; // TODO: Initialize to an appropriate value
+ byte[] signature = null; // TODO: Initialize to an appropriate value
+ bool expected = false; // TODO: Initialize to an appropriate value
+ bool actual;
+ actual = target.VerifySignature(data, signature);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Data
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DataTest()
+ {
+ HostAlgorithm target = CreateHostAlgorithm(); // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Data;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroup14Sha1Test.cs b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroup14Sha1Test.cs
index afa838ee..f4fcb91f 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroup14Sha1Test.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroup14Sha1Test.cs
@@ -1,13 +1,13 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security
-{
- ///
- /// Represents "diffie-hellman-group14-sha1" algorithm implementation.
- ///
- [TestClass]
- public class KeyExchangeDiffieHellmanGroup14Sha1Test : TestBase
- {
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security
+{
+ ///
+ /// Represents "diffie-hellman-group14-sha1" algorithm implementation.
+ ///
+ [TestClass]
+ public class KeyExchangeDiffieHellmanGroup14Sha1Test : TestBase
+ {
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroup1Sha1Test.cs b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroup1Sha1Test.cs
index 0c729810..a06f8760 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroup1Sha1Test.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroup1Sha1Test.cs
@@ -1,49 +1,49 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Security;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security
-{
- ///
- ///This is a test class for KeyExchangeDiffieHellmanGroup1Sha1Test and is intended
- ///to contain all KeyExchangeDiffieHellmanGroup1Sha1Test Unit Tests
- ///
- [TestClass()]
- public class KeyExchangeDiffieHellmanGroup1Sha1Test : TestBase
- {
- ///
- ///A test for KeyExchangeDiffieHellmanGroup1Sha1 Constructor
- ///
- [TestMethod()]
- public void KeyExchangeDiffieHellmanGroup1Sha1ConstructorTest()
- {
- KeyExchangeDiffieHellmanGroup1Sha1 target = new KeyExchangeDiffieHellmanGroup1Sha1();
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for GroupPrime
- ///
- [TestMethod()]
- public void GroupPrimeTest()
- {
- KeyExchangeDiffieHellmanGroup1Sha1 target = new KeyExchangeDiffieHellmanGroup1Sha1(); // TODO: Initialize to an appropriate value
- BigInteger actual;
- actual = target.GroupPrime;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Name
- ///
- [TestMethod()]
- public void NameTest()
- {
- KeyExchangeDiffieHellmanGroup1Sha1 target = new KeyExchangeDiffieHellmanGroup1Sha1(); // TODO: Initialize to an appropriate value
- string actual;
- actual = target.Name;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Security;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security
+{
+ ///
+ ///This is a test class for KeyExchangeDiffieHellmanGroup1Sha1Test and is intended
+ ///to contain all KeyExchangeDiffieHellmanGroup1Sha1Test Unit Tests
+ ///
+ [TestClass()]
+ public class KeyExchangeDiffieHellmanGroup1Sha1Test : TestBase
+ {
+ ///
+ ///A test for KeyExchangeDiffieHellmanGroup1Sha1 Constructor
+ ///
+ [TestMethod()]
+ public void KeyExchangeDiffieHellmanGroup1Sha1ConstructorTest()
+ {
+ KeyExchangeDiffieHellmanGroup1Sha1 target = new KeyExchangeDiffieHellmanGroup1Sha1();
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for GroupPrime
+ ///
+ [TestMethod()]
+ public void GroupPrimeTest()
+ {
+ KeyExchangeDiffieHellmanGroup1Sha1 target = new KeyExchangeDiffieHellmanGroup1Sha1(); // TODO: Initialize to an appropriate value
+ BigInteger actual;
+ actual = target.GroupPrime;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Name
+ ///
+ [TestMethod()]
+ public void NameTest()
+ {
+ KeyExchangeDiffieHellmanGroup1Sha1 target = new KeyExchangeDiffieHellmanGroup1Sha1(); // TODO: Initialize to an appropriate value
+ string actual;
+ actual = target.Name;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroupExchangeSha1Test.cs b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroupExchangeSha1Test.cs
index 87c45b60..980733e0 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroupExchangeSha1Test.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroupExchangeSha1Test.cs
@@ -1,13 +1,13 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security
-{
- ///
- /// Represents "diffie-hellman-group-exchange-sha1" algorithm implementation.
- ///
- [TestClass]
- public class KeyExchangeDiffieHellmanGroupExchangeSha1Test : TestBase
- {
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security
+{
+ ///
+ /// Represents "diffie-hellman-group-exchange-sha1" algorithm implementation.
+ ///
+ [TestClass]
+ public class KeyExchangeDiffieHellmanGroupExchangeSha1Test : TestBase
+ {
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroupExchangeSha256Test.cs b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroupExchangeSha256Test.cs
index 1fdd96ae..d6b5cfef 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroupExchangeSha256Test.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroupExchangeSha256Test.cs
@@ -1,63 +1,63 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Messages.Transport;
-using Renci.SshNet.Security;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security
-{
- ///
- ///This is a test class for KeyExchangeDiffieHellmanGroupExchangeSha256Test and is intended
- ///to contain all KeyExchangeDiffieHellmanGroupExchangeSha256Test Unit Tests
- ///
- [TestClass()]
- public class KeyExchangeDiffieHellmanGroupExchangeSha256Test : TestBase
- {
- ///
- ///A test for KeyExchangeDiffieHellmanGroupExchangeSha256 Constructor
- ///
- [TestMethod()]
- public void KeyExchangeDiffieHellmanGroupExchangeSha256ConstructorTest()
- {
- KeyExchangeDiffieHellmanGroupExchangeSha256 target = new KeyExchangeDiffieHellmanGroupExchangeSha256();
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for Finish
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void FinishTest()
- {
- KeyExchangeDiffieHellmanGroupExchangeSha256 target = new KeyExchangeDiffieHellmanGroupExchangeSha256(); // TODO: Initialize to an appropriate value
- target.Finish();
- Assert.Inconclusive("A method that does not return a value cannot be verified.");
- }
-
- ///
- ///A test for Start
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void StartTest()
- {
- KeyExchangeDiffieHellmanGroupExchangeSha256 target = new KeyExchangeDiffieHellmanGroupExchangeSha256(); // TODO: Initialize to an appropriate value
- Session session = null; // TODO: Initialize to an appropriate value
- KeyExchangeInitMessage message = null; // TODO: Initialize to an appropriate value
- target.Start(session, message);
- Assert.Inconclusive("A method that does not return a value cannot be verified.");
- }
-
- ///
- ///A test for Name
- ///
- [TestMethod()]
- public void NameTest()
- {
- KeyExchangeDiffieHellmanGroupExchangeSha256 target = new KeyExchangeDiffieHellmanGroupExchangeSha256(); // TODO: Initialize to an appropriate value
- string actual;
- actual = target.Name;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Messages.Transport;
+using Renci.SshNet.Security;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security
+{
+ ///
+ ///This is a test class for KeyExchangeDiffieHellmanGroupExchangeSha256Test and is intended
+ ///to contain all KeyExchangeDiffieHellmanGroupExchangeSha256Test Unit Tests
+ ///
+ [TestClass()]
+ public class KeyExchangeDiffieHellmanGroupExchangeSha256Test : TestBase
+ {
+ ///
+ ///A test for KeyExchangeDiffieHellmanGroupExchangeSha256 Constructor
+ ///
+ [TestMethod()]
+ public void KeyExchangeDiffieHellmanGroupExchangeSha256ConstructorTest()
+ {
+ KeyExchangeDiffieHellmanGroupExchangeSha256 target = new KeyExchangeDiffieHellmanGroupExchangeSha256();
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for Finish
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void FinishTest()
+ {
+ KeyExchangeDiffieHellmanGroupExchangeSha256 target = new KeyExchangeDiffieHellmanGroupExchangeSha256(); // TODO: Initialize to an appropriate value
+ target.Finish();
+ Assert.Inconclusive("A method that does not return a value cannot be verified.");
+ }
+
+ ///
+ ///A test for Start
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void StartTest()
+ {
+ KeyExchangeDiffieHellmanGroupExchangeSha256 target = new KeyExchangeDiffieHellmanGroupExchangeSha256(); // TODO: Initialize to an appropriate value
+ Session session = null; // TODO: Initialize to an appropriate value
+ KeyExchangeInitMessage message = null; // TODO: Initialize to an appropriate value
+ target.Start(session, message);
+ Assert.Inconclusive("A method that does not return a value cannot be verified.");
+ }
+
+ ///
+ ///A test for Name
+ ///
+ [TestMethod()]
+ public void NameTest()
+ {
+ KeyExchangeDiffieHellmanGroupExchangeSha256 target = new KeyExchangeDiffieHellmanGroupExchangeSha256(); // TODO: Initialize to an appropriate value
+ string actual;
+ actual = target.Name;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroupSha1Test.cs b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroupSha1Test.cs
index 8ad08550..40d6b3b8 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroupSha1Test.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanGroupSha1Test.cs
@@ -1,62 +1,62 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Messages.Transport;
-using Renci.SshNet.Security;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security
-{
- ///
- ///This is a test class for KeyExchangeDiffieHellmanGroupSha1Test and is intended
- ///to contain all KeyExchangeDiffieHellmanGroupSha1Test Unit Tests
- ///
- [TestClass()]
- public class KeyExchangeDiffieHellmanGroupSha1Test : TestBase
- {
- internal virtual KeyExchangeDiffieHellmanGroupSha1 CreateKeyExchangeDiffieHellmanGroupSha1()
- {
- // TODO: Instantiate an appropriate concrete class.
- KeyExchangeDiffieHellmanGroupSha1 target = null;
- return target;
- }
-
- ///
- ///A test for Finish
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void FinishTest()
- {
- KeyExchangeDiffieHellmanGroupSha1 target = CreateKeyExchangeDiffieHellmanGroupSha1(); // TODO: Initialize to an appropriate value
- target.Finish();
- Assert.Inconclusive("A method that does not return a value cannot be verified.");
- }
-
- ///
- ///A test for Start
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void StartTest()
- {
- KeyExchangeDiffieHellmanGroupSha1 target = CreateKeyExchangeDiffieHellmanGroupSha1(); // TODO: Initialize to an appropriate value
- Session session = null; // TODO: Initialize to an appropriate value
- KeyExchangeInitMessage message = null; // TODO: Initialize to an appropriate value
- target.Start(session, message);
- Assert.Inconclusive("A method that does not return a value cannot be verified.");
- }
-
- ///
- ///A test for GroupPrime
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void GroupPrimeTest()
- {
- KeyExchangeDiffieHellmanGroupSha1 target = CreateKeyExchangeDiffieHellmanGroupSha1(); // TODO: Initialize to an appropriate value
- BigInteger actual;
- actual = target.GroupPrime;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Transport;
+using Renci.SshNet.Security;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security
+{
+ ///
+ ///This is a test class for KeyExchangeDiffieHellmanGroupSha1Test and is intended
+ ///to contain all KeyExchangeDiffieHellmanGroupSha1Test Unit Tests
+ ///
+ [TestClass()]
+ public class KeyExchangeDiffieHellmanGroupSha1Test : TestBase
+ {
+ internal virtual KeyExchangeDiffieHellmanGroupSha1 CreateKeyExchangeDiffieHellmanGroupSha1()
+ {
+ // TODO: Instantiate an appropriate concrete class.
+ KeyExchangeDiffieHellmanGroupSha1 target = null;
+ return target;
+ }
+
+ ///
+ ///A test for Finish
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void FinishTest()
+ {
+ KeyExchangeDiffieHellmanGroupSha1 target = CreateKeyExchangeDiffieHellmanGroupSha1(); // TODO: Initialize to an appropriate value
+ target.Finish();
+ Assert.Inconclusive("A method that does not return a value cannot be verified.");
+ }
+
+ ///
+ ///A test for Start
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void StartTest()
+ {
+ KeyExchangeDiffieHellmanGroupSha1 target = CreateKeyExchangeDiffieHellmanGroupSha1(); // TODO: Initialize to an appropriate value
+ Session session = null; // TODO: Initialize to an appropriate value
+ KeyExchangeInitMessage message = null; // TODO: Initialize to an appropriate value
+ target.Start(session, message);
+ Assert.Inconclusive("A method that does not return a value cannot be verified.");
+ }
+
+ ///
+ ///A test for GroupPrime
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void GroupPrimeTest()
+ {
+ KeyExchangeDiffieHellmanGroupSha1 target = CreateKeyExchangeDiffieHellmanGroupSha1(); // TODO: Initialize to an appropriate value
+ BigInteger actual;
+ actual = target.GroupPrime;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanTest.cs b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanTest.cs
index 95d98e77..98b73858 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeDiffieHellmanTest.cs
@@ -1,36 +1,36 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Messages.Transport;
-using Renci.SshNet.Security;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security
-{
- ///
- ///This is a test class for KeyExchangeDiffieHellmanTest and is intended
- ///to contain all KeyExchangeDiffieHellmanTest Unit Tests
- ///
- [TestClass()]
- public class KeyExchangeDiffieHellmanTest : TestBase
- {
- internal virtual KeyExchangeDiffieHellman CreateKeyExchangeDiffieHellman()
- {
- // TODO: Instantiate an appropriate concrete class.
- KeyExchangeDiffieHellman target = null;
- return target;
- }
-
- ///
- ///A test for Start
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void StartTest()
- {
- KeyExchangeDiffieHellman target = CreateKeyExchangeDiffieHellman(); // TODO: Initialize to an appropriate value
- Session session = null; // TODO: Initialize to an appropriate value
- KeyExchangeInitMessage message = null; // TODO: Initialize to an appropriate value
- target.Start(session, message);
- Assert.Inconclusive("A method that does not return a value cannot be verified.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Messages.Transport;
+using Renci.SshNet.Security;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security
+{
+ ///
+ ///This is a test class for KeyExchangeDiffieHellmanTest and is intended
+ ///to contain all KeyExchangeDiffieHellmanTest Unit Tests
+ ///
+ [TestClass()]
+ public class KeyExchangeDiffieHellmanTest : TestBase
+ {
+ internal virtual KeyExchangeDiffieHellman CreateKeyExchangeDiffieHellman()
+ {
+ // TODO: Instantiate an appropriate concrete class.
+ KeyExchangeDiffieHellman target = null;
+ return target;
+ }
+
+ ///
+ ///A test for Start
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void StartTest()
+ {
+ KeyExchangeDiffieHellman target = CreateKeyExchangeDiffieHellman(); // TODO: Initialize to an appropriate value
+ Session session = null; // TODO: Initialize to an appropriate value
+ KeyExchangeInitMessage message = null; // TODO: Initialize to an appropriate value
+ target.Start(session, message);
+ Assert.Inconclusive("A method that does not return a value cannot be verified.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeTest.cs b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeTest.cs
index d1bab190..839394e6 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/KeyExchangeTest.cs
@@ -1,16 +1,16 @@
-using Renci.SshNet.Security;
-using Renci.SshNet.Tests.Common;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Renci.SshNet.Tests
-{
- ///
- ///This is a test class for KeyExchangeTest and is intended
- ///to contain all KeyExchangeTest Unit Tests
- ///
- [TestClass()]
- public class KeyExchangeTest : TestBase
- {
-
- }
-}
+using Renci.SshNet.Security;
+using Renci.SshNet.Tests.Common;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Renci.SshNet.Tests
+{
+ ///
+ ///This is a test class for KeyExchangeTest and is intended
+ ///to contain all KeyExchangeTest Unit Tests
+ ///
+ [TestClass()]
+ public class KeyExchangeTest : TestBase
+ {
+
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Security/KeyHostAlgorithmTest.cs b/src/Renci.SshNet.Tests/Classes/Security/KeyHostAlgorithmTest.cs
index 01c69c69..9bd5d10c 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/KeyHostAlgorithmTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/KeyHostAlgorithmTest.cs
@@ -1,123 +1,123 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Security;
-using Renci.SshNet.Tests.Common;
-using Renci.SshNet.Tests.Properties;
-
-namespace Renci.SshNet.Tests.Classes.Security
-{
- ///
- /// Implements key support for host algorithm.
- ///
- [TestClass]
- public class KeyHostAlgorithmTest : TestBase
- {
- [TestMethod]
- [TestCategory("integration")]
- public void Test_HostKey_SshRsa_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.HostKeyAlgorithms.Clear();
- connectionInfo.HostKeyAlgorithms.Add("ssh-rsa", (data) => { return new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data); });
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- [TestMethod]
- [TestCategory("integration")]
- public void Test_HostKey_SshDss_Connection()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
- connectionInfo.HostKeyAlgorithms.Clear();
- connectionInfo.HostKeyAlgorithms.Add("ssh-dss", (data) => { return new KeyHostAlgorithm("ssh-dss", new DsaKey(), data); });
-
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- }
-
- ///
- ///A test for KeyHostAlgorithm Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void KeyHostAlgorithmConstructorTest()
- {
- string name = string.Empty; // TODO: Initialize to an appropriate value
- Key key = null; // TODO: Initialize to an appropriate value
- KeyHostAlgorithm target = new KeyHostAlgorithm(name, key);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for KeyHostAlgorithm Constructor
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void KeyHostAlgorithmConstructorTest1()
- {
- string name = string.Empty; // TODO: Initialize to an appropriate value
- Key key = null; // TODO: Initialize to an appropriate value
- byte[] data = null; // TODO: Initialize to an appropriate value
- KeyHostAlgorithm target = new KeyHostAlgorithm(name, key, data);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
-
- ///
- ///A test for Sign
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void SignTest()
- {
- string name = string.Empty; // TODO: Initialize to an appropriate value
- Key key = null; // TODO: Initialize to an appropriate value
- KeyHostAlgorithm target = new KeyHostAlgorithm(name, key); // TODO: Initialize to an appropriate value
- byte[] data = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Sign(data);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for VerifySignature
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void VerifySignatureTest()
- {
- string name = string.Empty; // TODO: Initialize to an appropriate value
- Key key = null; // TODO: Initialize to an appropriate value
- KeyHostAlgorithm target = new KeyHostAlgorithm(name, key); // TODO: Initialize to an appropriate value
- byte[] data = null; // TODO: Initialize to an appropriate value
- byte[] signature = null; // TODO: Initialize to an appropriate value
- bool expected = false; // TODO: Initialize to an appropriate value
- bool actual;
- actual = target.VerifySignature(data, signature);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Data
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void DataTest()
- {
- string name = string.Empty; // TODO: Initialize to an appropriate value
- Key key = null; // TODO: Initialize to an appropriate value
- KeyHostAlgorithm target = new KeyHostAlgorithm(name, key); // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Data;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security;
+using Renci.SshNet.Tests.Common;
+using Renci.SshNet.Tests.Properties;
+
+namespace Renci.SshNet.Tests.Classes.Security
+{
+ ///
+ /// Implements key support for host algorithm.
+ ///
+ [TestClass]
+ public class KeyHostAlgorithmTest : TestBase
+ {
+ [TestMethod]
+ [TestCategory("integration")]
+ public void Test_HostKey_SshRsa_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.HostKeyAlgorithms.Clear();
+ connectionInfo.HostKeyAlgorithms.Add("ssh-rsa", (data) => { return new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data); });
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ [TestCategory("integration")]
+ public void Test_HostKey_SshDss_Connection()
+ {
+ var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
+ connectionInfo.HostKeyAlgorithms.Clear();
+ connectionInfo.HostKeyAlgorithms.Add("ssh-dss", (data) => { return new KeyHostAlgorithm("ssh-dss", new DsaKey(), data); });
+
+ using (var client = new SshClient(connectionInfo))
+ {
+ client.Connect();
+ client.Disconnect();
+ }
+ }
+
+ ///
+ ///A test for KeyHostAlgorithm Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void KeyHostAlgorithmConstructorTest()
+ {
+ string name = string.Empty; // TODO: Initialize to an appropriate value
+ Key key = null; // TODO: Initialize to an appropriate value
+ KeyHostAlgorithm target = new KeyHostAlgorithm(name, key);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for KeyHostAlgorithm Constructor
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void KeyHostAlgorithmConstructorTest1()
+ {
+ string name = string.Empty; // TODO: Initialize to an appropriate value
+ Key key = null; // TODO: Initialize to an appropriate value
+ byte[] data = null; // TODO: Initialize to an appropriate value
+ KeyHostAlgorithm target = new KeyHostAlgorithm(name, key, data);
+ Assert.Inconclusive("TODO: Implement code to verify target");
+ }
+
+ ///
+ ///A test for Sign
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void SignTest()
+ {
+ string name = string.Empty; // TODO: Initialize to an appropriate value
+ Key key = null; // TODO: Initialize to an appropriate value
+ KeyHostAlgorithm target = new KeyHostAlgorithm(name, key); // TODO: Initialize to an appropriate value
+ byte[] data = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Sign(data);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for VerifySignature
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void VerifySignatureTest()
+ {
+ string name = string.Empty; // TODO: Initialize to an appropriate value
+ Key key = null; // TODO: Initialize to an appropriate value
+ KeyHostAlgorithm target = new KeyHostAlgorithm(name, key); // TODO: Initialize to an appropriate value
+ byte[] data = null; // TODO: Initialize to an appropriate value
+ byte[] signature = null; // TODO: Initialize to an appropriate value
+ bool expected = false; // TODO: Initialize to an appropriate value
+ bool actual;
+ actual = target.VerifySignature(data, signature);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Data
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void DataTest()
+ {
+ string name = string.Empty; // TODO: Initialize to an appropriate value
+ Key key = null; // TODO: Initialize to an appropriate value
+ KeyHostAlgorithm target = new KeyHostAlgorithm(name, key); // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Data;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Security/KeyTest.cs b/src/Renci.SshNet.Tests/Classes/Security/KeyTest.cs
index 81339921..bbbbacff 100644
--- a/src/Renci.SshNet.Tests/Classes/Security/KeyTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Security/KeyTest.cs
@@ -1,84 +1,84 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Security;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Security
-{
- ///
- ///This is a test class for KeyTest and is intended
- ///to contain all KeyTest Unit Tests
- ///
- [TestClass()]
- public class KeyTest : TestBase
- {
- internal virtual Key CreateKey()
- {
- // TODO: Instantiate an appropriate concrete class.
- Key target = null;
- return target;
- }
-
- ///
- ///A test for Sign
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void SignTest()
- {
- Key target = CreateKey(); // TODO: Initialize to an appropriate value
- byte[] data = null; // TODO: Initialize to an appropriate value
- byte[] expected = null; // TODO: Initialize to an appropriate value
- byte[] actual;
- actual = target.Sign(data);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for VerifySignature
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void VerifySignatureTest()
- {
- Key target = CreateKey(); // TODO: Initialize to an appropriate value
- byte[] data = null; // TODO: Initialize to an appropriate value
- byte[] signature = null; // TODO: Initialize to an appropriate value
- bool expected = false; // TODO: Initialize to an appropriate value
- bool actual;
- actual = target.VerifySignature(data, signature);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for KeyLength
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void KeyLengthTest()
- {
- Key target = CreateKey(); // TODO: Initialize to an appropriate value
- int actual;
- actual = target.KeyLength;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Public
- ///
- [TestMethod]
- [Ignore] // placeholder for actual test
- public void PublicTest()
- {
- Key target = CreateKey(); // TODO: Initialize to an appropriate value
- BigInteger[] expected = null; // TODO: Initialize to an appropriate value
- BigInteger[] actual;
- target.Public = expected;
- actual = target.Public;
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Security;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Security
+{
+ ///
+ ///This is a test class for KeyTest and is intended
+ ///to contain all KeyTest Unit Tests
+ ///
+ [TestClass()]
+ public class KeyTest : TestBase
+ {
+ internal virtual Key CreateKey()
+ {
+ // TODO: Instantiate an appropriate concrete class.
+ Key target = null;
+ return target;
+ }
+
+ ///
+ ///A test for Sign
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void SignTest()
+ {
+ Key target = CreateKey(); // TODO: Initialize to an appropriate value
+ byte[] data = null; // TODO: Initialize to an appropriate value
+ byte[] expected = null; // TODO: Initialize to an appropriate value
+ byte[] actual;
+ actual = target.Sign(data);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for VerifySignature
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void VerifySignatureTest()
+ {
+ Key target = CreateKey(); // TODO: Initialize to an appropriate value
+ byte[] data = null; // TODO: Initialize to an appropriate value
+ byte[] signature = null; // TODO: Initialize to an appropriate value
+ bool expected = false; // TODO: Initialize to an appropriate value
+ bool actual;
+ actual = target.VerifySignature(data, signature);
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for KeyLength
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void KeyLengthTest()
+ {
+ Key target = CreateKey(); // TODO: Initialize to an appropriate value
+ int actual;
+ actual = target.KeyLength;
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+
+ ///
+ ///A test for Public
+ ///
+ [TestMethod]
+ [Ignore] // placeholder for actual test
+ public void PublicTest()
+ {
+ Key target = CreateKey(); // TODO: Initialize to an appropriate value
+ BigInteger[] expected = null; // TODO: Initialize to an appropriate value
+ BigInteger[] actual;
+ target.Public = expected;
+ actual = target.Public;
+ Assert.AreEqual(expected, actual);
+ Assert.Inconclusive("Verify the correctness of this test method.");
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest.HttpProxy.cs b/src/Renci.SshNet.Tests/Classes/SessionTest.HttpProxy.cs
index af54db1b..7780d2d8 100644
--- a/src/Renci.SshNet.Tests/Classes/SessionTest.HttpProxy.cs
+++ b/src/Renci.SshNet.Tests/Classes/SessionTest.HttpProxy.cs
@@ -1,263 +1,263 @@
-using System;
-using System.Net;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes
-{
- public partial class SessionTest
- {
- [TestMethod]
- public void ConnectShouldThrowProxyExceptionWhenHttpProxyResponseDoesNotContainStatusLine()
- {
- var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
-
- using (var proxyStub = new HttpProxyStub(proxyEndPoint))
- {
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("Whatever\r\n"));
- proxyStub.Start();
-
- using (var session = new Session(CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, "anon"), _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (ProxyException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("HTTP response does not contain status line.", ex.Message);
- }
- }
- }
- }
-
- [TestMethod]
- public void ConnectShouldThrowProxyExceptionWhenHttpProxyReturnsHttpStatusOtherThan200()
- {
- var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
-
- using (var proxyStub = new HttpProxyStub(proxyEndPoint))
- {
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 501 Custom\r\n"));
- proxyStub.Start();
-
- using (var session = new Session(CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, "anon"), _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (ProxyException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("HTTP: Status code 501, \"Custom\"", ex.Message);
- }
- }
- }
- }
-
- [TestMethod]
- public void ConnectShouldSkipHeadersWhenHttpProxyReturnsHttpStatus200()
- {
- var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
-
- using (var proxyStub = new HttpProxyStub(proxyEndPoint))
- {
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("\r\n"));
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("SSH-666-SshStub"));
- proxyStub.Start();
-
- using (var session = new Session(CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, "anon"), _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Server version '666' is not supported.", ex.Message);
- }
- }
- }
- }
-
- [TestMethod]
- public void ConnectShouldSkipContentWhenHttpProxyReturnsHttpStatus200()
- {
- var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
-
- using (var proxyStub = new HttpProxyStub(proxyEndPoint))
- {
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("Content-Length: 13\r\n"));
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("\r\n"));
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("DUMMY_CONTENT"));
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("SSH-666-SshStub"));
- proxyStub.Start();
-
- using (var session = new Session(CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, "anon"), _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Server version '666' is not supported.", ex.Message);
- }
- }
- }
- }
-
- [TestMethod]
- public void ConnectShouldWriteConnectMethodToHttpProxy()
- {
- var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
-
- using (var proxyStub = new HttpProxyStub(proxyEndPoint))
- {
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 501 Custom\r\n"));
- proxyStub.Start();
-
- using (var session = new Session(CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, "anon"), _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (ProxyException)
- {
- }
- }
-
- Assert.AreEqual(string.Format("CONNECT {0} HTTP/1.0", serverEndPoint), proxyStub.HttpRequest.RequestLine);
- }
- }
-
- [TestMethod]
- public void ConnectShouldWriteProxyAuthorizationToHttpProxyWhenProxyUserNameIsNotNullAndNotEmpty()
- {
- var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
-
- using (var proxyStub = new HttpProxyStub(proxyEndPoint))
- {
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 501 Custom\r\n"));
- proxyStub.Start();
-
- var connectionInfo = CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, "anon");
- using (var session = new Session(connectionInfo, _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (ProxyException)
- {
- }
- }
-
- var expectedProxyAuthorizationHeader = CreateProxyAuthorizationHeader(connectionInfo);
- Assert.IsNotNull(proxyStub.HttpRequest.Headers.SingleOrDefault(p => p == expectedProxyAuthorizationHeader));
- }
- }
-
- [TestMethod]
- public void ConnectShouldNotWriteProxyAuthorizationToHttpProxyWhenProxyUserNameIsEmpty()
- {
- var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
-
- using (var proxyStub = new HttpProxyStub(proxyEndPoint))
- {
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 501 Custom\r\n"));
- proxyStub.Start();
-
- var connectionInfo = CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, string.Empty);
- using (var session = new Session(connectionInfo, _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (ProxyException)
- {
- }
- }
-
- Assert.IsFalse(proxyStub.HttpRequest.Headers.Any(p => p.StartsWith("Proxy-Authorization:")));
- }
- }
-
- [TestMethod]
- public void ConnectShouldNotWriteProxyAuthorizationToHttpProxyWhenProxyUserNameIsNull()
- {
- var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
-
- using (var proxyStub = new HttpProxyStub(proxyEndPoint))
- {
- proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 501 Custom\r\n"));
- proxyStub.Start();
-
- var connectionInfo = CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, null);
- using (var session = new Session(connectionInfo, _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (ProxyException)
- {
- }
- }
-
- Assert.IsFalse(proxyStub.HttpRequest.Headers.Any(p => p.StartsWith("Proxy-Authorization:")));
- }
- }
-
- private static ConnectionInfo CreateConnectionInfoWithProxy(IPEndPoint proxyEndPoint, IPEndPoint serverEndPoint, string proxyUserName)
- {
- return new ConnectionInfo(
- serverEndPoint.Address.ToString(),
- serverEndPoint.Port,
- "eric",
- ProxyTypes.Http,
- proxyEndPoint.Address.ToString(),
- proxyEndPoint.Port,
- proxyUserName,
- "proxypwd",
- new NoneAuthenticationMethod("eric"));
- }
-
- private static string CreateProxyAuthorizationHeader(ConnectionInfo connectionInfo)
- {
- return string.Format("Proxy-Authorization: Basic {0}",
- Convert.ToBase64String(
- Encoding.ASCII.GetBytes(string.Format("{0}:{1}", connectionInfo.ProxyUsername,
- connectionInfo.ProxyPassword))));
- }
- }
-}
+using System;
+using System.Net;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ public partial class SessionTest
+ {
+ [TestMethod]
+ public void ConnectShouldThrowProxyExceptionWhenHttpProxyResponseDoesNotContainStatusLine()
+ {
+ var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+
+ using (var proxyStub = new HttpProxyStub(proxyEndPoint))
+ {
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("Whatever\r\n"));
+ proxyStub.Start();
+
+ using (var session = new Session(CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, "anon"), _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (ProxyException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("HTTP response does not contain status line.", ex.Message);
+ }
+ }
+ }
+ }
+
+ [TestMethod]
+ public void ConnectShouldThrowProxyExceptionWhenHttpProxyReturnsHttpStatusOtherThan200()
+ {
+ var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+
+ using (var proxyStub = new HttpProxyStub(proxyEndPoint))
+ {
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 501 Custom\r\n"));
+ proxyStub.Start();
+
+ using (var session = new Session(CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, "anon"), _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (ProxyException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("HTTP: Status code 501, \"Custom\"", ex.Message);
+ }
+ }
+ }
+ }
+
+ [TestMethod]
+ public void ConnectShouldSkipHeadersWhenHttpProxyReturnsHttpStatus200()
+ {
+ var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+
+ using (var proxyStub = new HttpProxyStub(proxyEndPoint))
+ {
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("\r\n"));
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("SSH-666-SshStub"));
+ proxyStub.Start();
+
+ using (var session = new Session(CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, "anon"), _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Server version '666' is not supported.", ex.Message);
+ }
+ }
+ }
+ }
+
+ [TestMethod]
+ public void ConnectShouldSkipContentWhenHttpProxyReturnsHttpStatus200()
+ {
+ var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+
+ using (var proxyStub = new HttpProxyStub(proxyEndPoint))
+ {
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("Content-Length: 13\r\n"));
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("\r\n"));
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("DUMMY_CONTENT"));
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("SSH-666-SshStub"));
+ proxyStub.Start();
+
+ using (var session = new Session(CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, "anon"), _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Server version '666' is not supported.", ex.Message);
+ }
+ }
+ }
+ }
+
+ [TestMethod]
+ public void ConnectShouldWriteConnectMethodToHttpProxy()
+ {
+ var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+
+ using (var proxyStub = new HttpProxyStub(proxyEndPoint))
+ {
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 501 Custom\r\n"));
+ proxyStub.Start();
+
+ using (var session = new Session(CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, "anon"), _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (ProxyException)
+ {
+ }
+ }
+
+ Assert.AreEqual(string.Format("CONNECT {0} HTTP/1.0", serverEndPoint), proxyStub.HttpRequest.RequestLine);
+ }
+ }
+
+ [TestMethod]
+ public void ConnectShouldWriteProxyAuthorizationToHttpProxyWhenProxyUserNameIsNotNullAndNotEmpty()
+ {
+ var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+
+ using (var proxyStub = new HttpProxyStub(proxyEndPoint))
+ {
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 501 Custom\r\n"));
+ proxyStub.Start();
+
+ var connectionInfo = CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, "anon");
+ using (var session = new Session(connectionInfo, _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (ProxyException)
+ {
+ }
+ }
+
+ var expectedProxyAuthorizationHeader = CreateProxyAuthorizationHeader(connectionInfo);
+ Assert.IsNotNull(proxyStub.HttpRequest.Headers.SingleOrDefault(p => p == expectedProxyAuthorizationHeader));
+ }
+ }
+
+ [TestMethod]
+ public void ConnectShouldNotWriteProxyAuthorizationToHttpProxyWhenProxyUserNameIsEmpty()
+ {
+ var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+
+ using (var proxyStub = new HttpProxyStub(proxyEndPoint))
+ {
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 501 Custom\r\n"));
+ proxyStub.Start();
+
+ var connectionInfo = CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, string.Empty);
+ using (var session = new Session(connectionInfo, _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (ProxyException)
+ {
+ }
+ }
+
+ Assert.IsFalse(proxyStub.HttpRequest.Headers.Any(p => p.StartsWith("Proxy-Authorization:")));
+ }
+ }
+
+ [TestMethod]
+ public void ConnectShouldNotWriteProxyAuthorizationToHttpProxyWhenProxyUserNameIsNull()
+ {
+ var proxyEndPoint = new IPEndPoint(IPAddress.Loopback, 8123);
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+
+ using (var proxyStub = new HttpProxyStub(proxyEndPoint))
+ {
+ proxyStub.Responses.Add(Encoding.ASCII.GetBytes("HTTP/1.0 501 Custom\r\n"));
+ proxyStub.Start();
+
+ var connectionInfo = CreateConnectionInfoWithProxy(proxyEndPoint, serverEndPoint, null);
+ using (var session = new Session(connectionInfo, _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (ProxyException)
+ {
+ }
+ }
+
+ Assert.IsFalse(proxyStub.HttpRequest.Headers.Any(p => p.StartsWith("Proxy-Authorization:")));
+ }
+ }
+
+ private static ConnectionInfo CreateConnectionInfoWithProxy(IPEndPoint proxyEndPoint, IPEndPoint serverEndPoint, string proxyUserName)
+ {
+ return new ConnectionInfo(
+ serverEndPoint.Address.ToString(),
+ serverEndPoint.Port,
+ "eric",
+ ProxyTypes.Http,
+ proxyEndPoint.Address.ToString(),
+ proxyEndPoint.Port,
+ proxyUserName,
+ "proxypwd",
+ new NoneAuthenticationMethod("eric"));
+ }
+
+ private static string CreateProxyAuthorizationHeader(ConnectionInfo connectionInfo)
+ {
+ return string.Format("Proxy-Authorization: Basic {0}",
+ Convert.ToBase64String(
+ Encoding.ASCII.GetBytes(string.Format("{0}:{1}", connectionInfo.ProxyUsername,
+ connectionInfo.ProxyPassword))));
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest.cs b/src/Renci.SshNet.Tests/Classes/SessionTest.cs
index c94bfe56..29e88746 100644
--- a/src/Renci.SshNet.Tests/Classes/SessionTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/SessionTest.cs
@@ -1,363 +1,363 @@
-using System;
-using System.Globalization;
-using System.Net;
-using System.Net.Sockets;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Moq;
-using Renci.SshNet.Common;
-using Renci.SshNet.Tests.Common;
-using Renci.SshNet.Tests.Properties;
-
-namespace Renci.SshNet.Tests.Classes
-{
- ///
- /// Provides functionality to connect and interact with SSH server.
- ///
- [TestClass]
- public partial class SessionTest : TestBase
- {
- private Mock _serviceFactoryMock;
-
- protected override void OnInit()
- {
- base.OnInit();
-
- _serviceFactoryMock = new Mock(MockBehavior.Strict);
- }
-
- [TestMethod]
- public void ConstructorShouldThrowArgumentNullExceptionWhenConnectionInfoIsNull()
- {
- ConnectionInfo connectionInfo = null;
- var serviceFactory = new Mock(MockBehavior.Strict).Object;
-
- try
- {
- new Session(connectionInfo, serviceFactory);
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("connectionInfo", ex.ParamName);
- }
- }
-
- [TestMethod]
- public void ConstructorShouldThrowArgumentNullExceptionWhenServiceFactoryIsNull()
- {
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
- var connectionInfo = CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5));
- IServiceFactory serviceFactory = null;
-
- try
- {
- new Session(connectionInfo, serviceFactory);
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("serviceFactory", ex.ParamName);
- }
- }
-
- [TestMethod]
- public void ConnectShouldSkipLinesBeforeProtocolIdentificationString()
- {
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
- var connectionInfo = CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5));
-
- using (var serverStub = new AsyncSocketListener(serverEndPoint))
- {
- serverStub.Connected += socket =>
- {
- socket.Send(Encoding.ASCII.GetBytes("\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("SSH-666-SshStub\r\n"));
- socket.Shutdown(SocketShutdown.Send);
- };
- serverStub.Start();
-
- using (var session = new Session(connectionInfo, _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Server version '666' is not supported.", ex.Message);
-
- Assert.AreEqual("SSH-666-SshStub", connectionInfo.ServerVersion);
- }
- }
- }
- }
-
- [TestMethod]
- public void ConnectShouldSupportProtocolIdentificationStringThatDoesNotEndWithCrlf()
- {
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
- var connectionInfo = CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5));
-
- using (var serverStub = new AsyncSocketListener(serverEndPoint))
- {
- serverStub.Connected += socket =>
- {
- socket.Send(Encoding.ASCII.GetBytes("\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("SSH-666-SshStub"));
- socket.Shutdown(SocketShutdown.Send);
- };
- serverStub.Start();
-
- using (var session = new Session(connectionInfo, _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Server version '666' is not supported.", ex.Message);
-
- Assert.AreEqual("SSH-666-SshStub", connectionInfo.ServerVersion);
- }
- }
- }
- }
-
- [TestMethod]
- public void ConnectShouldThrowSshOperationExceptionWhenServerDoesNotRespondWithinConnectionTimeout()
- {
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
- var timeout = TimeSpan.FromMilliseconds(500);
- Socket clientSocket = null;
-
- using (var serverStub = new AsyncSocketListener(serverEndPoint))
- {
- serverStub.Connected += socket =>
- {
- socket.Send(Encoding.ASCII.GetBytes("\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
- clientSocket = socket;
- };
- serverStub.Start();
-
- using (var session = new Session(CreateConnectionInfo(serverEndPoint, TimeSpan.FromMilliseconds(500)), _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (SshOperationTimeoutException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "Socket read operation has timed out after {0:F0} milliseconds.", timeout.TotalMilliseconds), ex.Message);
-
- Assert.IsNotNull(clientSocket);
- Assert.IsTrue(clientSocket.Connected);
-
- // shut down socket
- clientSocket.Shutdown(SocketShutdown.Send);
- }
- }
- }
- }
-
- [TestMethod]
- public void ConnectShouldSshConnectionExceptionWhenServerResponseDoesNotContainProtocolIdentificationString()
- {
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
-
- // response ends with CRLF
- using (var serverStub = new AsyncSocketListener(serverEndPoint))
- {
- serverStub.Connected += socket =>
- {
- socket.Send(Encoding.ASCII.GetBytes("\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
- socket.Shutdown(SocketShutdown.Send);
- };
- serverStub.Start();
-
- using (var session = new Session(CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5)), _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Server response does not contain SSH protocol identification.", ex.Message);
- }
- }
- }
-
- // response does not end with CRLF
- using (var serverStub = new AsyncSocketListener(serverEndPoint))
- {
- serverStub.Connected += socket =>
- {
- socket.Send(Encoding.ASCII.GetBytes("\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("WELCOME banner"));
- socket.Shutdown(SocketShutdown.Send);
- };
- serverStub.Start();
-
- using (var session = new Session(CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5)), _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Server response does not contain SSH protocol identification.", ex.Message);
- }
- }
- }
-
- // last line is empty
- using (var serverStub = new AsyncSocketListener(serverEndPoint))
- {
- serverStub.Connected += socket =>
- {
- socket.Send(Encoding.ASCII.GetBytes("\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("\r\n"));
- socket.Shutdown(SocketShutdown.Send);
- };
- serverStub.Start();
-
- using (var session = new Session(CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5)), _serviceFactoryMock.Object))
- {
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Server response does not contain SSH protocol identification.", ex.Message);
- }
- }
- }
- }
-
- [TestMethod]
- public void Connect_HostNameInvalid_ShouldThrowSocketExceptionWithErrorCodeHostNotFound()
- {
- var connectionInfo = new ConnectionInfo("invalid.", 40, "user",
- new KeyboardInteractiveAuthenticationMethod("user"));
- var session = new Session(connectionInfo, _serviceFactoryMock.Object);
-
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (SocketException ex)
- {
- Assert.AreEqual(ex.ErrorCode, (int)SocketError.HostNotFound);
- }
- }
-
- [TestMethod]
- public void Connect_ProxyHostNameInvalid_ShouldThrowSocketExceptionWithErrorCodeHostNotFound()
- {
- var connectionInfo = new ConnectionInfo("localhost", 40, "user", ProxyTypes.Http, "invalid.", 80,
- "proxyUser", "proxyPwd", new KeyboardInteractiveAuthenticationMethod("user"));
- var session = new Session(connectionInfo, _serviceFactoryMock.Object);
-
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (SocketException ex)
- {
- Assert.AreEqual(ex.ErrorCode, (int)SocketError.HostNotFound);
- }
- }
-
- [TestMethod]
- public void DisconnectShouldNotThrowExceptionWhenSocketIsNotConnected()
- {
- var connectionInfo = new ConnectionInfo("localhost", 6767, Resources.USERNAME,
- new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
- var session = new Session(connectionInfo, _serviceFactoryMock.Object);
-
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (SocketException)
- {
- session.Disconnect();
- }
- }
-
- [TestMethod]
- public void DisconnectShouldNotThrowExceptionWhenConnectHasNotBeenInvoked()
- {
- var connectionInfo = new ConnectionInfo("localhost", 6767, Resources.USERNAME,
- new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
- var session = new Session(connectionInfo, _serviceFactoryMock.Object);
-
- session.Disconnect();
- }
-
- [TestMethod]
- public void DisposeShouldNotThrowExceptionWhenSocketIsNotConnected()
- {
- var connectionInfo = new ConnectionInfo("localhost", 6767, Resources.USERNAME,
- new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
- var session = new Session(connectionInfo, _serviceFactoryMock.Object);
-
- try
- {
- session.Connect();
- Assert.Fail();
- }
- catch (SocketException)
- {
- session.Dispose();
- }
- }
-
- [TestMethod]
- public void DisposeShouldNotThrowExceptionWhenConenectHasNotBeenInvoked()
- {
- var connectionInfo = new ConnectionInfo("localhost", 6767, Resources.USERNAME,
- new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
- var session = new Session(connectionInfo, _serviceFactoryMock.Object);
-
- session.Disconnect();
- }
-
- private static ConnectionInfo CreateConnectionInfo(IPEndPoint serverEndPoint, TimeSpan timeout)
- {
- var connectionInfo = new ConnectionInfo(
- serverEndPoint.Address.ToString(),
- serverEndPoint.Port,
- "eric",
- new NoneAuthenticationMethod("eric"));
- connectionInfo.Timeout = timeout;
- return connectionInfo;
- }
- }
+using System;
+using System.Globalization;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Common;
+using Renci.SshNet.Tests.Common;
+using Renci.SshNet.Tests.Properties;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ ///
+ /// Provides functionality to connect and interact with SSH server.
+ ///
+ [TestClass]
+ public partial class SessionTest : TestBase
+ {
+ private Mock _serviceFactoryMock;
+
+ protected override void OnInit()
+ {
+ base.OnInit();
+
+ _serviceFactoryMock = new Mock(MockBehavior.Strict);
+ }
+
+ [TestMethod]
+ public void ConstructorShouldThrowArgumentNullExceptionWhenConnectionInfoIsNull()
+ {
+ ConnectionInfo connectionInfo = null;
+ var serviceFactory = new Mock(MockBehavior.Strict).Object;
+
+ try
+ {
+ new Session(connectionInfo, serviceFactory);
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("connectionInfo", ex.ParamName);
+ }
+ }
+
+ [TestMethod]
+ public void ConstructorShouldThrowArgumentNullExceptionWhenServiceFactoryIsNull()
+ {
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+ var connectionInfo = CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5));
+ IServiceFactory serviceFactory = null;
+
+ try
+ {
+ new Session(connectionInfo, serviceFactory);
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("serviceFactory", ex.ParamName);
+ }
+ }
+
+ [TestMethod]
+ public void ConnectShouldSkipLinesBeforeProtocolIdentificationString()
+ {
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+ var connectionInfo = CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5));
+
+ using (var serverStub = new AsyncSocketListener(serverEndPoint))
+ {
+ serverStub.Connected += socket =>
+ {
+ socket.Send(Encoding.ASCII.GetBytes("\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("SSH-666-SshStub\r\n"));
+ socket.Shutdown(SocketShutdown.Send);
+ };
+ serverStub.Start();
+
+ using (var session = new Session(connectionInfo, _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Server version '666' is not supported.", ex.Message);
+
+ Assert.AreEqual("SSH-666-SshStub", connectionInfo.ServerVersion);
+ }
+ }
+ }
+ }
+
+ [TestMethod]
+ public void ConnectShouldSupportProtocolIdentificationStringThatDoesNotEndWithCrlf()
+ {
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+ var connectionInfo = CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5));
+
+ using (var serverStub = new AsyncSocketListener(serverEndPoint))
+ {
+ serverStub.Connected += socket =>
+ {
+ socket.Send(Encoding.ASCII.GetBytes("\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("SSH-666-SshStub"));
+ socket.Shutdown(SocketShutdown.Send);
+ };
+ serverStub.Start();
+
+ using (var session = new Session(connectionInfo, _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Server version '666' is not supported.", ex.Message);
+
+ Assert.AreEqual("SSH-666-SshStub", connectionInfo.ServerVersion);
+ }
+ }
+ }
+ }
+
+ [TestMethod]
+ public void ConnectShouldThrowSshOperationExceptionWhenServerDoesNotRespondWithinConnectionTimeout()
+ {
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+ var timeout = TimeSpan.FromMilliseconds(500);
+ Socket clientSocket = null;
+
+ using (var serverStub = new AsyncSocketListener(serverEndPoint))
+ {
+ serverStub.Connected += socket =>
+ {
+ socket.Send(Encoding.ASCII.GetBytes("\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
+ clientSocket = socket;
+ };
+ serverStub.Start();
+
+ using (var session = new Session(CreateConnectionInfo(serverEndPoint, TimeSpan.FromMilliseconds(500)), _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (SshOperationTimeoutException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "Socket read operation has timed out after {0:F0} milliseconds.", timeout.TotalMilliseconds), ex.Message);
+
+ Assert.IsNotNull(clientSocket);
+ Assert.IsTrue(clientSocket.Connected);
+
+ // shut down socket
+ clientSocket.Shutdown(SocketShutdown.Send);
+ }
+ }
+ }
+ }
+
+ [TestMethod]
+ public void ConnectShouldSshConnectionExceptionWhenServerResponseDoesNotContainProtocolIdentificationString()
+ {
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+
+ // response ends with CRLF
+ using (var serverStub = new AsyncSocketListener(serverEndPoint))
+ {
+ serverStub.Connected += socket =>
+ {
+ socket.Send(Encoding.ASCII.GetBytes("\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
+ socket.Shutdown(SocketShutdown.Send);
+ };
+ serverStub.Start();
+
+ using (var session = new Session(CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5)), _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Server response does not contain SSH protocol identification.", ex.Message);
+ }
+ }
+ }
+
+ // response does not end with CRLF
+ using (var serverStub = new AsyncSocketListener(serverEndPoint))
+ {
+ serverStub.Connected += socket =>
+ {
+ socket.Send(Encoding.ASCII.GetBytes("\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("WELCOME banner"));
+ socket.Shutdown(SocketShutdown.Send);
+ };
+ serverStub.Start();
+
+ using (var session = new Session(CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5)), _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Server response does not contain SSH protocol identification.", ex.Message);
+ }
+ }
+ }
+
+ // last line is empty
+ using (var serverStub = new AsyncSocketListener(serverEndPoint))
+ {
+ serverStub.Connected += socket =>
+ {
+ socket.Send(Encoding.ASCII.GetBytes("\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("\r\n"));
+ socket.Shutdown(SocketShutdown.Send);
+ };
+ serverStub.Start();
+
+ using (var session = new Session(CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5)), _serviceFactoryMock.Object))
+ {
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Server response does not contain SSH protocol identification.", ex.Message);
+ }
+ }
+ }
+ }
+
+ [TestMethod]
+ public void Connect_HostNameInvalid_ShouldThrowSocketExceptionWithErrorCodeHostNotFound()
+ {
+ var connectionInfo = new ConnectionInfo("invalid.", 40, "user",
+ new KeyboardInteractiveAuthenticationMethod("user"));
+ var session = new Session(connectionInfo, _serviceFactoryMock.Object);
+
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (SocketException ex)
+ {
+ Assert.AreEqual(ex.ErrorCode, (int)SocketError.HostNotFound);
+ }
+ }
+
+ [TestMethod]
+ public void Connect_ProxyHostNameInvalid_ShouldThrowSocketExceptionWithErrorCodeHostNotFound()
+ {
+ var connectionInfo = new ConnectionInfo("localhost", 40, "user", ProxyTypes.Http, "invalid.", 80,
+ "proxyUser", "proxyPwd", new KeyboardInteractiveAuthenticationMethod("user"));
+ var session = new Session(connectionInfo, _serviceFactoryMock.Object);
+
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (SocketException ex)
+ {
+ Assert.AreEqual(ex.ErrorCode, (int)SocketError.HostNotFound);
+ }
+ }
+
+ [TestMethod]
+ public void DisconnectShouldNotThrowExceptionWhenSocketIsNotConnected()
+ {
+ var connectionInfo = new ConnectionInfo("localhost", 6767, Resources.USERNAME,
+ new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
+ var session = new Session(connectionInfo, _serviceFactoryMock.Object);
+
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (SocketException)
+ {
+ session.Disconnect();
+ }
+ }
+
+ [TestMethod]
+ public void DisconnectShouldNotThrowExceptionWhenConnectHasNotBeenInvoked()
+ {
+ var connectionInfo = new ConnectionInfo("localhost", 6767, Resources.USERNAME,
+ new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
+ var session = new Session(connectionInfo, _serviceFactoryMock.Object);
+
+ session.Disconnect();
+ }
+
+ [TestMethod]
+ public void DisposeShouldNotThrowExceptionWhenSocketIsNotConnected()
+ {
+ var connectionInfo = new ConnectionInfo("localhost", 6767, Resources.USERNAME,
+ new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
+ var session = new Session(connectionInfo, _serviceFactoryMock.Object);
+
+ try
+ {
+ session.Connect();
+ Assert.Fail();
+ }
+ catch (SocketException)
+ {
+ session.Dispose();
+ }
+ }
+
+ [TestMethod]
+ public void DisposeShouldNotThrowExceptionWhenConenectHasNotBeenInvoked()
+ {
+ var connectionInfo = new ConnectionInfo("localhost", 6767, Resources.USERNAME,
+ new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
+ var session = new Session(connectionInfo, _serviceFactoryMock.Object);
+
+ session.Disconnect();
+ }
+
+ private static ConnectionInfo CreateConnectionInfo(IPEndPoint serverEndPoint, TimeSpan timeout)
+ {
+ var connectionInfo = new ConnectionInfo(
+ serverEndPoint.Address.ToString(),
+ serverEndPoint.Port,
+ "eric",
+ new NoneAuthenticationMethod("eric"));
+ connectionInfo.Timeout = timeout;
+ return connectionInfo;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected.cs b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected.cs
index b92c2f0e..829bac3d 100644
--- a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected.cs
+++ b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected.cs
@@ -1,169 +1,169 @@
-using System;
-using System.Threading;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Messages.Transport;
-
-namespace Renci.SshNet.Tests.Classes
-{
- [TestClass]
- public class SessionTest_Connected : SessionTest_ConnectedBase
- {
- private IgnoreMessage _ignoreMessage;
-
- protected override void Arrange()
- {
- base.Arrange();
-
- var data = new byte[10];
- Random.NextBytes(data);
- _ignoreMessage = new IgnoreMessage(data);
- }
-
- protected override void Act()
- {
- }
-
- [TestMethod]
- public void ClientVersionIsRenciSshNet()
- {
- Assert.AreEqual("SSH-2.0-Renci.SshNet.SshClient.0.0.1", Session.ClientVersion);
- }
-
- [TestMethod]
- public void ConnectionInfoShouldReturnConnectionInfoPassedThroughConstructor()
- {
- Assert.AreSame(ConnectionInfo, Session.ConnectionInfo);
- }
-
- [TestMethod]
- public void IsConnectedShouldReturnTrue()
- {
- Assert.IsTrue(Session.IsConnected);
- }
-
- [TestMethod]
- public void SendMessageShouldSendPacketToServer()
- {
- ServerBytesReceivedRegister.Clear();
-
- Session.SendMessage(_ignoreMessage);
-
- // give session time to process message
- Thread.Sleep(100);
-
- Assert.AreEqual(1, ServerBytesReceivedRegister.Count);
- }
-
- [TestMethod]
- public void SessionIdShouldReturnExchangeHashCalculatedFromKeyExchangeInitMessage()
- {
- Assert.IsNotNull(Session.SessionId);
- Assert.AreSame(SessionId, Session.SessionId);
- }
-
- [TestMethod]
- public void ServerVersionShouldNotReturnNull()
- {
- Assert.IsNotNull(Session.ServerVersion);
- Assert.AreEqual("SSH-2.0-SshStub", Session.ServerVersion);
- }
-
- [TestMethod]
- public void WaitOnHandle_WaitHandle_ShouldThrowArgumentNullExceptionWhenWaitHandleIsNull()
- {
- WaitHandle waitHandle = null;
-
- try
- {
- Session.WaitOnHandle(waitHandle);
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("waitHandle", ex.ParamName);
- }
- }
-
- [TestMethod]
- public void WaitOnHandle_WaitHandleAndTimeout_ShouldThrowArgumentNullExceptionWhenWaitHandleIsNull()
- {
- WaitHandle waitHandle = null;
- var timeout = TimeSpan.FromMinutes(5);
-
- try
- {
- Session.WaitOnHandle(waitHandle, timeout);
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("waitHandle", ex.ParamName);
- }
- }
-
- [TestMethod]
- public void ISession_ConnectionInfoShouldReturnConnectionInfoPassedThroughConstructor()
- {
- var session = (ISession) Session;
- Assert.AreSame(ConnectionInfo, session.ConnectionInfo);
- }
-
- [TestMethod]
- public void ISession_MessageListenerCompletedShouldNotBeSignaled()
- {
- var session = (ISession) Session;
-
- Assert.IsNotNull(session.MessageListenerCompleted);
- Assert.IsFalse(session.MessageListenerCompleted.WaitOne(0));
- }
-
- [TestMethod]
- public void ISession_SendMessageShouldSendPacketToServer()
- {
- var session = (ISession) Session;
- ServerBytesReceivedRegister.Clear();
-
- session.SendMessage(_ignoreMessage);
-
- // give session time to process message
- Thread.Sleep(100);
-
- Assert.AreEqual(1, ServerBytesReceivedRegister.Count);
- }
-
- [TestMethod]
- public void ISession_TrySendMessageShouldSendPacketToServerAndReturnTrue()
- {
- var session = (ISession) Session;
- ServerBytesReceivedRegister.Clear();
-
- var actual = session.TrySendMessage(new IgnoreMessage());
-
- // give session time to process message
- Thread.Sleep(100);
-
- Assert.IsTrue(actual);
- Assert.AreEqual(1, ServerBytesReceivedRegister.Count);
- }
-
- [TestMethod]
- public void ISession_WaitOnHandleShouldThrowArgumentNullExceptionWhenWaitHandleIsNull()
- {
- WaitHandle waitHandle = null;
- var session = (ISession) Session;
-
- try
- {
- session.WaitOnHandle(waitHandle);
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("waitHandle", ex.ParamName);
- }
- }
- }
-}
+using System;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Messages.Transport;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ [TestClass]
+ public class SessionTest_Connected : SessionTest_ConnectedBase
+ {
+ private IgnoreMessage _ignoreMessage;
+
+ protected override void Arrange()
+ {
+ base.Arrange();
+
+ var data = new byte[10];
+ Random.NextBytes(data);
+ _ignoreMessage = new IgnoreMessage(data);
+ }
+
+ protected override void Act()
+ {
+ }
+
+ [TestMethod]
+ public void ClientVersionIsRenciSshNet()
+ {
+ Assert.AreEqual("SSH-2.0-Renci.SshNet.SshClient.0.0.1", Session.ClientVersion);
+ }
+
+ [TestMethod]
+ public void ConnectionInfoShouldReturnConnectionInfoPassedThroughConstructor()
+ {
+ Assert.AreSame(ConnectionInfo, Session.ConnectionInfo);
+ }
+
+ [TestMethod]
+ public void IsConnectedShouldReturnTrue()
+ {
+ Assert.IsTrue(Session.IsConnected);
+ }
+
+ [TestMethod]
+ public void SendMessageShouldSendPacketToServer()
+ {
+ ServerBytesReceivedRegister.Clear();
+
+ Session.SendMessage(_ignoreMessage);
+
+ // give session time to process message
+ Thread.Sleep(100);
+
+ Assert.AreEqual(1, ServerBytesReceivedRegister.Count);
+ }
+
+ [TestMethod]
+ public void SessionIdShouldReturnExchangeHashCalculatedFromKeyExchangeInitMessage()
+ {
+ Assert.IsNotNull(Session.SessionId);
+ Assert.AreSame(SessionId, Session.SessionId);
+ }
+
+ [TestMethod]
+ public void ServerVersionShouldNotReturnNull()
+ {
+ Assert.IsNotNull(Session.ServerVersion);
+ Assert.AreEqual("SSH-2.0-SshStub", Session.ServerVersion);
+ }
+
+ [TestMethod]
+ public void WaitOnHandle_WaitHandle_ShouldThrowArgumentNullExceptionWhenWaitHandleIsNull()
+ {
+ WaitHandle waitHandle = null;
+
+ try
+ {
+ Session.WaitOnHandle(waitHandle);
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("waitHandle", ex.ParamName);
+ }
+ }
+
+ [TestMethod]
+ public void WaitOnHandle_WaitHandleAndTimeout_ShouldThrowArgumentNullExceptionWhenWaitHandleIsNull()
+ {
+ WaitHandle waitHandle = null;
+ var timeout = TimeSpan.FromMinutes(5);
+
+ try
+ {
+ Session.WaitOnHandle(waitHandle, timeout);
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("waitHandle", ex.ParamName);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_ConnectionInfoShouldReturnConnectionInfoPassedThroughConstructor()
+ {
+ var session = (ISession) Session;
+ Assert.AreSame(ConnectionInfo, session.ConnectionInfo);
+ }
+
+ [TestMethod]
+ public void ISession_MessageListenerCompletedShouldNotBeSignaled()
+ {
+ var session = (ISession) Session;
+
+ Assert.IsNotNull(session.MessageListenerCompleted);
+ Assert.IsFalse(session.MessageListenerCompleted.WaitOne(0));
+ }
+
+ [TestMethod]
+ public void ISession_SendMessageShouldSendPacketToServer()
+ {
+ var session = (ISession) Session;
+ ServerBytesReceivedRegister.Clear();
+
+ session.SendMessage(_ignoreMessage);
+
+ // give session time to process message
+ Thread.Sleep(100);
+
+ Assert.AreEqual(1, ServerBytesReceivedRegister.Count);
+ }
+
+ [TestMethod]
+ public void ISession_TrySendMessageShouldSendPacketToServerAndReturnTrue()
+ {
+ var session = (ISession) Session;
+ ServerBytesReceivedRegister.Clear();
+
+ var actual = session.TrySendMessage(new IgnoreMessage());
+
+ // give session time to process message
+ Thread.Sleep(100);
+
+ Assert.IsTrue(actual);
+ Assert.AreEqual(1, ServerBytesReceivedRegister.Count);
+ }
+
+ [TestMethod]
+ public void ISession_WaitOnHandleShouldThrowArgumentNullExceptionWhenWaitHandleIsNull()
+ {
+ WaitHandle waitHandle = null;
+ var session = (ISession) Session;
+
+ try
+ {
+ session.WaitOnHandle(waitHandle);
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("waitHandle", ex.ParamName);
+ }
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs b/src/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs
index 56b03d85..9584d0c0 100644
--- a/src/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs
+++ b/src/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs
@@ -1,192 +1,192 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Net;
-using System.Net.Sockets;
-using System.Security.Cryptography;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Moq;
-using Renci.SshNet.Common;
-using Renci.SshNet.Compression;
-using Renci.SshNet.Messages;
-using Renci.SshNet.Messages.Transport;
-using Renci.SshNet.Security;
-using Renci.SshNet.Security.Cryptography;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes
-{
- [TestClass]
- public abstract class SessionTest_ConnectedBase
- {
- private Mock _serviceFactoryMock;
- private Mock _keyExchangeMock;
- private Mock _clientAuthenticationMock;
- private IPEndPoint _serverEndPoint;
- private string _keyExchangeAlgorithm;
-
- protected Random Random { get; private set; }
- protected byte[] SessionId { get; private set; }
- protected ConnectionInfo ConnectionInfo { get; private set; }
- protected IList DisconnectedRegister { get; private set; }
- protected IList> DisconnectReceivedRegister { get; private set; }
- protected IList ErrorOccurredRegister { get; private set; }
- protected AsyncSocketListener ServerListener { get; private set; }
- protected IList ServerBytesReceivedRegister { get; private set; }
- protected Session Session { get; private set; }
- protected Socket ServerSocket { get; private set; }
-
- [TestInitialize]
- public void Setup()
- {
- Arrange();
- Act();
- }
-
- [TestCleanup]
- public void TearDown()
- {
- if (ServerListener != null)
- {
- ServerListener.Dispose();
- }
-
- if (Session != null)
- {
- Session.Dispose();
- }
- }
-
- protected virtual void Arrange()
- {
- Random = new Random();
-
- _serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
- ConnectionInfo = new ConnectionInfo(
- _serverEndPoint.Address.ToString(),
- _serverEndPoint.Port,
- "user",
- new PasswordAuthenticationMethod("user", "password"));
- ConnectionInfo.Timeout = TimeSpan.FromSeconds(20);
- _keyExchangeAlgorithm = Random.Next().ToString(CultureInfo.InvariantCulture);
- SessionId = new byte[10];
- Random.NextBytes(SessionId);
- DisconnectedRegister = new List();
- DisconnectReceivedRegister = new List>();
- ErrorOccurredRegister = new List();
- ServerBytesReceivedRegister = new List();
-
- _serviceFactoryMock = new Mock(MockBehavior.Strict);
- _keyExchangeMock = new Mock(MockBehavior.Strict);
- _clientAuthenticationMock = new Mock(MockBehavior.Strict);
-
- Session = new Session(ConnectionInfo, _serviceFactoryMock.Object);
- Session.Disconnected += (sender, args) => DisconnectedRegister.Add(args);
- Session.DisconnectReceived += (sender, args) => DisconnectReceivedRegister.Add(args);
- Session.ErrorOccured += (sender, args) => ErrorOccurredRegister.Add(args);
- Session.KeyExchangeInitReceived += (sender, args) =>
- {
- var newKeysMessage = new NewKeysMessage();
- var newKeys = newKeysMessage.GetPacket(8, null);
- ServerSocket.Send(newKeys, 4, newKeys.Length - 4, SocketFlags.None);
- };
-
- _serviceFactoryMock.Setup(
- p =>
- p.CreateKeyExchange(ConnectionInfo.KeyExchangeAlgorithms, new[] {_keyExchangeAlgorithm})).Returns(_keyExchangeMock.Object);
- _keyExchangeMock.Setup(p => p.Name).Returns(_keyExchangeAlgorithm);
- _keyExchangeMock.Setup(p => p.Start(Session, It.IsAny()));
- _keyExchangeMock.Setup(p => p.ExchangeHash).Returns(SessionId);
- _keyExchangeMock.Setup(p => p.CreateServerCipher()).Returns((Cipher) null);
- _keyExchangeMock.Setup(p => p.CreateClientCipher()).Returns((Cipher) null);
- _keyExchangeMock.Setup(p => p.CreateServerHash()).Returns((HashAlgorithm) null);
- _keyExchangeMock.Setup(p => p.CreateClientHash()).Returns((HashAlgorithm) null);
- _keyExchangeMock.Setup(p => p.CreateCompressor()).Returns((Compressor) null);
- _keyExchangeMock.Setup(p => p.CreateDecompressor()).Returns((Compressor) null);
- _keyExchangeMock.Setup(p => p.Dispose());
- _serviceFactoryMock.Setup(p => p.CreateClientAuthentication()).Callback(ClientAuthentication_Callback).Returns(_clientAuthenticationMock.Object);
- _clientAuthenticationMock.Setup(p => p.Authenticate(ConnectionInfo, Session));
-
- ServerListener = new AsyncSocketListener(_serverEndPoint);
- ServerListener.Connected += socket =>
- {
- ServerSocket = socket;
-
- socket.Send(Encoding.ASCII.GetBytes("\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("SSH-2.0-SshStub\r\n"));
- };
-
- var counter = 0;
-
- ServerListener.BytesReceived += (received, socket) =>
- {
- ServerBytesReceivedRegister.Add(received);
-
- switch (counter++)
- {
- case 0:
- var keyExchangeInitMessage = new KeyExchangeInitMessage
- {
- CompressionAlgorithmsClientToServer = new string[0],
- CompressionAlgorithmsServerToClient = new string[0],
- EncryptionAlgorithmsClientToServer = new string[0],
- EncryptionAlgorithmsServerToClient = new string[0],
- KeyExchangeAlgorithms = new[] {_keyExchangeAlgorithm},
- LanguagesClientToServer = new string[0],
- LanguagesServerToClient = new string[0],
- MacAlgorithmsClientToServer = new string[0],
- MacAlgorithmsServerToClient = new string[0],
- ServerHostKeyAlgorithms = new string[0]
- };
- var keyExchangeInit = keyExchangeInitMessage.GetPacket(8, null);
- ServerSocket.Send(keyExchangeInit, 4, keyExchangeInit.Length - 4, SocketFlags.None);
- break;
- case 1:
- var serviceAcceptMessage =
- ServiceAcceptMessageBuilder.Create(ServiceName.UserAuthentication)
- .Build();
- ServerSocket.Send(serviceAcceptMessage, 0, serviceAcceptMessage.Length, SocketFlags.None);
- break;
- }
- };
- ServerListener.Start();
-
- Session.Connect();
- }
-
- protected virtual void ClientAuthentication_Callback()
- {
- }
-
- protected abstract void Act();
-
- private class ServiceAcceptMessageBuilder
- {
- private readonly ServiceName _serviceName;
-
- private ServiceAcceptMessageBuilder(ServiceName serviceName)
- {
- _serviceName = serviceName;
- }
-
- public static ServiceAcceptMessageBuilder Create(ServiceName serviceName)
- {
- return new ServiceAcceptMessageBuilder(serviceName);
- }
-
- public byte[] Build()
- {
- var serviceName = _serviceName.ToArray();
-
- var sshDataStream = new SshDataStream(4 + 1 + 1 + 4 + serviceName.Length);
- sshDataStream.Write((uint)(sshDataStream.Capacity - 4)); // packet length
- sshDataStream.WriteByte(0); // padding length
- sshDataStream.WriteByte(ServiceAcceptMessage.MessageNumber);
- sshDataStream.WriteBinary(serviceName);
- return sshDataStream.ToArray();
- }
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Net;
+using System.Net.Sockets;
+using System.Security.Cryptography;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Common;
+using Renci.SshNet.Compression;
+using Renci.SshNet.Messages;
+using Renci.SshNet.Messages.Transport;
+using Renci.SshNet.Security;
+using Renci.SshNet.Security.Cryptography;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ [TestClass]
+ public abstract class SessionTest_ConnectedBase
+ {
+ private Mock _serviceFactoryMock;
+ private Mock _keyExchangeMock;
+ private Mock _clientAuthenticationMock;
+ private IPEndPoint _serverEndPoint;
+ private string _keyExchangeAlgorithm;
+
+ protected Random Random { get; private set; }
+ protected byte[] SessionId { get; private set; }
+ protected ConnectionInfo ConnectionInfo { get; private set; }
+ protected IList DisconnectedRegister { get; private set; }
+ protected IList> DisconnectReceivedRegister { get; private set; }
+ protected IList ErrorOccurredRegister { get; private set; }
+ protected AsyncSocketListener ServerListener { get; private set; }
+ protected IList ServerBytesReceivedRegister { get; private set; }
+ protected Session Session { get; private set; }
+ protected Socket ServerSocket { get; private set; }
+
+ [TestInitialize]
+ public void Setup()
+ {
+ Arrange();
+ Act();
+ }
+
+ [TestCleanup]
+ public void TearDown()
+ {
+ if (ServerListener != null)
+ {
+ ServerListener.Dispose();
+ }
+
+ if (Session != null)
+ {
+ Session.Dispose();
+ }
+ }
+
+ protected virtual void Arrange()
+ {
+ Random = new Random();
+
+ _serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+ ConnectionInfo = new ConnectionInfo(
+ _serverEndPoint.Address.ToString(),
+ _serverEndPoint.Port,
+ "user",
+ new PasswordAuthenticationMethod("user", "password"));
+ ConnectionInfo.Timeout = TimeSpan.FromSeconds(20);
+ _keyExchangeAlgorithm = Random.Next().ToString(CultureInfo.InvariantCulture);
+ SessionId = new byte[10];
+ Random.NextBytes(SessionId);
+ DisconnectedRegister = new List();
+ DisconnectReceivedRegister = new List>();
+ ErrorOccurredRegister = new List();
+ ServerBytesReceivedRegister = new List();
+
+ _serviceFactoryMock = new Mock(MockBehavior.Strict);
+ _keyExchangeMock = new Mock(MockBehavior.Strict);
+ _clientAuthenticationMock = new Mock(MockBehavior.Strict);
+
+ Session = new Session(ConnectionInfo, _serviceFactoryMock.Object);
+ Session.Disconnected += (sender, args) => DisconnectedRegister.Add(args);
+ Session.DisconnectReceived += (sender, args) => DisconnectReceivedRegister.Add(args);
+ Session.ErrorOccured += (sender, args) => ErrorOccurredRegister.Add(args);
+ Session.KeyExchangeInitReceived += (sender, args) =>
+ {
+ var newKeysMessage = new NewKeysMessage();
+ var newKeys = newKeysMessage.GetPacket(8, null);
+ ServerSocket.Send(newKeys, 4, newKeys.Length - 4, SocketFlags.None);
+ };
+
+ _serviceFactoryMock.Setup(
+ p =>
+ p.CreateKeyExchange(ConnectionInfo.KeyExchangeAlgorithms, new[] {_keyExchangeAlgorithm})).Returns(_keyExchangeMock.Object);
+ _keyExchangeMock.Setup(p => p.Name).Returns(_keyExchangeAlgorithm);
+ _keyExchangeMock.Setup(p => p.Start(Session, It.IsAny()));
+ _keyExchangeMock.Setup(p => p.ExchangeHash).Returns(SessionId);
+ _keyExchangeMock.Setup(p => p.CreateServerCipher()).Returns((Cipher) null);
+ _keyExchangeMock.Setup(p => p.CreateClientCipher()).Returns((Cipher) null);
+ _keyExchangeMock.Setup(p => p.CreateServerHash()).Returns((HashAlgorithm) null);
+ _keyExchangeMock.Setup(p => p.CreateClientHash()).Returns((HashAlgorithm) null);
+ _keyExchangeMock.Setup(p => p.CreateCompressor()).Returns((Compressor) null);
+ _keyExchangeMock.Setup(p => p.CreateDecompressor()).Returns((Compressor) null);
+ _keyExchangeMock.Setup(p => p.Dispose());
+ _serviceFactoryMock.Setup(p => p.CreateClientAuthentication()).Callback(ClientAuthentication_Callback).Returns(_clientAuthenticationMock.Object);
+ _clientAuthenticationMock.Setup(p => p.Authenticate(ConnectionInfo, Session));
+
+ ServerListener = new AsyncSocketListener(_serverEndPoint);
+ ServerListener.Connected += socket =>
+ {
+ ServerSocket = socket;
+
+ socket.Send(Encoding.ASCII.GetBytes("\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("SSH-2.0-SshStub\r\n"));
+ };
+
+ var counter = 0;
+
+ ServerListener.BytesReceived += (received, socket) =>
+ {
+ ServerBytesReceivedRegister.Add(received);
+
+ switch (counter++)
+ {
+ case 0:
+ var keyExchangeInitMessage = new KeyExchangeInitMessage
+ {
+ CompressionAlgorithmsClientToServer = new string[0],
+ CompressionAlgorithmsServerToClient = new string[0],
+ EncryptionAlgorithmsClientToServer = new string[0],
+ EncryptionAlgorithmsServerToClient = new string[0],
+ KeyExchangeAlgorithms = new[] {_keyExchangeAlgorithm},
+ LanguagesClientToServer = new string[0],
+ LanguagesServerToClient = new string[0],
+ MacAlgorithmsClientToServer = new string[0],
+ MacAlgorithmsServerToClient = new string[0],
+ ServerHostKeyAlgorithms = new string[0]
+ };
+ var keyExchangeInit = keyExchangeInitMessage.GetPacket(8, null);
+ ServerSocket.Send(keyExchangeInit, 4, keyExchangeInit.Length - 4, SocketFlags.None);
+ break;
+ case 1:
+ var serviceAcceptMessage =
+ ServiceAcceptMessageBuilder.Create(ServiceName.UserAuthentication)
+ .Build();
+ ServerSocket.Send(serviceAcceptMessage, 0, serviceAcceptMessage.Length, SocketFlags.None);
+ break;
+ }
+ };
+ ServerListener.Start();
+
+ Session.Connect();
+ }
+
+ protected virtual void ClientAuthentication_Callback()
+ {
+ }
+
+ protected abstract void Act();
+
+ private class ServiceAcceptMessageBuilder
+ {
+ private readonly ServiceName _serviceName;
+
+ private ServiceAcceptMessageBuilder(ServiceName serviceName)
+ {
+ _serviceName = serviceName;
+ }
+
+ public static ServiceAcceptMessageBuilder Create(ServiceName serviceName)
+ {
+ return new ServiceAcceptMessageBuilder(serviceName);
+ }
+
+ public byte[] Build()
+ {
+ var serviceName = _serviceName.ToArray();
+
+ var sshDataStream = new SshDataStream(4 + 1 + 1 + 4 + serviceName.Length);
+ sshDataStream.Write((uint)(sshDataStream.Capacity - 4)); // packet length
+ sshDataStream.WriteByte(0); // padding length
+ sshDataStream.WriteByte(ServiceAcceptMessage.MessageNumber);
+ sshDataStream.WriteBinary(serviceName);
+ return sshDataStream.ToArray();
+ }
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ConnectionReset.cs b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ConnectionReset.cs
index bd94eba1..6587a710 100644
--- a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ConnectionReset.cs
+++ b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ConnectionReset.cs
@@ -1,168 +1,168 @@
-using System.Diagnostics;
-using System.Net.Sockets;
-using System.Threading;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Messages.Transport;
-
-namespace Renci.SshNet.Tests.Classes
-{
- [TestClass]
- public class SessionTest_Connected_ConnectionReset : SessionTest_ConnectedBase
- {
- protected override void Act()
- {
- ServerSocket.Close();
-
- // give session some time to react to connection reset
- Thread.Sleep(200);
- }
-
- [TestMethodAttribute]
- public void IsConnectedShouldReturnFalse()
- {
- Assert.IsFalse(Session.IsConnected);
- }
-
- [TestMethodAttribute]
- public void DisconnectShouldFinishImmediately()
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- Session.Disconnect();
-
- stopwatch.Stop();
- Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
- }
-
- [TestMethod]
- public void DisconnectedIsNeverRaised()
- {
- Assert.AreEqual(0, DisconnectedRegister.Count);
- }
-
- [TestMethod]
- public void DisconnectReceivedIsNeverRaised()
- {
- Assert.AreEqual(0, DisconnectReceivedRegister.Count);
- }
-
- [TestMethod]
- public void ErrorOccurredIsRaisedOnce()
- {
- Assert.AreEqual(1, ErrorOccurredRegister.Count);
-
- var errorOccurred = ErrorOccurredRegister[0];
- Assert.IsNotNull(errorOccurred);
-
- var exception = errorOccurred.Exception;
- Assert.IsNotNull(exception);
- Assert.AreEqual(typeof(SshConnectionException), exception.GetType());
-
- var connectionException = (SshConnectionException) exception;
- Assert.AreEqual(DisconnectReason.ConnectionLost, connectionException.DisconnectReason);
-
- var innerException = exception.InnerException;
- Assert.IsNotNull(innerException);
- Assert.AreEqual(typeof(SocketException), innerException.GetType());
-
- var socketException = (SocketException) innerException;
- Assert.AreEqual(SocketError.ConnectionReset, socketException.SocketErrorCode);
-
- Assert.AreSame(innerException.Message, connectionException.Message);
- }
-
- [TestMethodAttribute]
- public void DisposeShouldFinishImmediately()
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- Session.Dispose();
-
- stopwatch.Stop();
- Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
- }
-
- [TestMethodAttribute]
- public void SendMessageShouldThrowSshConnectionException()
- {
- try
- {
- Session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethodAttribute]
- public void ISession_MessageListenerCompletedShouldBeSignaled()
- {
- var session = (ISession) Session;
-
- Assert.IsNotNull(session.MessageListenerCompleted);
- Assert.IsTrue(session.MessageListenerCompleted.WaitOne());
- }
-
- [TestMethodAttribute]
- public void ISession_SendMessageShouldThrowSshConnectionException()
- {
- var session = (ISession) Session;
-
- try
- {
- session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethodAttribute]
- public void ISession_TrySendMessageShouldReturnFalse()
- {
- var session = (ISession) Session;
-
- var actual = session.TrySendMessage(new IgnoreMessage());
-
- Assert.IsFalse(actual);
- }
-
- [TestMethodAttribute]
- public void ISession_WaitOnHandleShouldThrowSshConnectionExceptionDetailingConnectionReset()
- {
- var session = (ISession) Session;
- var waitHandle = new ManualResetEvent(false);
-
- try
- {
- session.WaitOnHandle(waitHandle);
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.ConnectionLost, ex.DisconnectReason);
-
- var innerException = ex.InnerException;
- Assert.IsNotNull(innerException);
- Assert.AreEqual(typeof(SocketException), innerException.GetType());
-
- var socketException = (SocketException)ex.InnerException;
- Assert.AreEqual(SocketError.ConnectionReset, socketException.SocketErrorCode);
-
- Assert.AreSame(innerException.Message, ex.Message);
-
- }
- }
- }
-}
+using System.Diagnostics;
+using System.Net.Sockets;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Transport;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ [TestClass]
+ public class SessionTest_Connected_ConnectionReset : SessionTest_ConnectedBase
+ {
+ protected override void Act()
+ {
+ ServerSocket.Close();
+
+ // give session some time to react to connection reset
+ Thread.Sleep(200);
+ }
+
+ [TestMethodAttribute]
+ public void IsConnectedShouldReturnFalse()
+ {
+ Assert.IsFalse(Session.IsConnected);
+ }
+
+ [TestMethodAttribute]
+ public void DisconnectShouldFinishImmediately()
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ Session.Disconnect();
+
+ stopwatch.Stop();
+ Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
+ }
+
+ [TestMethod]
+ public void DisconnectedIsNeverRaised()
+ {
+ Assert.AreEqual(0, DisconnectedRegister.Count);
+ }
+
+ [TestMethod]
+ public void DisconnectReceivedIsNeverRaised()
+ {
+ Assert.AreEqual(0, DisconnectReceivedRegister.Count);
+ }
+
+ [TestMethod]
+ public void ErrorOccurredIsRaisedOnce()
+ {
+ Assert.AreEqual(1, ErrorOccurredRegister.Count);
+
+ var errorOccurred = ErrorOccurredRegister[0];
+ Assert.IsNotNull(errorOccurred);
+
+ var exception = errorOccurred.Exception;
+ Assert.IsNotNull(exception);
+ Assert.AreEqual(typeof(SshConnectionException), exception.GetType());
+
+ var connectionException = (SshConnectionException) exception;
+ Assert.AreEqual(DisconnectReason.ConnectionLost, connectionException.DisconnectReason);
+
+ var innerException = exception.InnerException;
+ Assert.IsNotNull(innerException);
+ Assert.AreEqual(typeof(SocketException), innerException.GetType());
+
+ var socketException = (SocketException) innerException;
+ Assert.AreEqual(SocketError.ConnectionReset, socketException.SocketErrorCode);
+
+ Assert.AreSame(innerException.Message, connectionException.Message);
+ }
+
+ [TestMethodAttribute]
+ public void DisposeShouldFinishImmediately()
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ Session.Dispose();
+
+ stopwatch.Stop();
+ Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
+ }
+
+ [TestMethodAttribute]
+ public void SendMessageShouldThrowSshConnectionException()
+ {
+ try
+ {
+ Session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethodAttribute]
+ public void ISession_MessageListenerCompletedShouldBeSignaled()
+ {
+ var session = (ISession) Session;
+
+ Assert.IsNotNull(session.MessageListenerCompleted);
+ Assert.IsTrue(session.MessageListenerCompleted.WaitOne());
+ }
+
+ [TestMethodAttribute]
+ public void ISession_SendMessageShouldThrowSshConnectionException()
+ {
+ var session = (ISession) Session;
+
+ try
+ {
+ session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethodAttribute]
+ public void ISession_TrySendMessageShouldReturnFalse()
+ {
+ var session = (ISession) Session;
+
+ var actual = session.TrySendMessage(new IgnoreMessage());
+
+ Assert.IsFalse(actual);
+ }
+
+ [TestMethodAttribute]
+ public void ISession_WaitOnHandleShouldThrowSshConnectionExceptionDetailingConnectionReset()
+ {
+ var session = (ISession) Session;
+ var waitHandle = new ManualResetEvent(false);
+
+ try
+ {
+ session.WaitOnHandle(waitHandle);
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.ConnectionLost, ex.DisconnectReason);
+
+ var innerException = ex.InnerException;
+ Assert.IsNotNull(innerException);
+ Assert.AreEqual(typeof(SocketException), innerException.GetType());
+
+ var socketException = (SocketException)ex.InnerException;
+ Assert.AreEqual(SocketError.ConnectionReset, socketException.SocketErrorCode);
+
+ Assert.AreSame(innerException.Message, ex.Message);
+
+ }
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_Disconnect.cs b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_Disconnect.cs
index 99f676f7..cf2827cc 100644
--- a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_Disconnect.cs
+++ b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_Disconnect.cs
@@ -1,148 +1,148 @@
-using System.Diagnostics;
-using System.Net.Sockets;
-using System.Threading;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Messages.Transport;
-
-namespace Renci.SshNet.Tests.Classes
-{
- [TestClass]
- public class SessionTest_Connected_Disconnect : SessionTest_ConnectedBase
- {
- protected override void Act()
- {
- Session.Disconnect();
- }
-
- [TestMethod]
- public void IsConnectedShouldReturnFalse()
- {
- Assert.IsFalse(Session.IsConnected);
- }
-
- [TestMethod]
- public void DisconnectShouldFinishImmediately()
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- Session.Disconnect();
-
- stopwatch.Stop();
- Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
- }
-
- [TestMethod]
- public void DisconnectedIsNeverRaised()
- {
- Assert.AreEqual(0, DisconnectedRegister.Count);
- }
-
- [TestMethod]
- public void DisconnectReceivedIsNeverRaised()
- {
- Assert.AreEqual(0, DisconnectReceivedRegister.Count);
- }
-
- [TestMethod]
- public void ErrorOccurredIsNeverRaised()
- {
- Assert.AreEqual(0, ErrorOccurredRegister.Count);
- }
-
- [TestMethod]
- public void DisposeShouldFinishImmediately()
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- Session.Dispose();
-
- stopwatch.Stop();
- Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
- }
-
- [TestMethod]
- public void ReceiveOnServerSocketShouldReturnZero()
- {
- var buffer = new byte[1];
-
- var actual = ServerSocket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
-
- Assert.AreEqual(0, actual);
- }
-
- [TestMethod]
- public void SendMessageShouldThrowSshConnectionException()
- {
- try
- {
- Session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethod]
- public void ISession_MessageListenerCompletedShouldBeSignaled()
- {
- var session = (ISession)Session;
-
- Assert.IsNotNull(session.MessageListenerCompleted);
- Assert.IsTrue(session.MessageListenerCompleted.WaitOne());
- }
-
- [TestMethodAttribute]
- public void ISession_SendMessageShouldThrowSshConnectionException()
- {
- var session = (ISession) Session;
-
- try
- {
- session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethod]
- public void ISession_TrySendMessageShouldReturnFalse()
- {
- var session = (ISession) Session;
-
- var actual = session.TrySendMessage(new IgnoreMessage());
-
- Assert.IsFalse(actual);
- }
-
- [TestMethod]
- public void ISession_WaitOnHandleShouldThrowSshConnectionExceptionDetailingBadPacket()
- {
- var session = (ISession) Session;
- var waitHandle = new ManualResetEvent(false);
-
- try
- {
- session.WaitOnHandle(waitHandle);
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
- }
-}
+using System.Diagnostics;
+using System.Net.Sockets;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Transport;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ [TestClass]
+ public class SessionTest_Connected_Disconnect : SessionTest_ConnectedBase
+ {
+ protected override void Act()
+ {
+ Session.Disconnect();
+ }
+
+ [TestMethod]
+ public void IsConnectedShouldReturnFalse()
+ {
+ Assert.IsFalse(Session.IsConnected);
+ }
+
+ [TestMethod]
+ public void DisconnectShouldFinishImmediately()
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ Session.Disconnect();
+
+ stopwatch.Stop();
+ Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
+ }
+
+ [TestMethod]
+ public void DisconnectedIsNeverRaised()
+ {
+ Assert.AreEqual(0, DisconnectedRegister.Count);
+ }
+
+ [TestMethod]
+ public void DisconnectReceivedIsNeverRaised()
+ {
+ Assert.AreEqual(0, DisconnectReceivedRegister.Count);
+ }
+
+ [TestMethod]
+ public void ErrorOccurredIsNeverRaised()
+ {
+ Assert.AreEqual(0, ErrorOccurredRegister.Count);
+ }
+
+ [TestMethod]
+ public void DisposeShouldFinishImmediately()
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ Session.Dispose();
+
+ stopwatch.Stop();
+ Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
+ }
+
+ [TestMethod]
+ public void ReceiveOnServerSocketShouldReturnZero()
+ {
+ var buffer = new byte[1];
+
+ var actual = ServerSocket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
+
+ Assert.AreEqual(0, actual);
+ }
+
+ [TestMethod]
+ public void SendMessageShouldThrowSshConnectionException()
+ {
+ try
+ {
+ Session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_MessageListenerCompletedShouldBeSignaled()
+ {
+ var session = (ISession)Session;
+
+ Assert.IsNotNull(session.MessageListenerCompleted);
+ Assert.IsTrue(session.MessageListenerCompleted.WaitOne());
+ }
+
+ [TestMethodAttribute]
+ public void ISession_SendMessageShouldThrowSshConnectionException()
+ {
+ var session = (ISession) Session;
+
+ try
+ {
+ session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_TrySendMessageShouldReturnFalse()
+ {
+ var session = (ISession) Session;
+
+ var actual = session.TrySendMessage(new IgnoreMessage());
+
+ Assert.IsFalse(actual);
+ }
+
+ [TestMethod]
+ public void ISession_WaitOnHandleShouldThrowSshConnectionExceptionDetailingBadPacket()
+ {
+ var session = (ISession) Session;
+ var waitHandle = new ManualResetEvent(false);
+
+ try
+ {
+ session.WaitOnHandle(waitHandle);
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsBadPacket.cs b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsBadPacket.cs
index 6b29f75f..b55f87c4 100644
--- a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsBadPacket.cs
+++ b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsBadPacket.cs
@@ -1,164 +1,164 @@
-using System.Diagnostics;
-using System.Net.Sockets;
-using System.Threading;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Messages.Transport;
-
-namespace Renci.SshNet.Tests.Classes
-{
- [TestClass]
- public class SessionTest_Connected_ServerSendsBadPacket : SessionTest_ConnectedBase
- {
- protected override void Act()
- {
- var badPacket = new byte[] { 0x0a, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05 };
- ServerSocket.Send(badPacket, 0, badPacket.Length, SocketFlags.None);
-
- // give session some time to react to bad packet
- Thread.Sleep(200);
- }
-
- [TestMethod]
- public void IsConnectedShouldReturnFalse()
- {
- Assert.IsFalse(Session.IsConnected);
- }
-
- [TestMethod]
- public void DisconnectShouldFinishImmediately()
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- Session.Disconnect();
-
- stopwatch.Stop();
- Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
- }
-
- [TestMethod]
- public void DisconnectedIsNeverRaised()
- {
- Assert.AreEqual(0, DisconnectedRegister.Count);
- }
-
- [TestMethod]
- public void DisconnectReceivedIsNeverRaised()
- {
- Assert.AreEqual(0, DisconnectReceivedRegister.Count);
- }
-
- [TestMethod]
- public void ErrorOccurredIsRaisedOnce()
- {
- Assert.AreEqual(1, ErrorOccurredRegister.Count);
-
- var errorOccurred = ErrorOccurredRegister[0];
- Assert.IsNotNull(errorOccurred);
-
- var exception = errorOccurred.Exception;
- Assert.IsNotNull(exception);
- Assert.AreEqual(typeof (SshConnectionException), exception.GetType());
-
- var connectionException = (SshConnectionException) exception;
- Assert.AreEqual(DisconnectReason.ProtocolError, connectionException.DisconnectReason);
- Assert.IsNull(connectionException.InnerException);
- Assert.AreEqual("Bad packet length: 168101125.", connectionException.Message);
- }
-
- [TestMethod]
- public void DisposeShouldFinishImmediately()
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- Session.Dispose();
-
- stopwatch.Stop();
- Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
- }
-
- [TestMethod]
- public void ReceiveOnServerSocketShouldReturnZero()
- {
- var buffer = new byte[1];
-
- var actual = ServerSocket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
-
- Assert.AreEqual(0, actual);
- }
-
- [TestMethod]
- public void SendMessageShouldThrowSshConnectionException()
- {
- try
- {
- Session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethod]
- public void ISession_MessageListenerCompletedShouldBeSignaled()
- {
- var session = (ISession)Session;
-
- Assert.IsNotNull(session.MessageListenerCompleted);
- Assert.IsTrue(session.MessageListenerCompleted.WaitOne());
- }
-
- [TestMethodAttribute]
- public void ISession_SendMessageShouldThrowSshConnectionException()
- {
- var session = (ISession) Session;
-
- try
- {
- session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethod]
- public void ISession_TrySendMessageShouldReturnFalse()
- {
- var session = (ISession) Session;
-
- var actual = session.TrySendMessage(new IgnoreMessage());
-
- Assert.IsFalse(actual);
- }
-
- [TestMethod]
- public void ISession_WaitOnHandleShouldThrowSshConnectionExceptionDetailingBadPacket()
- {
- var session = (ISession) Session;
- var waitHandle = new ManualResetEvent(false);
-
- try
- {
- session.WaitOnHandle(waitHandle);
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.ProtocolError, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Bad packet length: 168101125.", ex.Message);
- }
- }
- }
-}
+using System.Diagnostics;
+using System.Net.Sockets;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Transport;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ [TestClass]
+ public class SessionTest_Connected_ServerSendsBadPacket : SessionTest_ConnectedBase
+ {
+ protected override void Act()
+ {
+ var badPacket = new byte[] { 0x0a, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05 };
+ ServerSocket.Send(badPacket, 0, badPacket.Length, SocketFlags.None);
+
+ // give session some time to react to bad packet
+ Thread.Sleep(200);
+ }
+
+ [TestMethod]
+ public void IsConnectedShouldReturnFalse()
+ {
+ Assert.IsFalse(Session.IsConnected);
+ }
+
+ [TestMethod]
+ public void DisconnectShouldFinishImmediately()
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ Session.Disconnect();
+
+ stopwatch.Stop();
+ Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
+ }
+
+ [TestMethod]
+ public void DisconnectedIsNeverRaised()
+ {
+ Assert.AreEqual(0, DisconnectedRegister.Count);
+ }
+
+ [TestMethod]
+ public void DisconnectReceivedIsNeverRaised()
+ {
+ Assert.AreEqual(0, DisconnectReceivedRegister.Count);
+ }
+
+ [TestMethod]
+ public void ErrorOccurredIsRaisedOnce()
+ {
+ Assert.AreEqual(1, ErrorOccurredRegister.Count);
+
+ var errorOccurred = ErrorOccurredRegister[0];
+ Assert.IsNotNull(errorOccurred);
+
+ var exception = errorOccurred.Exception;
+ Assert.IsNotNull(exception);
+ Assert.AreEqual(typeof (SshConnectionException), exception.GetType());
+
+ var connectionException = (SshConnectionException) exception;
+ Assert.AreEqual(DisconnectReason.ProtocolError, connectionException.DisconnectReason);
+ Assert.IsNull(connectionException.InnerException);
+ Assert.AreEqual("Bad packet length: 168101125.", connectionException.Message);
+ }
+
+ [TestMethod]
+ public void DisposeShouldFinishImmediately()
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ Session.Dispose();
+
+ stopwatch.Stop();
+ Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
+ }
+
+ [TestMethod]
+ public void ReceiveOnServerSocketShouldReturnZero()
+ {
+ var buffer = new byte[1];
+
+ var actual = ServerSocket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
+
+ Assert.AreEqual(0, actual);
+ }
+
+ [TestMethod]
+ public void SendMessageShouldThrowSshConnectionException()
+ {
+ try
+ {
+ Session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_MessageListenerCompletedShouldBeSignaled()
+ {
+ var session = (ISession)Session;
+
+ Assert.IsNotNull(session.MessageListenerCompleted);
+ Assert.IsTrue(session.MessageListenerCompleted.WaitOne());
+ }
+
+ [TestMethodAttribute]
+ public void ISession_SendMessageShouldThrowSshConnectionException()
+ {
+ var session = (ISession) Session;
+
+ try
+ {
+ session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_TrySendMessageShouldReturnFalse()
+ {
+ var session = (ISession) Session;
+
+ var actual = session.TrySendMessage(new IgnoreMessage());
+
+ Assert.IsFalse(actual);
+ }
+
+ [TestMethod]
+ public void ISession_WaitOnHandleShouldThrowSshConnectionExceptionDetailingBadPacket()
+ {
+ var session = (ISession) Session;
+ var waitHandle = new ManualResetEvent(false);
+
+ try
+ {
+ session.WaitOnHandle(waitHandle);
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.ProtocolError, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Bad packet length: 168101125.", ex.Message);
+ }
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessage.cs b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessage.cs
index 4a69acbd..c47b444e 100644
--- a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessage.cs
+++ b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessage.cs
@@ -1,168 +1,168 @@
-using System.Diagnostics;
-using System.Globalization;
-using System.Net.Sockets;
-using System.Threading;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Messages.Transport;
-
-namespace Renci.SshNet.Tests.Classes
-{
- [TestClass]
- public class SessionTest_Connected_ServerSendsDisconnectMessage : SessionTest_ConnectedBase
- {
- private DisconnectMessage _disconnectMessage;
-
- protected override void Arrange()
- {
- _disconnectMessage = new DisconnectMessage(DisconnectReason.ServiceNotAvailable, "Not today!");
-
- base.Arrange();
- }
-
- protected override void Act()
- {
- var disconnect = _disconnectMessage.GetPacket(8, null);
- ServerSocket.Send(disconnect, 4, disconnect.Length - 4, SocketFlags.None);
-
- // give session some time to process DisconnectMessage
- Thread.Sleep(200);
- }
-
- [TestMethod]
- public void IsConnectedShouldReturnFalse()
- {
- Assert.IsFalse(Session.IsConnected);
- }
-
- [TestMethod]
- public void DisconnectShouldFinishImmediately()
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- Session.Disconnect();
-
- stopwatch.Stop();
- Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
- }
-
- [TestMethod]
- public void DisconnectedIsRaisedOnce()
- {
- Assert.AreEqual(1, DisconnectedRegister.Count);
- }
-
- [TestMethod]
- public void DisconnectReceivedIsRaisedOnce()
- {
- Assert.AreEqual(1, DisconnectReceivedRegister.Count);
-
- var disconnectMessage = DisconnectReceivedRegister[0].Message;
- Assert.IsNotNull(disconnectMessage);
- Assert.AreEqual(_disconnectMessage.Description, disconnectMessage.Description);
- Assert.AreEqual("en", disconnectMessage.Language);
- Assert.AreEqual(_disconnectMessage.ReasonCode, disconnectMessage.ReasonCode);
- }
-
- [TestMethod]
- public void ErrorOccurredIsNeverRaised()
- {
- Assert.AreEqual(0, ErrorOccurredRegister.Count);
- }
-
- [TestMethod]
- public void DisposeShouldFinishImmediately()
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- Session.Dispose();
-
- stopwatch.Stop();
- Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
- }
-
- [TestMethod]
- public void ReceiveOnServerSocketShouldReturnZero()
- {
- var buffer = new byte[1];
-
- var actual = ServerSocket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
-
- Assert.AreEqual(0, actual);
- }
-
- [TestMethod]
- public void SendMessageShouldThrowSshConnectionException()
- {
- try
- {
- Session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethod]
- public void ISession_MessageListenerCompletedShouldBeSignaled()
- {
- var session = (ISession)Session;
-
- Assert.IsNotNull(session.MessageListenerCompleted);
- Assert.IsTrue(session.MessageListenerCompleted.WaitOne());
- }
-
- [TestMethodAttribute]
- public void ISession_SendMessageShouldThrowSshConnectionException()
- {
- var session = (ISession) Session;
-
- try
- {
- session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethod]
- public void ISession_TrySendMessageShouldReturnFalse()
- {
- var session = (ISession) Session;
-
- var actual = session.TrySendMessage(new IgnoreMessage());
-
- Assert.IsFalse(actual);
- }
-
- [TestMethod]
- public void ISession_WaitOnHandleShouldThrowSshConnectionExceptionDetailingDisconnectReason()
- {
- var session = (ISession)Session;
- var waitHandle = new ManualResetEvent(false);
-
- try
- {
- session.WaitOnHandle(waitHandle);
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.ServiceNotAvailable, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "The connection was closed by the server: {0} ({1}).", _disconnectMessage.Description, _disconnectMessage.ReasonCode), ex.Message);
- }
- }
- }
-}
+using System.Diagnostics;
+using System.Globalization;
+using System.Net.Sockets;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Transport;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ [TestClass]
+ public class SessionTest_Connected_ServerSendsDisconnectMessage : SessionTest_ConnectedBase
+ {
+ private DisconnectMessage _disconnectMessage;
+
+ protected override void Arrange()
+ {
+ _disconnectMessage = new DisconnectMessage(DisconnectReason.ServiceNotAvailable, "Not today!");
+
+ base.Arrange();
+ }
+
+ protected override void Act()
+ {
+ var disconnect = _disconnectMessage.GetPacket(8, null);
+ ServerSocket.Send(disconnect, 4, disconnect.Length - 4, SocketFlags.None);
+
+ // give session some time to process DisconnectMessage
+ Thread.Sleep(200);
+ }
+
+ [TestMethod]
+ public void IsConnectedShouldReturnFalse()
+ {
+ Assert.IsFalse(Session.IsConnected);
+ }
+
+ [TestMethod]
+ public void DisconnectShouldFinishImmediately()
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ Session.Disconnect();
+
+ stopwatch.Stop();
+ Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
+ }
+
+ [TestMethod]
+ public void DisconnectedIsRaisedOnce()
+ {
+ Assert.AreEqual(1, DisconnectedRegister.Count);
+ }
+
+ [TestMethod]
+ public void DisconnectReceivedIsRaisedOnce()
+ {
+ Assert.AreEqual(1, DisconnectReceivedRegister.Count);
+
+ var disconnectMessage = DisconnectReceivedRegister[0].Message;
+ Assert.IsNotNull(disconnectMessage);
+ Assert.AreEqual(_disconnectMessage.Description, disconnectMessage.Description);
+ Assert.AreEqual("en", disconnectMessage.Language);
+ Assert.AreEqual(_disconnectMessage.ReasonCode, disconnectMessage.ReasonCode);
+ }
+
+ [TestMethod]
+ public void ErrorOccurredIsNeverRaised()
+ {
+ Assert.AreEqual(0, ErrorOccurredRegister.Count);
+ }
+
+ [TestMethod]
+ public void DisposeShouldFinishImmediately()
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ Session.Dispose();
+
+ stopwatch.Stop();
+ Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
+ }
+
+ [TestMethod]
+ public void ReceiveOnServerSocketShouldReturnZero()
+ {
+ var buffer = new byte[1];
+
+ var actual = ServerSocket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
+
+ Assert.AreEqual(0, actual);
+ }
+
+ [TestMethod]
+ public void SendMessageShouldThrowSshConnectionException()
+ {
+ try
+ {
+ Session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_MessageListenerCompletedShouldBeSignaled()
+ {
+ var session = (ISession)Session;
+
+ Assert.IsNotNull(session.MessageListenerCompleted);
+ Assert.IsTrue(session.MessageListenerCompleted.WaitOne());
+ }
+
+ [TestMethodAttribute]
+ public void ISession_SendMessageShouldThrowSshConnectionException()
+ {
+ var session = (ISession) Session;
+
+ try
+ {
+ session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_TrySendMessageShouldReturnFalse()
+ {
+ var session = (ISession) Session;
+
+ var actual = session.TrySendMessage(new IgnoreMessage());
+
+ Assert.IsFalse(actual);
+ }
+
+ [TestMethod]
+ public void ISession_WaitOnHandleShouldThrowSshConnectionExceptionDetailingDisconnectReason()
+ {
+ var session = (ISession)Session;
+ var waitHandle = new ManualResetEvent(false);
+
+ try
+ {
+ session.WaitOnHandle(waitHandle);
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.ServiceNotAvailable, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "The connection was closed by the server: {0} ({1}).", _disconnectMessage.Description, _disconnectMessage.ReasonCode), ex.Message);
+ }
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessageAndShutsDownSocket.cs b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessageAndShutsDownSocket.cs
index b1e073c9..f6c9152f 100644
--- a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessageAndShutsDownSocket.cs
+++ b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessageAndShutsDownSocket.cs
@@ -1,172 +1,172 @@
-using System.Diagnostics;
-using System.Globalization;
-using System.Net.Sockets;
-using System.Threading;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Messages.Transport;
-
-namespace Renci.SshNet.Tests.Classes
-{
- [TestClass]
- public class SessionTest_Connected_ServerSendsDisconnectMessageAndShutsDownSocket : SessionTest_ConnectedBase
- {
- private DisconnectMessage _disconnectMessage;
-
- protected override void Arrange()
- {
- _disconnectMessage = new DisconnectMessage(DisconnectReason.ServiceNotAvailable, "Not today!");
-
- base.Arrange();
- }
-
- protected override void Act()
- {
- // server sends SSH_MSG_DISCONNECT
- var disconnect = _disconnectMessage.GetPacket(8, null);
- ServerSocket.Send(disconnect, 4, disconnect.Length - 4, SocketFlags.None);
-
- // server shuts down the socket
- ServerSocket.Shutdown(SocketShutdown.Send);
-
- // give session some time to process DisconnectMessage and socket shutdown
- Thread.Sleep(200);
- }
-
- [TestMethod]
- public void IsConnectedShouldReturnFalse()
- {
- Assert.IsFalse(Session.IsConnected);
- }
-
- [TestMethod]
- public void DisconnectShouldFinishImmediately()
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- Session.Disconnect();
-
- stopwatch.Stop();
- Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
- }
-
- [TestMethod]
- public void DisconnectedIsRaisedOnce()
- {
- Assert.AreEqual(1, DisconnectedRegister.Count);
- }
-
- [TestMethod]
- public void DisconnectReceivedIsRaisedOnce()
- {
- Assert.AreEqual(1, DisconnectReceivedRegister.Count);
-
- var disconnectMessage = DisconnectReceivedRegister[0].Message;
- Assert.IsNotNull(disconnectMessage);
- Assert.AreEqual(_disconnectMessage.Description, disconnectMessage.Description);
- Assert.AreEqual("en", disconnectMessage.Language);
- Assert.AreEqual(_disconnectMessage.ReasonCode, disconnectMessage.ReasonCode);
- }
-
- [TestMethod]
- public void ErrorOccurredIsNeverRaised()
- {
- Assert.AreEqual(0, ErrorOccurredRegister.Count);
- }
-
- [TestMethod]
- public void DisposeShouldFinishImmediately()
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- Session.Dispose();
-
- stopwatch.Stop();
- Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
- }
-
- [TestMethod]
- public void ReceiveOnServerSocketShouldReturnZero()
- {
- var buffer = new byte[1];
-
- var actual = ServerSocket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
-
- Assert.AreEqual(0, actual);
- }
-
- [TestMethod]
- public void SendMessageShouldThrowSshConnectionException()
- {
- try
- {
- Session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethod]
- public void ISession_MessageListenerCompletedShouldBeSignaled()
- {
- var session = (ISession)Session;
-
- Assert.IsNotNull(session.MessageListenerCompleted);
- Assert.IsTrue(session.MessageListenerCompleted.WaitOne());
- }
-
- [TestMethodAttribute]
- public void ISession_SendMessageShouldThrowSshConnectionException()
- {
- var session = (ISession) Session;
-
- try
- {
- session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethod]
- public void ISession_TrySendMessageShouldReturnFalse()
- {
- var session = (ISession)Session;
-
- var actual = session.TrySendMessage(new IgnoreMessage());
-
- Assert.IsFalse(actual);
- }
-
- [TestMethod]
- public void ISession_WaitOnHandleShouldThrowSshConnectionExceptionDetailingDisconnectReason()
- {
- var session = (ISession)Session;
- var waitHandle = new ManualResetEvent(false);
-
- try
- {
- session.WaitOnHandle(waitHandle);
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.ServiceNotAvailable, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "The connection was closed by the server: {0} ({1}).", _disconnectMessage.Description, _disconnectMessage.ReasonCode), ex.Message);
- }
- }
- }
-}
+using System.Diagnostics;
+using System.Globalization;
+using System.Net.Sockets;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Transport;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ [TestClass]
+ public class SessionTest_Connected_ServerSendsDisconnectMessageAndShutsDownSocket : SessionTest_ConnectedBase
+ {
+ private DisconnectMessage _disconnectMessage;
+
+ protected override void Arrange()
+ {
+ _disconnectMessage = new DisconnectMessage(DisconnectReason.ServiceNotAvailable, "Not today!");
+
+ base.Arrange();
+ }
+
+ protected override void Act()
+ {
+ // server sends SSH_MSG_DISCONNECT
+ var disconnect = _disconnectMessage.GetPacket(8, null);
+ ServerSocket.Send(disconnect, 4, disconnect.Length - 4, SocketFlags.None);
+
+ // server shuts down the socket
+ ServerSocket.Shutdown(SocketShutdown.Send);
+
+ // give session some time to process DisconnectMessage and socket shutdown
+ Thread.Sleep(200);
+ }
+
+ [TestMethod]
+ public void IsConnectedShouldReturnFalse()
+ {
+ Assert.IsFalse(Session.IsConnected);
+ }
+
+ [TestMethod]
+ public void DisconnectShouldFinishImmediately()
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ Session.Disconnect();
+
+ stopwatch.Stop();
+ Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
+ }
+
+ [TestMethod]
+ public void DisconnectedIsRaisedOnce()
+ {
+ Assert.AreEqual(1, DisconnectedRegister.Count);
+ }
+
+ [TestMethod]
+ public void DisconnectReceivedIsRaisedOnce()
+ {
+ Assert.AreEqual(1, DisconnectReceivedRegister.Count);
+
+ var disconnectMessage = DisconnectReceivedRegister[0].Message;
+ Assert.IsNotNull(disconnectMessage);
+ Assert.AreEqual(_disconnectMessage.Description, disconnectMessage.Description);
+ Assert.AreEqual("en", disconnectMessage.Language);
+ Assert.AreEqual(_disconnectMessage.ReasonCode, disconnectMessage.ReasonCode);
+ }
+
+ [TestMethod]
+ public void ErrorOccurredIsNeverRaised()
+ {
+ Assert.AreEqual(0, ErrorOccurredRegister.Count);
+ }
+
+ [TestMethod]
+ public void DisposeShouldFinishImmediately()
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ Session.Dispose();
+
+ stopwatch.Stop();
+ Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
+ }
+
+ [TestMethod]
+ public void ReceiveOnServerSocketShouldReturnZero()
+ {
+ var buffer = new byte[1];
+
+ var actual = ServerSocket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
+
+ Assert.AreEqual(0, actual);
+ }
+
+ [TestMethod]
+ public void SendMessageShouldThrowSshConnectionException()
+ {
+ try
+ {
+ Session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_MessageListenerCompletedShouldBeSignaled()
+ {
+ var session = (ISession)Session;
+
+ Assert.IsNotNull(session.MessageListenerCompleted);
+ Assert.IsTrue(session.MessageListenerCompleted.WaitOne());
+ }
+
+ [TestMethodAttribute]
+ public void ISession_SendMessageShouldThrowSshConnectionException()
+ {
+ var session = (ISession) Session;
+
+ try
+ {
+ session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_TrySendMessageShouldReturnFalse()
+ {
+ var session = (ISession)Session;
+
+ var actual = session.TrySendMessage(new IgnoreMessage());
+
+ Assert.IsFalse(actual);
+ }
+
+ [TestMethod]
+ public void ISession_WaitOnHandleShouldThrowSshConnectionExceptionDetailingDisconnectReason()
+ {
+ var session = (ISession)Session;
+ var waitHandle = new ManualResetEvent(false);
+
+ try
+ {
+ session.WaitOnHandle(waitHandle);
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.ServiceNotAvailable, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "The connection was closed by the server: {0} ({1}).", _disconnectMessage.Description, _disconnectMessage.ReasonCode), ex.Message);
+ }
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerShutsDownSocket.cs b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerShutsDownSocket.cs
index a7a7867c..fd6755f4 100644
--- a/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerShutsDownSocket.cs
+++ b/src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerShutsDownSocket.cs
@@ -1,161 +1,161 @@
-using System;
-using System.Diagnostics;
-using System.Net.Sockets;
-using System.Threading;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Messages.Transport;
-
-namespace Renci.SshNet.Tests.Classes
-{
- [TestClass]
- public class SessionTest_Connected_ServerShutsDownSocket : SessionTest_ConnectedBase
- {
- protected override void Act()
- {
- ServerSocket.Shutdown(SocketShutdown.Send);
-
- // give session some time to process socket shutdown
- Thread.Sleep(200);
- }
-
- [TestMethod]
- public void IsConnectedShouldReturnFalse()
- {
- Assert.IsFalse(Session.IsConnected);
- }
-
- [TestMethod]
- public void DisconnectShouldFinishImmediately()
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- Session.Disconnect();
-
- stopwatch.Stop();
- Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
- }
-
- [TestMethod]
- public void DisconnectedIsNeverRaised()
- {
- Assert.AreEqual(0, DisconnectedRegister.Count);
- }
-
- [TestMethod]
- public void DisconnectReceivedIsNeverRaised()
- {
- Assert.AreEqual(0, DisconnectReceivedRegister.Count);
- }
-
- [TestMethod]
- public void ErrorOccurredIsRaisedOnce()
- {
- Assert.AreEqual(1, ErrorOccurredRegister.Count);
-
- var errorOccurred = ErrorOccurredRegister[0];
- Assert.IsNotNull(errorOccurred);
-
- var exception = errorOccurred.Exception;
- Assert.IsNotNull(exception);
- Assert.AreEqual(typeof(SshConnectionException), exception.GetType());
-
- var connectionException = (SshConnectionException) exception;
- Assert.AreEqual(DisconnectReason.ConnectionLost, connectionException.DisconnectReason);
- Assert.IsNull(connectionException.InnerException);
- Assert.AreEqual("An established connection was aborted by the server.", connectionException.Message);
- }
-
- [TestMethod]
- public void DisposeShouldFinishImmediately()
- {
- var stopwatch = new Stopwatch();
- stopwatch.Start();
-
- Session.Dispose();
-
- stopwatch.Stop();
- Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
- }
-
- [TestMethod]
- public void ReceiveOnServerSocketShouldReturnZero()
- {
- var buffer = new byte[1];
-
- var actual = ServerSocket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
-
- Assert.AreEqual(0, actual);
- }
-
- [TestMethod]
- public void SendMessageShouldThrowSshConnectionException()
- {
- try
- {
- Session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethod]
- public void ISession_MessageListenerCompletedShouldBeSignaled()
- {
- var session = (ISession)Session;
-
- Assert.IsNotNull(session.MessageListenerCompleted);
- Assert.IsTrue(session.MessageListenerCompleted.WaitOne());
- }
-
- [TestMethodAttribute]
- public void ISession_SendMessageShouldThrowSshConnectionException()
- {
- var session = (ISession) Session;
-
- try
- {
- session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethod]
- public void ISession_TrySendMessageShouldReturnFalse()
- {
- var session = (ISession)Session;
-
- var actual = session.TrySendMessage(new IgnoreMessage());
-
- Assert.IsFalse(actual);
- }
-
- [TestMethod]
- public void ISession_WaitOnHandleShouldThrowSshConnectionExceptionDetailingAbortedConnection()
- {
- var session = (ISession)Session;
- var waitHandle = new ManualResetEvent(false);
-
- try
- {
- session.WaitOnHandle(waitHandle);
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("An established connection was aborted by the server.", ex.Message);
- }
- }
- }
-}
+using System;
+using System.Diagnostics;
+using System.Net.Sockets;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Transport;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ [TestClass]
+ public class SessionTest_Connected_ServerShutsDownSocket : SessionTest_ConnectedBase
+ {
+ protected override void Act()
+ {
+ ServerSocket.Shutdown(SocketShutdown.Send);
+
+ // give session some time to process socket shutdown
+ Thread.Sleep(200);
+ }
+
+ [TestMethod]
+ public void IsConnectedShouldReturnFalse()
+ {
+ Assert.IsFalse(Session.IsConnected);
+ }
+
+ [TestMethod]
+ public void DisconnectShouldFinishImmediately()
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ Session.Disconnect();
+
+ stopwatch.Stop();
+ Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
+ }
+
+ [TestMethod]
+ public void DisconnectedIsNeverRaised()
+ {
+ Assert.AreEqual(0, DisconnectedRegister.Count);
+ }
+
+ [TestMethod]
+ public void DisconnectReceivedIsNeverRaised()
+ {
+ Assert.AreEqual(0, DisconnectReceivedRegister.Count);
+ }
+
+ [TestMethod]
+ public void ErrorOccurredIsRaisedOnce()
+ {
+ Assert.AreEqual(1, ErrorOccurredRegister.Count);
+
+ var errorOccurred = ErrorOccurredRegister[0];
+ Assert.IsNotNull(errorOccurred);
+
+ var exception = errorOccurred.Exception;
+ Assert.IsNotNull(exception);
+ Assert.AreEqual(typeof(SshConnectionException), exception.GetType());
+
+ var connectionException = (SshConnectionException) exception;
+ Assert.AreEqual(DisconnectReason.ConnectionLost, connectionException.DisconnectReason);
+ Assert.IsNull(connectionException.InnerException);
+ Assert.AreEqual("An established connection was aborted by the server.", connectionException.Message);
+ }
+
+ [TestMethod]
+ public void DisposeShouldFinishImmediately()
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+
+ Session.Dispose();
+
+ stopwatch.Stop();
+ Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500);
+ }
+
+ [TestMethod]
+ public void ReceiveOnServerSocketShouldReturnZero()
+ {
+ var buffer = new byte[1];
+
+ var actual = ServerSocket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
+
+ Assert.AreEqual(0, actual);
+ }
+
+ [TestMethod]
+ public void SendMessageShouldThrowSshConnectionException()
+ {
+ try
+ {
+ Session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_MessageListenerCompletedShouldBeSignaled()
+ {
+ var session = (ISession)Session;
+
+ Assert.IsNotNull(session.MessageListenerCompleted);
+ Assert.IsTrue(session.MessageListenerCompleted.WaitOne());
+ }
+
+ [TestMethodAttribute]
+ public void ISession_SendMessageShouldThrowSshConnectionException()
+ {
+ var session = (ISession) Session;
+
+ try
+ {
+ session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_TrySendMessageShouldReturnFalse()
+ {
+ var session = (ISession)Session;
+
+ var actual = session.TrySendMessage(new IgnoreMessage());
+
+ Assert.IsFalse(actual);
+ }
+
+ [TestMethod]
+ public void ISession_WaitOnHandleShouldThrowSshConnectionExceptionDetailingAbortedConnection()
+ {
+ var session = (ISession)Session;
+ var waitHandle = new ManualResetEvent(false);
+
+ try
+ {
+ session.WaitOnHandle(waitHandle);
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("An established connection was aborted by the server.", ex.Message);
+ }
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest_NotConnected.cs b/src/Renci.SshNet.Tests/Classes/SessionTest_NotConnected.cs
index 44cbd7d6..4638b698 100644
--- a/src/Renci.SshNet.Tests/Classes/SessionTest_NotConnected.cs
+++ b/src/Renci.SshNet.Tests/Classes/SessionTest_NotConnected.cs
@@ -1,191 +1,191 @@
-using System;
-using System.Net;
-using System.Threading;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Moq;
-using Renci.SshNet.Common;
-using Renci.SshNet.Messages.Transport;
-
-namespace Renci.SshNet.Tests.Classes
-{
- [TestClass]
- public class SessionTest_NotConnected
- {
- private ConnectionInfo _connectionInfo;
- private IServiceFactory _serviceFactory;
- private Session _session;
-
- [TestInitialize]
- public void Setup()
- {
- Arrange();
- Act();
- }
-
- protected void Arrange()
- {
- var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
- _connectionInfo = CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5));
- _serviceFactory = new Mock(MockBehavior.Strict).Object;
- }
-
- protected void Act()
- {
- _session = new Session(_connectionInfo, _serviceFactory);
- }
-
- [TestMethod]
- public void ClientVersionIsRenciSshNet()
- {
- Assert.AreEqual("SSH-2.0-Renci.SshNet.SshClient.0.0.1", _session.ClientVersion);
- }
-
- [TestMethod]
- public void ConnectionInfoShouldReturnConnectionInfoPassedThroughConstructor()
- {
- Assert.AreSame(_connectionInfo, _session.ConnectionInfo);
- }
-
- [TestMethod]
- public void IsConnectedShouldReturnFalse()
- {
- Assert.IsFalse(_session.IsConnected);
- }
-
- [TestMethod]
- public void SendMessageShouldThrowShhConnectionException()
- {
- try
- {
- _session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethod]
- public void SessionIdShouldReturnNull()
- {
- Assert.IsNull(_session.SessionId);
- }
-
- [TestMethod]
- public void ServerVersionShouldReturnNull()
- {
- Assert.IsNull(_session.ServerVersion);
- }
-
- [TestMethod]
- public void WaitOnHandle_WaitHandle_ShouldThrowArgumentNullExceptionWhenWaitHandleIsNull()
- {
- WaitHandle waitHandle = null;
-
- try
- {
- _session.WaitOnHandle(waitHandle);
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("waitHandle", ex.ParamName);
- }
- }
-
- [TestMethod]
- public void WaitOnHandle_WaitHandleAndTimeout_ShouldThrowArgumentNullExceptionWhenWaitHandleIsNull()
- {
- WaitHandle waitHandle = null;
- var timeout = TimeSpan.FromMinutes(5);
-
- try
- {
- _session.WaitOnHandle(waitHandle, timeout);
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("waitHandle", ex.ParamName);
- }
- }
-
- [TestMethod]
- public void ISession_ConnectionInfoShouldReturnConnectionInfoPassedThroughConstructor()
- {
- var session = (ISession)_session;
- Assert.AreSame(_connectionInfo, session.ConnectionInfo);
- }
-
- [TestMethod]
- public void ISession_MessageListenerCompletedShouldBeSignaled()
- {
- var session = (ISession) _session;
-
- Assert.IsNotNull(session.MessageListenerCompleted);
- Assert.IsTrue(session.MessageListenerCompleted.WaitOne(0));
- }
-
- [TestMethod]
- public void ISession_SendMessageShouldThrowShhConnectionException()
- {
- var session = (ISession)_session;
-
- try
- {
- session.SendMessage(new IgnoreMessage());
- Assert.Fail();
- }
- catch (SshConnectionException ex)
- {
- Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("Client not connected.", ex.Message);
- }
- }
-
- [TestMethod]
- public void ISession_TrySendMessageShouldReturnFalse()
- {
- var session = (ISession)_session;
-
- var actual = session.TrySendMessage(new IgnoreMessage());
-
- Assert.IsFalse(actual);
- }
-
- [TestMethod]
- public void ISession_WaitOnHandleShouldThrowArgumentNullExceptionWhenWaitHandleIsNull()
- {
- WaitHandle waitHandle = null;
- var session = (ISession)_session;
-
- try
- {
- session.WaitOnHandle(waitHandle);
- Assert.Fail();
- }
- catch (ArgumentNullException ex)
- {
- Assert.IsNull(ex.InnerException);
- Assert.AreEqual("waitHandle", ex.ParamName);
- }
- }
-
- private static ConnectionInfo CreateConnectionInfo(IPEndPoint serverEndPoint, TimeSpan timeout)
- {
- var connectionInfo = new ConnectionInfo(
- serverEndPoint.Address.ToString(),
- serverEndPoint.Port,
- "eric",
- new NoneAuthenticationMethod("eric"));
- connectionInfo.Timeout = timeout;
- return connectionInfo;
- }
- }
-}
+using System;
+using System.Net;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Transport;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ [TestClass]
+ public class SessionTest_NotConnected
+ {
+ private ConnectionInfo _connectionInfo;
+ private IServiceFactory _serviceFactory;
+ private Session _session;
+
+ [TestInitialize]
+ public void Setup()
+ {
+ Arrange();
+ Act();
+ }
+
+ protected void Arrange()
+ {
+ var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+ _connectionInfo = CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5));
+ _serviceFactory = new Mock(MockBehavior.Strict).Object;
+ }
+
+ protected void Act()
+ {
+ _session = new Session(_connectionInfo, _serviceFactory);
+ }
+
+ [TestMethod]
+ public void ClientVersionIsRenciSshNet()
+ {
+ Assert.AreEqual("SSH-2.0-Renci.SshNet.SshClient.0.0.1", _session.ClientVersion);
+ }
+
+ [TestMethod]
+ public void ConnectionInfoShouldReturnConnectionInfoPassedThroughConstructor()
+ {
+ Assert.AreSame(_connectionInfo, _session.ConnectionInfo);
+ }
+
+ [TestMethod]
+ public void IsConnectedShouldReturnFalse()
+ {
+ Assert.IsFalse(_session.IsConnected);
+ }
+
+ [TestMethod]
+ public void SendMessageShouldThrowShhConnectionException()
+ {
+ try
+ {
+ _session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethod]
+ public void SessionIdShouldReturnNull()
+ {
+ Assert.IsNull(_session.SessionId);
+ }
+
+ [TestMethod]
+ public void ServerVersionShouldReturnNull()
+ {
+ Assert.IsNull(_session.ServerVersion);
+ }
+
+ [TestMethod]
+ public void WaitOnHandle_WaitHandle_ShouldThrowArgumentNullExceptionWhenWaitHandleIsNull()
+ {
+ WaitHandle waitHandle = null;
+
+ try
+ {
+ _session.WaitOnHandle(waitHandle);
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("waitHandle", ex.ParamName);
+ }
+ }
+
+ [TestMethod]
+ public void WaitOnHandle_WaitHandleAndTimeout_ShouldThrowArgumentNullExceptionWhenWaitHandleIsNull()
+ {
+ WaitHandle waitHandle = null;
+ var timeout = TimeSpan.FromMinutes(5);
+
+ try
+ {
+ _session.WaitOnHandle(waitHandle, timeout);
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("waitHandle", ex.ParamName);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_ConnectionInfoShouldReturnConnectionInfoPassedThroughConstructor()
+ {
+ var session = (ISession)_session;
+ Assert.AreSame(_connectionInfo, session.ConnectionInfo);
+ }
+
+ [TestMethod]
+ public void ISession_MessageListenerCompletedShouldBeSignaled()
+ {
+ var session = (ISession) _session;
+
+ Assert.IsNotNull(session.MessageListenerCompleted);
+ Assert.IsTrue(session.MessageListenerCompleted.WaitOne(0));
+ }
+
+ [TestMethod]
+ public void ISession_SendMessageShouldThrowShhConnectionException()
+ {
+ var session = (ISession)_session;
+
+ try
+ {
+ session.SendMessage(new IgnoreMessage());
+ Assert.Fail();
+ }
+ catch (SshConnectionException ex)
+ {
+ Assert.AreEqual(DisconnectReason.None, ex.DisconnectReason);
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("Client not connected.", ex.Message);
+ }
+ }
+
+ [TestMethod]
+ public void ISession_TrySendMessageShouldReturnFalse()
+ {
+ var session = (ISession)_session;
+
+ var actual = session.TrySendMessage(new IgnoreMessage());
+
+ Assert.IsFalse(actual);
+ }
+
+ [TestMethod]
+ public void ISession_WaitOnHandleShouldThrowArgumentNullExceptionWhenWaitHandleIsNull()
+ {
+ WaitHandle waitHandle = null;
+ var session = (ISession)_session;
+
+ try
+ {
+ session.WaitOnHandle(waitHandle);
+ Assert.Fail();
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.IsNull(ex.InnerException);
+ Assert.AreEqual("waitHandle", ex.ParamName);
+ }
+ }
+
+ private static ConnectionInfo CreateConnectionInfo(IPEndPoint serverEndPoint, TimeSpan timeout)
+ {
+ var connectionInfo = new ConnectionInfo(
+ serverEndPoint.Address.ToString(),
+ serverEndPoint.Port,
+ "eric",
+ new NoneAuthenticationMethod("eric"));
+ connectionInfo.Timeout = timeout;
+ return connectionInfo;
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest_SocketConnected_BadPacketAndDispose.cs b/src/Renci.SshNet.Tests/Classes/SessionTest_SocketConnected_BadPacketAndDispose.cs
index 985e5087..a13de281 100644
--- a/src/Renci.SshNet.Tests/Classes/SessionTest_SocketConnected_BadPacketAndDispose.cs
+++ b/src/Renci.SshNet.Tests/Classes/SessionTest_SocketConnected_BadPacketAndDispose.cs
@@ -1,95 +1,95 @@
-using System;
-using System.Net;
-using System.Net.Sockets;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Moq;
-using Renci.SshNet.Common;
-using Renci.SshNet.Messages.Transport;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes
-{
- [TestClass]
- public class SessionTest_SocketConnected_BadPacketAndDispose
- {
- private Mock _serviceFactoryMock;
- private ConnectionInfo _connectionInfo;
- private Session _session;
- private AsyncSocketListener _serverListener;
- private IPEndPoint _serverEndPoint;
- private Socket _serverSocket;
- private SshConnectionException _actualException;
-
- [TestInitialize]
- public void Setup()
- {
- Arrange();
- Act();
- }
-
- [TestCleanup]
- public void TearDown()
- {
- if (_serverListener != null)
- {
- _serverListener.Dispose();
- }
- }
-
- protected void Arrange()
- {
- _serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
- _connectionInfo = new ConnectionInfo(
- _serverEndPoint.Address.ToString(),
- _serverEndPoint.Port,
- "user",
- new PasswordAuthenticationMethod("user", "password"));
- _connectionInfo.Timeout = TimeSpan.FromMilliseconds(200);
- _actualException = null;
-
- _serviceFactoryMock = new Mock(MockBehavior.Strict);
-
- _serverListener = new AsyncSocketListener(_serverEndPoint);
- _serverListener.Connected += (socket) =>
- {
- _serverSocket = socket;
-
- socket.Send(Encoding.ASCII.GetBytes("\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
- socket.Send(Encoding.ASCII.GetBytes("SSH-2.0-SshStub\r\n"));
- };
- _serverListener.BytesReceived += (received, socket) =>
- {
- var badPacket = new byte[] {0x0a, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05};
- _serverSocket.Send(badPacket, 0, badPacket.Length, SocketFlags.None);
- _serverSocket.Shutdown(SocketShutdown.Send);
- };
- _serverListener.Start();
- }
-
- protected virtual void Act()
- {
- try
- {
- using (_session = new Session(_connectionInfo, _serviceFactoryMock.Object))
- {
- _session.Connect();
- }
- }
- catch (SshConnectionException ex)
- {
- _actualException = ex;
- }
- }
-
- [TestMethod]
- public void ConnectShouldThrowSshConnectionException()
- {
- Assert.IsNotNull(_actualException);
- Assert.IsNull(_actualException.InnerException);
- Assert.AreEqual(DisconnectReason.ProtocolError, _actualException.DisconnectReason);
- Assert.AreEqual("Bad packet length: 168101125.", _actualException.Message);
- }
- }
-}
+using System;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Transport;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes
+{
+ [TestClass]
+ public class SessionTest_SocketConnected_BadPacketAndDispose
+ {
+ private Mock _serviceFactoryMock;
+ private ConnectionInfo _connectionInfo;
+ private Session _session;
+ private AsyncSocketListener _serverListener;
+ private IPEndPoint _serverEndPoint;
+ private Socket _serverSocket;
+ private SshConnectionException _actualException;
+
+ [TestInitialize]
+ public void Setup()
+ {
+ Arrange();
+ Act();
+ }
+
+ [TestCleanup]
+ public void TearDown()
+ {
+ if (_serverListener != null)
+ {
+ _serverListener.Dispose();
+ }
+ }
+
+ protected void Arrange()
+ {
+ _serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+ _connectionInfo = new ConnectionInfo(
+ _serverEndPoint.Address.ToString(),
+ _serverEndPoint.Port,
+ "user",
+ new PasswordAuthenticationMethod("user", "password"));
+ _connectionInfo.Timeout = TimeSpan.FromMilliseconds(200);
+ _actualException = null;
+
+ _serviceFactoryMock = new Mock(MockBehavior.Strict);
+
+ _serverListener = new AsyncSocketListener(_serverEndPoint);
+ _serverListener.Connected += (socket) =>
+ {
+ _serverSocket = socket;
+
+ socket.Send(Encoding.ASCII.GetBytes("\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
+ socket.Send(Encoding.ASCII.GetBytes("SSH-2.0-SshStub\r\n"));
+ };
+ _serverListener.BytesReceived += (received, socket) =>
+ {
+ var badPacket = new byte[] {0x0a, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05};
+ _serverSocket.Send(badPacket, 0, badPacket.Length, SocketFlags.None);
+ _serverSocket.Shutdown(SocketShutdown.Send);
+ };
+ _serverListener.Start();
+ }
+
+ protected virtual void Act()
+ {
+ try
+ {
+ using (_session = new Session(_connectionInfo, _serviceFactoryMock.Object))
+ {
+ _session.Connect();
+ }
+ }
+ catch (SshConnectionException ex)
+ {
+ _actualException = ex;
+ }
+ }
+
+ [TestMethod]
+ public void ConnectShouldThrowSshConnectionException()
+ {
+ Assert.IsNotNull(_actualException);
+ Assert.IsNull(_actualException.InnerException);
+ Assert.AreEqual(DisconnectReason.ProtocolError, _actualException.DisconnectReason);
+ Assert.AreEqual("Bad packet length: 168101125.", _actualException.Message);
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/FStatVfsRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/FStatVfsRequestTest.cs
index ba139e9d..bad627f2 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/FStatVfsRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/FStatVfsRequestTest.cs
@@ -1,123 +1,123 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
-{
- [TestClass]
- public class FStatVfsRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private byte[] _handle;
- private string _name;
- private byte[] _nameBytes;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
- _protocolVersion = (uint)random.Next(0, int.MaxValue);
- _requestId = (uint)random.Next(0, int.MaxValue);
- _handle = new byte[random.Next(1, 10)];
- random.NextBytes(_handle);
-
- _name = "fstatvfs@openssh.com";
- _nameBytes = Encoding.UTF8.GetBytes(_name);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new FStatVfsRequest(_protocolVersion, _requestId, _handle, null, null);
-
- Assert.AreSame(_handle, request.Handle);
- Assert.AreEqual(_name, request.Name);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.Extended, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- IList statusActionInvocations = new List();
- IList extendedReplyActionInvocations = new List();
-
- Action extendedAction = extendedReplyActionInvocations.Add;
- Action statusAction = statusActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new FStatVfsRequest(_protocolVersion, _requestId, _handle, extendedAction, statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- Assert.AreEqual(0, extendedReplyActionInvocations.Count);
- }
-
- [TestMethod]
- public void Complete_SftpExtendedReplyResponse()
- {
- IList statusActionInvocations = new List();
- IList extendedReplyActionInvocations = new List();
-
- Action extendedAction = extendedReplyActionInvocations.Add;
- Action statusAction = statusActionInvocations.Add;
- var extendedReplyResponse = new SftpExtendedReplyResponse(_protocolVersion);
-
- var request = new FStatVfsRequest(_protocolVersion, _requestId, _handle, extendedAction, statusAction);
-
- request.Complete(extendedReplyResponse);
-
- Assert.AreEqual(0, statusActionInvocations.Count);
- Assert.AreEqual(1, extendedReplyActionInvocations.Count);
- Assert.AreSame(extendedReplyResponse, extendedReplyActionInvocations[0]);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new FStatVfsRequest(_protocolVersion, _requestId, _handle, null, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Name length
- expectedBytesLength += _nameBytes.Length; // Name
- expectedBytesLength += 4; // Handle length
- expectedBytesLength += _handle.Length; // Handle
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.Extended, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
- Assert.AreEqual((uint) _nameBytes.Length, sshDataStream.ReadUInt32());
-
- var actualNameBytes = new byte[_nameBytes.Length];
- sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
- Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));
-
- Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
-
- var actualHandle = new byte[_handle.Length];
- sshDataStream.Read(actualHandle, 0, actualHandle.Length);
- Assert.IsTrue(_handle.SequenceEqual(actualHandle));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
+{
+ [TestClass]
+ public class FStatVfsRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private byte[] _handle;
+ private string _name;
+ private byte[] _nameBytes;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+ _protocolVersion = (uint)random.Next(0, int.MaxValue);
+ _requestId = (uint)random.Next(0, int.MaxValue);
+ _handle = new byte[random.Next(1, 10)];
+ random.NextBytes(_handle);
+
+ _name = "fstatvfs@openssh.com";
+ _nameBytes = Encoding.UTF8.GetBytes(_name);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new FStatVfsRequest(_protocolVersion, _requestId, _handle, null, null);
+
+ Assert.AreSame(_handle, request.Handle);
+ Assert.AreEqual(_name, request.Name);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.Extended, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ IList statusActionInvocations = new List();
+ IList extendedReplyActionInvocations = new List();
+
+ Action extendedAction = extendedReplyActionInvocations.Add;
+ Action statusAction = statusActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new FStatVfsRequest(_protocolVersion, _requestId, _handle, extendedAction, statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ Assert.AreEqual(0, extendedReplyActionInvocations.Count);
+ }
+
+ [TestMethod]
+ public void Complete_SftpExtendedReplyResponse()
+ {
+ IList statusActionInvocations = new List();
+ IList extendedReplyActionInvocations = new List();
+
+ Action extendedAction = extendedReplyActionInvocations.Add;
+ Action statusAction = statusActionInvocations.Add;
+ var extendedReplyResponse = new SftpExtendedReplyResponse(_protocolVersion);
+
+ var request = new FStatVfsRequest(_protocolVersion, _requestId, _handle, extendedAction, statusAction);
+
+ request.Complete(extendedReplyResponse);
+
+ Assert.AreEqual(0, statusActionInvocations.Count);
+ Assert.AreEqual(1, extendedReplyActionInvocations.Count);
+ Assert.AreSame(extendedReplyResponse, extendedReplyActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new FStatVfsRequest(_protocolVersion, _requestId, _handle, null, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Name length
+ expectedBytesLength += _nameBytes.Length; // Name
+ expectedBytesLength += 4; // Handle length
+ expectedBytesLength += _handle.Length; // Handle
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.Extended, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+ Assert.AreEqual((uint) _nameBytes.Length, sshDataStream.ReadUInt32());
+
+ var actualNameBytes = new byte[_nameBytes.Length];
+ sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
+ Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));
+
+ Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
+
+ var actualHandle = new byte[_handle.Length];
+ sshDataStream.Read(actualHandle, 0, actualHandle.Length);
+ Assert.IsTrue(_handle.SequenceEqual(actualHandle));
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/HardLinkRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/HardLinkRequestTest.cs
index 8282f52d..787f9904 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/HardLinkRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/HardLinkRequestTest.cs
@@ -1,116 +1,116 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
-{
- [TestClass]
- public class HardLinkRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private string _name;
- private string _oldPath;
- private byte[] _oldPathBytes;
- private string _newPath;
- private byte[] _newPathBytes;
- private byte[] _nameBytes;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
- _protocolVersion = (uint)random.Next(0, int.MaxValue);
- _requestId = (uint)random.Next(0, int.MaxValue);
- _oldPath = random.Next().ToString(CultureInfo.InvariantCulture);
- _oldPathBytes = Encoding.UTF8.GetBytes(_oldPath);
- _newPath = random.Next().ToString(CultureInfo.InvariantCulture);
- _newPathBytes = Encoding.UTF8.GetBytes(_newPath);
-
- _name = "hardlink@openssh.com";
- _nameBytes = Encoding.UTF8.GetBytes(_name);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new HardLinkRequest(_protocolVersion, _requestId, _oldPath, _newPath, null);
-
- Assert.AreEqual(_name, request.Name);
- Assert.AreEqual(_newPath, request.NewPath);
- Assert.AreEqual(_oldPath, request.OldPath);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.Extended, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- IList statusActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new HardLinkRequest(_protocolVersion, _requestId, _oldPath, _newPath, statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new HardLinkRequest(_protocolVersion, _requestId, _oldPath, _newPath, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Name length
- expectedBytesLength += _nameBytes.Length; // Name
- expectedBytesLength += 4; // OldPath length
- expectedBytesLength += _oldPathBytes.Length; // OldPath
- expectedBytesLength += 4; // NewPath length
- expectedBytesLength += _newPathBytes.Length; // NewPath
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.Extended, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
- Assert.AreEqual((uint) _nameBytes.Length, sshDataStream.ReadUInt32());
-
- var actualNameBytes = new byte[_nameBytes.Length];
- sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
- Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));
-
- Assert.AreEqual((uint) _oldPathBytes.Length, sshDataStream.ReadUInt32());
-
- var actualOldPath = new byte[_oldPathBytes.Length];
- sshDataStream.Read(actualOldPath, 0, actualOldPath.Length);
- Assert.IsTrue(_oldPathBytes.SequenceEqual(actualOldPath));
-
- Assert.AreEqual((uint) _newPathBytes.Length, sshDataStream.ReadUInt32());
-
- var actualNewPath = new byte[_newPathBytes.Length];
- sshDataStream.Read(actualNewPath, 0, actualNewPath.Length);
- Assert.IsTrue(_newPathBytes.SequenceEqual(actualNewPath));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
+{
+ [TestClass]
+ public class HardLinkRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private string _name;
+ private string _oldPath;
+ private byte[] _oldPathBytes;
+ private string _newPath;
+ private byte[] _newPathBytes;
+ private byte[] _nameBytes;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+ _protocolVersion = (uint)random.Next(0, int.MaxValue);
+ _requestId = (uint)random.Next(0, int.MaxValue);
+ _oldPath = random.Next().ToString(CultureInfo.InvariantCulture);
+ _oldPathBytes = Encoding.UTF8.GetBytes(_oldPath);
+ _newPath = random.Next().ToString(CultureInfo.InvariantCulture);
+ _newPathBytes = Encoding.UTF8.GetBytes(_newPath);
+
+ _name = "hardlink@openssh.com";
+ _nameBytes = Encoding.UTF8.GetBytes(_name);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new HardLinkRequest(_protocolVersion, _requestId, _oldPath, _newPath, null);
+
+ Assert.AreEqual(_name, request.Name);
+ Assert.AreEqual(_newPath, request.NewPath);
+ Assert.AreEqual(_oldPath, request.OldPath);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.Extended, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ IList statusActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new HardLinkRequest(_protocolVersion, _requestId, _oldPath, _newPath, statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new HardLinkRequest(_protocolVersion, _requestId, _oldPath, _newPath, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Name length
+ expectedBytesLength += _nameBytes.Length; // Name
+ expectedBytesLength += 4; // OldPath length
+ expectedBytesLength += _oldPathBytes.Length; // OldPath
+ expectedBytesLength += 4; // NewPath length
+ expectedBytesLength += _newPathBytes.Length; // NewPath
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.Extended, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+ Assert.AreEqual((uint) _nameBytes.Length, sshDataStream.ReadUInt32());
+
+ var actualNameBytes = new byte[_nameBytes.Length];
+ sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
+ Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));
+
+ Assert.AreEqual((uint) _oldPathBytes.Length, sshDataStream.ReadUInt32());
+
+ var actualOldPath = new byte[_oldPathBytes.Length];
+ sshDataStream.Read(actualOldPath, 0, actualOldPath.Length);
+ Assert.IsTrue(_oldPathBytes.SequenceEqual(actualOldPath));
+
+ Assert.AreEqual((uint) _newPathBytes.Length, sshDataStream.ReadUInt32());
+
+ var actualNewPath = new byte[_newPathBytes.Length];
+ sshDataStream.Read(actualNewPath, 0, actualNewPath.Length);
+ Assert.IsTrue(_newPathBytes.SequenceEqual(actualNewPath));
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/PosixRenameRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/PosixRenameRequestTest.cs
index c9edf3bd..60cc1d03 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/PosixRenameRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/PosixRenameRequestTest.cs
@@ -1,120 +1,120 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
-{
- [TestClass]
- public class PosixRenameRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private string _name;
- private string _oldPath;
- private byte[] _oldPathBytes;
- private string _newPath;
- private byte[] _newPathBytes;
- private byte[] _nameBytes;
- private Encoding _encoding;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _encoding = Encoding.Unicode;
- _protocolVersion = (uint)random.Next(0, int.MaxValue);
- _requestId = (uint)random.Next(0, int.MaxValue);
- _oldPath = random.Next().ToString(CultureInfo.InvariantCulture);
- _oldPathBytes = _encoding.GetBytes(_oldPath);
- _newPath = random.Next().ToString(CultureInfo.InvariantCulture);
- _newPathBytes = _encoding.GetBytes(_newPath);
-
- _name = "posix-rename@openssh.com";
- _nameBytes = Encoding.UTF8.GetBytes(_name);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new PosixRenameRequest(_protocolVersion, _requestId, _oldPath, _newPath, _encoding, null);
-
- Assert.AreSame(_encoding, request.Encoding);
- Assert.AreEqual(_name, request.Name);
- Assert.AreEqual(_newPath, request.NewPath);
- Assert.AreEqual(_oldPath, request.OldPath);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.Extended, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- IList statusActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new PosixRenameRequest(_protocolVersion, _requestId, _oldPath, _newPath, _encoding, statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new PosixRenameRequest(_protocolVersion, _requestId, _oldPath, _newPath, _encoding, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Name length
- expectedBytesLength += _nameBytes.Length; // Name
- expectedBytesLength += 4; // OldPath length
- expectedBytesLength += _oldPathBytes.Length; // OldPath
- expectedBytesLength += 4; // NewPath length
- expectedBytesLength += _newPathBytes.Length; // NewPath
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.Extended, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
- Assert.AreEqual((uint) _nameBytes.Length, sshDataStream.ReadUInt32());
-
- var actualNameBytes = new byte[_nameBytes.Length];
- sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
- Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));
-
- Assert.AreEqual((uint) _oldPathBytes.Length, sshDataStream.ReadUInt32());
-
- var actualOldPath = new byte[_oldPathBytes.Length];
- sshDataStream.Read(actualOldPath, 0, actualOldPath.Length);
- Assert.IsTrue(_oldPathBytes.SequenceEqual(actualOldPath));
-
- Assert.AreEqual((uint) _newPathBytes.Length, sshDataStream.ReadUInt32());
-
- var actualNewPath = new byte[_newPathBytes.Length];
- sshDataStream.Read(actualNewPath, 0, actualNewPath.Length);
- Assert.IsTrue(_newPathBytes.SequenceEqual(actualNewPath));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
+{
+ [TestClass]
+ public class PosixRenameRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private string _name;
+ private string _oldPath;
+ private byte[] _oldPathBytes;
+ private string _newPath;
+ private byte[] _newPathBytes;
+ private byte[] _nameBytes;
+ private Encoding _encoding;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _encoding = Encoding.Unicode;
+ _protocolVersion = (uint)random.Next(0, int.MaxValue);
+ _requestId = (uint)random.Next(0, int.MaxValue);
+ _oldPath = random.Next().ToString(CultureInfo.InvariantCulture);
+ _oldPathBytes = _encoding.GetBytes(_oldPath);
+ _newPath = random.Next().ToString(CultureInfo.InvariantCulture);
+ _newPathBytes = _encoding.GetBytes(_newPath);
+
+ _name = "posix-rename@openssh.com";
+ _nameBytes = Encoding.UTF8.GetBytes(_name);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new PosixRenameRequest(_protocolVersion, _requestId, _oldPath, _newPath, _encoding, null);
+
+ Assert.AreSame(_encoding, request.Encoding);
+ Assert.AreEqual(_name, request.Name);
+ Assert.AreEqual(_newPath, request.NewPath);
+ Assert.AreEqual(_oldPath, request.OldPath);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.Extended, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ IList statusActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new PosixRenameRequest(_protocolVersion, _requestId, _oldPath, _newPath, _encoding, statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new PosixRenameRequest(_protocolVersion, _requestId, _oldPath, _newPath, _encoding, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Name length
+ expectedBytesLength += _nameBytes.Length; // Name
+ expectedBytesLength += 4; // OldPath length
+ expectedBytesLength += _oldPathBytes.Length; // OldPath
+ expectedBytesLength += 4; // NewPath length
+ expectedBytesLength += _newPathBytes.Length; // NewPath
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.Extended, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+ Assert.AreEqual((uint) _nameBytes.Length, sshDataStream.ReadUInt32());
+
+ var actualNameBytes = new byte[_nameBytes.Length];
+ sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
+ Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));
+
+ Assert.AreEqual((uint) _oldPathBytes.Length, sshDataStream.ReadUInt32());
+
+ var actualOldPath = new byte[_oldPathBytes.Length];
+ sshDataStream.Read(actualOldPath, 0, actualOldPath.Length);
+ Assert.IsTrue(_oldPathBytes.SequenceEqual(actualOldPath));
+
+ Assert.AreEqual((uint) _newPathBytes.Length, sshDataStream.ReadUInt32());
+
+ var actualNewPath = new byte[_newPathBytes.Length];
+ sshDataStream.Read(actualNewPath, 0, actualNewPath.Length);
+ Assert.IsTrue(_newPathBytes.SequenceEqual(actualNewPath));
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/StatVfsRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/StatVfsRequestTest.cs
index 5dd1e9a8..89d315f3 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/StatVfsRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/ExtendedRequests/StatVfsRequestTest.cs
@@ -1,129 +1,129 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
-{
- [TestClass]
- public class StatVfsRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private string _name;
- private string _path;
- private byte[] _pathBytes;
- private byte[] _nameBytes;
- private Encoding _encoding;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _encoding = Encoding.Unicode;
- _protocolVersion = (uint)random.Next(0, int.MaxValue);
- _requestId = (uint)random.Next(0, int.MaxValue);
- _path = random.Next().ToString(CultureInfo.InvariantCulture);
- _pathBytes = _encoding.GetBytes(_path);
-
- _name = "statvfs@openssh.com";
- _nameBytes = Encoding.UTF8.GetBytes(_name);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new StatVfsRequest(_protocolVersion, _requestId, _path, _encoding, null, null);
-
- Assert.AreSame(_encoding, request.Encoding);
- Assert.AreEqual(_name, request.Name);
- Assert.AreEqual(_path, request.Path);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.Extended, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- IList statusActionInvocations = new List();
- IList extendedReplyActionInvocations = new List();
-
- Action extendedAction = extendedReplyActionInvocations.Add;
- Action statusAction = statusActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new StatVfsRequest(_protocolVersion, _requestId, _path, _encoding, extendedAction, statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- Assert.AreEqual(0, extendedReplyActionInvocations.Count);
- }
-
- [TestMethod]
- public void Complete_SftpExtendedReplyResponse()
- {
- IList statusActionInvocations = new List();
- IList extendedReplyActionInvocations = new List();
-
- Action extendedAction = extendedReplyActionInvocations.Add;
- Action statusAction = statusActionInvocations.Add;
- var extendedReplyResponse = new SftpExtendedReplyResponse(_protocolVersion);
-
- var request = new StatVfsRequest(_protocolVersion, _requestId, _path, _encoding, extendedAction, statusAction);
-
- request.Complete(extendedReplyResponse);
-
- Assert.AreEqual(0, statusActionInvocations.Count);
- Assert.AreEqual(1, extendedReplyActionInvocations.Count);
- Assert.AreSame(extendedReplyResponse, extendedReplyActionInvocations[0]);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new StatVfsRequest(_protocolVersion, _requestId, _path, _encoding, null, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Name length
- expectedBytesLength += _nameBytes.Length; // Name
- expectedBytesLength += 4; // Path length
- expectedBytesLength += _pathBytes.Length; // Path
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.Extended, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
- Assert.AreEqual((uint) _nameBytes.Length, sshDataStream.ReadUInt32());
-
- var actualNameBytes = new byte[_nameBytes.Length];
- sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
- Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));
-
- Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
-
- var actualPath = new byte[_pathBytes.Length];
- sshDataStream.Read(actualPath, 0, actualPath.Length);
- Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests.ExtendedRequests
+{
+ [TestClass]
+ public class StatVfsRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private string _name;
+ private string _path;
+ private byte[] _pathBytes;
+ private byte[] _nameBytes;
+ private Encoding _encoding;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _encoding = Encoding.Unicode;
+ _protocolVersion = (uint)random.Next(0, int.MaxValue);
+ _requestId = (uint)random.Next(0, int.MaxValue);
+ _path = random.Next().ToString(CultureInfo.InvariantCulture);
+ _pathBytes = _encoding.GetBytes(_path);
+
+ _name = "statvfs@openssh.com";
+ _nameBytes = Encoding.UTF8.GetBytes(_name);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new StatVfsRequest(_protocolVersion, _requestId, _path, _encoding, null, null);
+
+ Assert.AreSame(_encoding, request.Encoding);
+ Assert.AreEqual(_name, request.Name);
+ Assert.AreEqual(_path, request.Path);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.Extended, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ IList statusActionInvocations = new List();
+ IList extendedReplyActionInvocations = new List();
+
+ Action extendedAction = extendedReplyActionInvocations.Add;
+ Action statusAction = statusActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new StatVfsRequest(_protocolVersion, _requestId, _path, _encoding, extendedAction, statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ Assert.AreEqual(0, extendedReplyActionInvocations.Count);
+ }
+
+ [TestMethod]
+ public void Complete_SftpExtendedReplyResponse()
+ {
+ IList statusActionInvocations = new List();
+ IList extendedReplyActionInvocations = new List();
+
+ Action extendedAction = extendedReplyActionInvocations.Add;
+ Action statusAction = statusActionInvocations.Add;
+ var extendedReplyResponse = new SftpExtendedReplyResponse(_protocolVersion);
+
+ var request = new StatVfsRequest(_protocolVersion, _requestId, _path, _encoding, extendedAction, statusAction);
+
+ request.Complete(extendedReplyResponse);
+
+ Assert.AreEqual(0, statusActionInvocations.Count);
+ Assert.AreEqual(1, extendedReplyActionInvocations.Count);
+ Assert.AreSame(extendedReplyResponse, extendedReplyActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new StatVfsRequest(_protocolVersion, _requestId, _path, _encoding, null, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Name length
+ expectedBytesLength += _nameBytes.Length; // Name
+ expectedBytesLength += 4; // Path length
+ expectedBytesLength += _pathBytes.Length; // Path
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.Extended, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+ Assert.AreEqual((uint) _nameBytes.Length, sshDataStream.ReadUInt32());
+
+ var actualNameBytes = new byte[_nameBytes.Length];
+ sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
+ Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));
+
+ Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
+
+ var actualPath = new byte[_pathBytes.Length];
+ sshDataStream.Read(actualPath, 0, actualPath.Length);
+ Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpBlockRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpBlockRequestTest.cs
index a62472ff..22100993 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpBlockRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpBlockRequestTest.cs
@@ -1,102 +1,102 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpBlockRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private byte[] _handle;
- private ulong _offset;
- private ulong _length;
- private uint _lockMask;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _protocolVersion = (uint)random.Next(0, int.MaxValue);
- _requestId = (uint)random.Next(0, int.MaxValue);
- _handle = new byte[random.Next(1, 10)];
- random.NextBytes(_handle);
- _offset = (ulong) random.Next(0, int.MaxValue);
- _length = (ulong) random.Next(0, int.MaxValue);
- _lockMask = (uint) random.Next(0, int.MaxValue);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new SftpBlockRequest(_protocolVersion, _requestId, _handle, _offset, _length, _lockMask, null);
-
- Assert.AreSame(_handle, request.Handle);
- Assert.AreEqual(_length, request.Length);
- Assert.AreEqual(_lockMask, request.LockMask);
- Assert.AreEqual(_offset, request.Offset);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.Block, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- IList statusActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new SftpBlockRequest(_protocolVersion, _requestId, _handle, _offset, _length, _lockMask, statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new SftpBlockRequest(_protocolVersion, _requestId, _handle, _offset, _length, _lockMask, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Handle length
- expectedBytesLength += _handle.Length; // Handle
- expectedBytesLength += 8; // Offset
- expectedBytesLength += 8; // Length
- expectedBytesLength += 4; // LockMask
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.Block, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
-
- Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
- var actualHandle = new byte[_handle.Length];
- sshDataStream.Read(actualHandle, 0, actualHandle.Length);
- Assert.IsTrue(_handle.SequenceEqual(actualHandle));
-
- Assert.AreEqual(_offset, sshDataStream.ReadUInt64());
- Assert.AreEqual(_length, sshDataStream.ReadUInt64());
- Assert.AreEqual(_lockMask, sshDataStream.ReadUInt32());
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpBlockRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private byte[] _handle;
+ private ulong _offset;
+ private ulong _length;
+ private uint _lockMask;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _protocolVersion = (uint)random.Next(0, int.MaxValue);
+ _requestId = (uint)random.Next(0, int.MaxValue);
+ _handle = new byte[random.Next(1, 10)];
+ random.NextBytes(_handle);
+ _offset = (ulong) random.Next(0, int.MaxValue);
+ _length = (ulong) random.Next(0, int.MaxValue);
+ _lockMask = (uint) random.Next(0, int.MaxValue);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new SftpBlockRequest(_protocolVersion, _requestId, _handle, _offset, _length, _lockMask, null);
+
+ Assert.AreSame(_handle, request.Handle);
+ Assert.AreEqual(_length, request.Length);
+ Assert.AreEqual(_lockMask, request.LockMask);
+ Assert.AreEqual(_offset, request.Offset);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.Block, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ IList statusActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new SftpBlockRequest(_protocolVersion, _requestId, _handle, _offset, _length, _lockMask, statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new SftpBlockRequest(_protocolVersion, _requestId, _handle, _offset, _length, _lockMask, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Handle length
+ expectedBytesLength += _handle.Length; // Handle
+ expectedBytesLength += 8; // Offset
+ expectedBytesLength += 8; // Length
+ expectedBytesLength += 4; // LockMask
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.Block, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+
+ Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
+ var actualHandle = new byte[_handle.Length];
+ sshDataStream.Read(actualHandle, 0, actualHandle.Length);
+ Assert.IsTrue(_handle.SequenceEqual(actualHandle));
+
+ Assert.AreEqual(_offset, sshDataStream.ReadUInt64());
+ Assert.AreEqual(_length, sshDataStream.ReadUInt64());
+ Assert.AreEqual(_lockMask, sshDataStream.ReadUInt32());
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpCloseRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpCloseRequestTest.cs
index 8fe79c6f..3959af33 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpCloseRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpCloseRequestTest.cs
@@ -1,87 +1,87 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpCloseRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private byte[] _handle;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _protocolVersion = (uint)random.Next(0, int.MaxValue);
- _requestId = (uint)random.Next(0, int.MaxValue);
- _handle = new byte[random.Next(1, 10)];
- random.NextBytes(_handle);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new SftpCloseRequest(_protocolVersion, _requestId, _handle, null);
-
- Assert.AreSame(_handle, request.Handle);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.Close, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- IList statusActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new SftpCloseRequest(_protocolVersion, _requestId, _handle, statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new SftpCloseRequest(_protocolVersion, _requestId, _handle, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Handle length
- expectedBytesLength += _handle.Length; // Handle
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.Close, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
-
- Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
- var actualHandle = new byte[_handle.Length];
- sshDataStream.Read(actualHandle, 0, actualHandle.Length);
- Assert.IsTrue(_handle.SequenceEqual(actualHandle));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpCloseRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private byte[] _handle;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _protocolVersion = (uint)random.Next(0, int.MaxValue);
+ _requestId = (uint)random.Next(0, int.MaxValue);
+ _handle = new byte[random.Next(1, 10)];
+ random.NextBytes(_handle);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new SftpCloseRequest(_protocolVersion, _requestId, _handle, null);
+
+ Assert.AreSame(_handle, request.Handle);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.Close, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ IList statusActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new SftpCloseRequest(_protocolVersion, _requestId, _handle, statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new SftpCloseRequest(_protocolVersion, _requestId, _handle, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Handle length
+ expectedBytesLength += _handle.Length; // Handle
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.Close, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+
+ Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
+ var actualHandle = new byte[_handle.Length];
+ sshDataStream.Read(actualHandle, 0, actualHandle.Length);
+ Assert.IsTrue(_handle.SequenceEqual(actualHandle));
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpFSetStatRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpFSetStatRequestTest.cs
index 01b81331..a91797ed 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpFSetStatRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpFSetStatRequestTest.cs
@@ -1,96 +1,96 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpFSetStatRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private byte[] _handle;
- private SftpFileAttributes _attributes;
- private byte[] _attributesBytes;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _protocolVersion = (uint)random.Next(0, int.MaxValue);
- _requestId = (uint)random.Next(0, int.MaxValue);
- _handle = new byte[random.Next(1, 10)];
- random.NextBytes(_handle);
- _attributes = SftpFileAttributes.Empty;
- _attributesBytes = _attributes.GetBytes();
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new SftpFSetStatRequest(_protocolVersion, _requestId, _handle, _attributes, null);
-
- Assert.AreSame(_handle, request.Handle);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.FSetStat, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- IList statusActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new SftpFSetStatRequest(_protocolVersion, _requestId, _handle, _attributes, statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new SftpFSetStatRequest(_protocolVersion, _requestId, _handle, _attributes, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Handle length
- expectedBytesLength += _handle.Length; // Handle
- expectedBytesLength += _attributesBytes.Length; // Attributes
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.FSetStat, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
-
- Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
- var actualHandle = new byte[_handle.Length];
- sshDataStream.Read(actualHandle, 0, actualHandle.Length);
- Assert.IsTrue(_handle.SequenceEqual(actualHandle));
-
- var actualAttributes = new byte[_attributesBytes.Length];
- sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
- Assert.IsTrue(_attributesBytes.SequenceEqual(actualAttributes));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpFSetStatRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private byte[] _handle;
+ private SftpFileAttributes _attributes;
+ private byte[] _attributesBytes;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _protocolVersion = (uint)random.Next(0, int.MaxValue);
+ _requestId = (uint)random.Next(0, int.MaxValue);
+ _handle = new byte[random.Next(1, 10)];
+ random.NextBytes(_handle);
+ _attributes = SftpFileAttributes.Empty;
+ _attributesBytes = _attributes.GetBytes();
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new SftpFSetStatRequest(_protocolVersion, _requestId, _handle, _attributes, null);
+
+ Assert.AreSame(_handle, request.Handle);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.FSetStat, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ IList statusActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new SftpFSetStatRequest(_protocolVersion, _requestId, _handle, _attributes, statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new SftpFSetStatRequest(_protocolVersion, _requestId, _handle, _attributes, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Handle length
+ expectedBytesLength += _handle.Length; // Handle
+ expectedBytesLength += _attributesBytes.Length; // Attributes
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.FSetStat, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+
+ Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
+ var actualHandle = new byte[_handle.Length];
+ sshDataStream.Read(actualHandle, 0, actualHandle.Length);
+ Assert.IsTrue(_handle.SequenceEqual(actualHandle));
+
+ var actualAttributes = new byte[_attributesBytes.Length];
+ sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
+ Assert.IsTrue(_attributesBytes.SequenceEqual(actualAttributes));
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpFStatRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpFStatRequestTest.cs
index 5ff1dd04..03cf64a9 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpFStatRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpFStatRequestTest.cs
@@ -1,109 +1,109 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpFStatRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private byte[] _handle;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _protocolVersion = (uint)random.Next(0, int.MaxValue);
- _requestId = (uint)random.Next(0, int.MaxValue);
- _handle = new byte[random.Next(1, 10)];
- random.NextBytes(_handle);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new SftpFStatRequest(_protocolVersion, _requestId, _handle, null, null);
-
- Assert.AreSame(_handle, request.Handle);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.FStat, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpAttrsResponse()
- {
- var statusActionInvocations = new List();
- var attrsActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action attrsAction = attrsActionInvocations.Add;
- var attrsResponse = new SftpAttrsResponse(_protocolVersion);
-
- var request = new SftpFStatRequest(_protocolVersion, _requestId, _handle, attrsAction, statusAction);
-
- request.Complete(attrsResponse);
-
- Assert.AreEqual(0, statusActionInvocations.Count);
- Assert.AreEqual(1, attrsActionInvocations.Count);
- Assert.AreSame(attrsResponse, attrsActionInvocations[0]);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- var statusActionInvocations = new List();
- var attrsActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action attrsAction = attrsActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new SftpFStatRequest(_protocolVersion, _requestId, _handle, attrsAction, statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- Assert.AreEqual(0, attrsActionInvocations.Count);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new SftpFStatRequest(_protocolVersion, _requestId, _handle, null, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Handle length
- expectedBytesLength += _handle.Length; // Handle
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.FStat, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
-
- Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
- var actualHandle = new byte[_handle.Length];
- sshDataStream.Read(actualHandle, 0, actualHandle.Length);
- Assert.IsTrue(_handle.SequenceEqual(actualHandle));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpFStatRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private byte[] _handle;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _protocolVersion = (uint)random.Next(0, int.MaxValue);
+ _requestId = (uint)random.Next(0, int.MaxValue);
+ _handle = new byte[random.Next(1, 10)];
+ random.NextBytes(_handle);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new SftpFStatRequest(_protocolVersion, _requestId, _handle, null, null);
+
+ Assert.AreSame(_handle, request.Handle);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.FStat, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpAttrsResponse()
+ {
+ var statusActionInvocations = new List();
+ var attrsActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action attrsAction = attrsActionInvocations.Add;
+ var attrsResponse = new SftpAttrsResponse(_protocolVersion);
+
+ var request = new SftpFStatRequest(_protocolVersion, _requestId, _handle, attrsAction, statusAction);
+
+ request.Complete(attrsResponse);
+
+ Assert.AreEqual(0, statusActionInvocations.Count);
+ Assert.AreEqual(1, attrsActionInvocations.Count);
+ Assert.AreSame(attrsResponse, attrsActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ var statusActionInvocations = new List();
+ var attrsActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action attrsAction = attrsActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new SftpFStatRequest(_protocolVersion, _requestId, _handle, attrsAction, statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ Assert.AreEqual(0, attrsActionInvocations.Count);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new SftpFStatRequest(_protocolVersion, _requestId, _handle, null, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Handle length
+ expectedBytesLength += _handle.Length; // Handle
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.FStat, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+
+ Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
+ var actualHandle = new byte[_handle.Length];
+ sshDataStream.Read(actualHandle, 0, actualHandle.Length);
+ Assert.IsTrue(_handle.SequenceEqual(actualHandle));
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpInitRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpInitRequestTest.cs
index 704c6982..4f039b1f 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpInitRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpInitRequestTest.cs
@@ -1,10 +1,10 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpInitRequestTest : TestBase
- {
- }
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpInitRequestTest : TestBase
+ {
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpLStatRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpLStatRequestTest.cs
index 878b18a2..08313b05 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpLStatRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpLStatRequestTest.cs
@@ -1,115 +1,115 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpLStatRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private Encoding _encoding;
- private string _path;
- private byte[] _pathBytes;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _encoding = Encoding.Unicode;
- _protocolVersion = (uint) random.Next(0, int.MaxValue);
- _requestId = (uint) random.Next(0, int.MaxValue);
- _path = random.Next().ToString(CultureInfo.InvariantCulture);
- _pathBytes = _encoding.GetBytes(_path);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new SftpLStatRequest(_protocolVersion, _requestId, _path, _encoding, null, null);
-
- Assert.AreSame(_encoding, request.Encoding);
- Assert.AreEqual(_path, request.Path);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.LStat, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpAttrsResponse()
- {
- var statusActionInvocations = new List();
- var attrsActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action attrsAction = attrsActionInvocations.Add;
- var attrsResponse = new SftpAttrsResponse(_protocolVersion);
-
- var request = new SftpLStatRequest(_protocolVersion, _requestId, _path, _encoding, attrsAction, statusAction);
-
- request.Complete(attrsResponse);
-
- Assert.AreEqual(0, statusActionInvocations.Count);
- Assert.AreEqual(1, attrsActionInvocations.Count);
- Assert.AreSame(attrsResponse, attrsActionInvocations[0]);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- var statusActionInvocations = new List();
- var attrsActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action attrsAction = attrsActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new SftpLStatRequest(_protocolVersion, _requestId, _path, _encoding, attrsAction, statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- Assert.AreEqual(0, attrsActionInvocations.Count);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new SftpLStatRequest(_protocolVersion, _requestId, _path, _encoding, null, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Pah length
- expectedBytesLength += _pathBytes.Length; // Path
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.LStat, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
-
- Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
- var actualPath = new byte[_pathBytes.Length];
- sshDataStream.Read(actualPath, 0, actualPath.Length);
- Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpLStatRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private Encoding _encoding;
+ private string _path;
+ private byte[] _pathBytes;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _encoding = Encoding.Unicode;
+ _protocolVersion = (uint) random.Next(0, int.MaxValue);
+ _requestId = (uint) random.Next(0, int.MaxValue);
+ _path = random.Next().ToString(CultureInfo.InvariantCulture);
+ _pathBytes = _encoding.GetBytes(_path);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new SftpLStatRequest(_protocolVersion, _requestId, _path, _encoding, null, null);
+
+ Assert.AreSame(_encoding, request.Encoding);
+ Assert.AreEqual(_path, request.Path);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.LStat, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpAttrsResponse()
+ {
+ var statusActionInvocations = new List();
+ var attrsActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action attrsAction = attrsActionInvocations.Add;
+ var attrsResponse = new SftpAttrsResponse(_protocolVersion);
+
+ var request = new SftpLStatRequest(_protocolVersion, _requestId, _path, _encoding, attrsAction, statusAction);
+
+ request.Complete(attrsResponse);
+
+ Assert.AreEqual(0, statusActionInvocations.Count);
+ Assert.AreEqual(1, attrsActionInvocations.Count);
+ Assert.AreSame(attrsResponse, attrsActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ var statusActionInvocations = new List();
+ var attrsActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action attrsAction = attrsActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new SftpLStatRequest(_protocolVersion, _requestId, _path, _encoding, attrsAction, statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ Assert.AreEqual(0, attrsActionInvocations.Count);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new SftpLStatRequest(_protocolVersion, _requestId, _path, _encoding, null, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Pah length
+ expectedBytesLength += _pathBytes.Length; // Path
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.LStat, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+
+ Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
+ var actualPath = new byte[_pathBytes.Length];
+ sshDataStream.Read(actualPath, 0, actualPath.Length);
+ Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpLinkRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpLinkRequestTest.cs
index 77b94645..eba2f249 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpLinkRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpLinkRequestTest.cs
@@ -1,110 +1,110 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpLinkRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private string _newLinkPath;
- private byte[] _newLinkPathBytes;
- private string _existingPath;
- private byte[] _existingPathBytes;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _protocolVersion = (uint)random.Next(0, int.MaxValue);
- _requestId = (uint)random.Next(0, int.MaxValue);
- _newLinkPath = random.Next().ToString(CultureInfo.InvariantCulture);
- _newLinkPathBytes = Encoding.UTF8.GetBytes(_newLinkPath);
- _existingPath = random.Next().ToString(CultureInfo.InvariantCulture);
- _existingPathBytes = Encoding.UTF8.GetBytes(_existingPath);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new SftpLinkRequest(_protocolVersion, _requestId, _newLinkPath, _existingPath, true, null);
-
- Assert.AreEqual(_existingPath, request.ExistingPath);
- Assert.IsTrue(request.IsSymLink);
- Assert.AreEqual(_newLinkPath, request.NewLinkPath);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.Link, request.SftpMessageType);
-
- request = new SftpLinkRequest(_protocolVersion, _requestId, _newLinkPath, _existingPath, false, null);
-
- Assert.IsFalse(request.IsSymLink);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- var statusActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new SftpLinkRequest(_protocolVersion, _requestId, _newLinkPath, _existingPath, true, statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new SftpLinkRequest(_protocolVersion, _requestId, _newLinkPath, _existingPath, true, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // NewLinkPath length
- expectedBytesLength += _newLinkPathBytes.Length; // NewLinkPath
- expectedBytesLength += 4; // ExistingPath length
- expectedBytesLength += _existingPathBytes.Length; // ExistingPath
- expectedBytesLength += 1; // IsSymLink
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.Link, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
-
- Assert.AreEqual((uint) _newLinkPathBytes.Length, sshDataStream.ReadUInt32());
- var actualNewLinkPath = new byte[_newLinkPathBytes.Length];
- sshDataStream.Read(actualNewLinkPath, 0, actualNewLinkPath.Length);
- Assert.IsTrue(_newLinkPathBytes.SequenceEqual(actualNewLinkPath));
-
- Assert.AreEqual((uint) _existingPathBytes.Length, sshDataStream.ReadUInt32());
- var actualExistingPath = new byte[_existingPathBytes.Length];
- sshDataStream.Read(actualExistingPath, 0, actualExistingPath.Length);
- Assert.IsTrue(_existingPathBytes.SequenceEqual(actualExistingPath));
-
- Assert.AreEqual(1, sshDataStream.ReadByte());
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpLinkRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private string _newLinkPath;
+ private byte[] _newLinkPathBytes;
+ private string _existingPath;
+ private byte[] _existingPathBytes;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _protocolVersion = (uint)random.Next(0, int.MaxValue);
+ _requestId = (uint)random.Next(0, int.MaxValue);
+ _newLinkPath = random.Next().ToString(CultureInfo.InvariantCulture);
+ _newLinkPathBytes = Encoding.UTF8.GetBytes(_newLinkPath);
+ _existingPath = random.Next().ToString(CultureInfo.InvariantCulture);
+ _existingPathBytes = Encoding.UTF8.GetBytes(_existingPath);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new SftpLinkRequest(_protocolVersion, _requestId, _newLinkPath, _existingPath, true, null);
+
+ Assert.AreEqual(_existingPath, request.ExistingPath);
+ Assert.IsTrue(request.IsSymLink);
+ Assert.AreEqual(_newLinkPath, request.NewLinkPath);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.Link, request.SftpMessageType);
+
+ request = new SftpLinkRequest(_protocolVersion, _requestId, _newLinkPath, _existingPath, false, null);
+
+ Assert.IsFalse(request.IsSymLink);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ var statusActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new SftpLinkRequest(_protocolVersion, _requestId, _newLinkPath, _existingPath, true, statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new SftpLinkRequest(_protocolVersion, _requestId, _newLinkPath, _existingPath, true, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // NewLinkPath length
+ expectedBytesLength += _newLinkPathBytes.Length; // NewLinkPath
+ expectedBytesLength += 4; // ExistingPath length
+ expectedBytesLength += _existingPathBytes.Length; // ExistingPath
+ expectedBytesLength += 1; // IsSymLink
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.Link, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+
+ Assert.AreEqual((uint) _newLinkPathBytes.Length, sshDataStream.ReadUInt32());
+ var actualNewLinkPath = new byte[_newLinkPathBytes.Length];
+ sshDataStream.Read(actualNewLinkPath, 0, actualNewLinkPath.Length);
+ Assert.IsTrue(_newLinkPathBytes.SequenceEqual(actualNewLinkPath));
+
+ Assert.AreEqual((uint) _existingPathBytes.Length, sshDataStream.ReadUInt32());
+ var actualExistingPath = new byte[_existingPathBytes.Length];
+ sshDataStream.Read(actualExistingPath, 0, actualExistingPath.Length);
+ Assert.IsTrue(_existingPathBytes.SequenceEqual(actualExistingPath));
+
+ Assert.AreEqual(1, sshDataStream.ReadByte());
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpMkDirRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpMkDirRequestTest.cs
index e3bed2fb..d8a3a9eb 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpMkDirRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpMkDirRequestTest.cs
@@ -1,102 +1,102 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpMkDirRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private Encoding _encoding;
- private string _path;
- private byte[] _pathBytes;
- private SftpFileAttributes _attributes;
- private byte[] _attributesBytes;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _protocolVersion = (uint) random.Next(0, int.MaxValue);
- _requestId = (uint) random.Next(0, int.MaxValue);
- _encoding = Encoding.Unicode;
- _path = random.Next().ToString(CultureInfo.InvariantCulture);
- _pathBytes = _encoding.GetBytes(_path);
- _attributes = SftpFileAttributes.Empty;
- _attributesBytes = _attributes.GetBytes();
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new SftpMkDirRequest(_protocolVersion, _requestId, _path, _encoding, null);
-
- Assert.AreSame(_encoding, request.Encoding);
- Assert.AreEqual(_path, request.Path);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.MkDir, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- var statusActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new SftpMkDirRequest(_protocolVersion, _requestId, _path, _encoding, statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new SftpMkDirRequest(_protocolVersion, _requestId, _path, _encoding, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Path length
- expectedBytesLength += _pathBytes.Length; // Path
- expectedBytesLength += _attributesBytes.Length; // Attributes
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.MkDir, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
-
- Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
- var actualPath = new byte[_pathBytes.Length];
- sshDataStream.Read(actualPath, 0, actualPath.Length);
- Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));
-
- var actualAttributes = new byte[_attributesBytes.Length];
- sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
- Assert.IsTrue(_attributesBytes.SequenceEqual(actualAttributes));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpMkDirRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private Encoding _encoding;
+ private string _path;
+ private byte[] _pathBytes;
+ private SftpFileAttributes _attributes;
+ private byte[] _attributesBytes;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _protocolVersion = (uint) random.Next(0, int.MaxValue);
+ _requestId = (uint) random.Next(0, int.MaxValue);
+ _encoding = Encoding.Unicode;
+ _path = random.Next().ToString(CultureInfo.InvariantCulture);
+ _pathBytes = _encoding.GetBytes(_path);
+ _attributes = SftpFileAttributes.Empty;
+ _attributesBytes = _attributes.GetBytes();
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new SftpMkDirRequest(_protocolVersion, _requestId, _path, _encoding, null);
+
+ Assert.AreSame(_encoding, request.Encoding);
+ Assert.AreEqual(_path, request.Path);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.MkDir, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ var statusActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new SftpMkDirRequest(_protocolVersion, _requestId, _path, _encoding, statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new SftpMkDirRequest(_protocolVersion, _requestId, _path, _encoding, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Path length
+ expectedBytesLength += _pathBytes.Length; // Path
+ expectedBytesLength += _attributesBytes.Length; // Attributes
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.MkDir, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+
+ Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
+ var actualPath = new byte[_pathBytes.Length];
+ sshDataStream.Read(actualPath, 0, actualPath.Length);
+ Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));
+
+ var actualAttributes = new byte[_attributesBytes.Length];
+ sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
+ Assert.IsTrue(_attributesBytes.SequenceEqual(actualAttributes));
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpOpenRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpOpenRequestTest.cs
index 5a4a1c70..9a82ae8e 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpOpenRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpOpenRequestTest.cs
@@ -1,143 +1,143 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpOpenRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private Encoding _encoding;
- private string _filename;
- private byte[] _filenameBytes;
- private Flags _flags;
- private SftpFileAttributes _attributes;
- private byte[] _attributesBytes;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _protocolVersion = (uint)random.Next(0, int.MaxValue);
- _requestId = (uint)random.Next(0, int.MaxValue);
- _encoding = Encoding.Unicode;
- _filename = random.Next().ToString(CultureInfo.InvariantCulture);
- _filenameBytes = _encoding.GetBytes(_filename);
- _flags = Flags.Read;
- _attributes = SftpFileAttributes.Empty;
- _attributesBytes = _attributes.GetBytes();
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new SftpOpenRequest(_protocolVersion, _requestId, _filename, _encoding, _flags, null, null);
-
- Assert.AreSame(_encoding, request.Encoding);
- Assert.AreEqual(_filename, request.Filename);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.Open, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpHandleResponse()
- {
- var statusActionInvocations = new List();
- var handleActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action handleAction = handleActionInvocations.Add;
- var handleResponse = new SftpHandleResponse(_protocolVersion);
-
- var request = new SftpOpenRequest(
- _protocolVersion,
- _requestId,
- _filename,
- _encoding,
- _flags,
- handleAction,
- statusAction);
-
- request.Complete(handleResponse);
-
- Assert.AreEqual(0, statusActionInvocations.Count);
- Assert.AreEqual(1, handleActionInvocations.Count);
- Assert.AreSame(handleResponse, handleActionInvocations[0]);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- var statusActionInvocations = new List();
- var handleActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action handleAction = handleActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new SftpOpenRequest(
- _protocolVersion,
- _requestId,
- _filename,
- _encoding,
- _flags,
- handleAction,
- statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- Assert.AreEqual(0, handleActionInvocations.Count);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new SftpOpenRequest(_protocolVersion, _requestId, _filename, _encoding, _flags, null, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Filename length
- expectedBytesLength += _filenameBytes.Length; // Filename
- expectedBytesLength += 4; // Flags
- expectedBytesLength += _attributesBytes.Length; // Attributes
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.Open, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
-
- Assert.AreEqual((uint) _filenameBytes.Length, sshDataStream.ReadUInt32());
- var actualPath = new byte[_filenameBytes.Length];
- sshDataStream.Read(actualPath, 0, actualPath.Length);
- Assert.IsTrue(_filenameBytes.SequenceEqual(actualPath));
-
- Assert.AreEqual((uint) _flags, sshDataStream.ReadUInt32());
-
- var actualAttributes = new byte[_attributesBytes.Length];
- sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
- Assert.IsTrue(_attributesBytes.SequenceEqual(actualAttributes));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpOpenRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private Encoding _encoding;
+ private string _filename;
+ private byte[] _filenameBytes;
+ private Flags _flags;
+ private SftpFileAttributes _attributes;
+ private byte[] _attributesBytes;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _protocolVersion = (uint)random.Next(0, int.MaxValue);
+ _requestId = (uint)random.Next(0, int.MaxValue);
+ _encoding = Encoding.Unicode;
+ _filename = random.Next().ToString(CultureInfo.InvariantCulture);
+ _filenameBytes = _encoding.GetBytes(_filename);
+ _flags = Flags.Read;
+ _attributes = SftpFileAttributes.Empty;
+ _attributesBytes = _attributes.GetBytes();
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new SftpOpenRequest(_protocolVersion, _requestId, _filename, _encoding, _flags, null, null);
+
+ Assert.AreSame(_encoding, request.Encoding);
+ Assert.AreEqual(_filename, request.Filename);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.Open, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpHandleResponse()
+ {
+ var statusActionInvocations = new List();
+ var handleActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action handleAction = handleActionInvocations.Add;
+ var handleResponse = new SftpHandleResponse(_protocolVersion);
+
+ var request = new SftpOpenRequest(
+ _protocolVersion,
+ _requestId,
+ _filename,
+ _encoding,
+ _flags,
+ handleAction,
+ statusAction);
+
+ request.Complete(handleResponse);
+
+ Assert.AreEqual(0, statusActionInvocations.Count);
+ Assert.AreEqual(1, handleActionInvocations.Count);
+ Assert.AreSame(handleResponse, handleActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ var statusActionInvocations = new List();
+ var handleActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action handleAction = handleActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new SftpOpenRequest(
+ _protocolVersion,
+ _requestId,
+ _filename,
+ _encoding,
+ _flags,
+ handleAction,
+ statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ Assert.AreEqual(0, handleActionInvocations.Count);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new SftpOpenRequest(_protocolVersion, _requestId, _filename, _encoding, _flags, null, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Filename length
+ expectedBytesLength += _filenameBytes.Length; // Filename
+ expectedBytesLength += 4; // Flags
+ expectedBytesLength += _attributesBytes.Length; // Attributes
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.Open, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+
+ Assert.AreEqual((uint) _filenameBytes.Length, sshDataStream.ReadUInt32());
+ var actualPath = new byte[_filenameBytes.Length];
+ sshDataStream.Read(actualPath, 0, actualPath.Length);
+ Assert.IsTrue(_filenameBytes.SequenceEqual(actualPath));
+
+ Assert.AreEqual((uint) _flags, sshDataStream.ReadUInt32());
+
+ var actualAttributes = new byte[_attributesBytes.Length];
+ sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
+ Assert.IsTrue(_attributesBytes.SequenceEqual(actualAttributes));
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpReadDirRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpReadDirRequestTest.cs
index 020c4f7c..01b21ed1 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpReadDirRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpReadDirRequestTest.cs
@@ -1,110 +1,110 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpReadDirRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private byte[] _handle;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _protocolVersion = (uint) random.Next(0, int.MaxValue);
- _requestId = (uint) random.Next(0, int.MaxValue);
- _handle = new byte[random.Next(1, 10)];
- random.NextBytes(_handle);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new SftpReadDirRequest(_protocolVersion, _requestId, _handle, null, null);
-
- Assert.AreSame(_handle, request.Handle);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.ReadDir, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpAttrsResponse()
- {
- var statusActionInvocations = new List();
- var nameActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action nameAction = nameActionInvocations.Add;
- var nameResponse = new SftpNameResponse(_protocolVersion, Encoding.Unicode);
-
- var request = new SftpReadDirRequest(_protocolVersion, _requestId, _handle, nameAction, statusAction);
-
- request.Complete(nameResponse);
-
- Assert.AreEqual(0, statusActionInvocations.Count);
- Assert.AreEqual(1, nameActionInvocations.Count);
- Assert.AreSame(nameResponse, nameActionInvocations[0]);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- var statusActionInvocations = new List();
- var nameActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action nameAction = nameActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new SftpReadDirRequest(_protocolVersion, _requestId, _handle, nameAction, statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- Assert.AreEqual(0, nameActionInvocations.Count);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new SftpReadDirRequest(_protocolVersion, _requestId, _handle, null, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Handle length
- expectedBytesLength += _handle.Length; // Handle
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.ReadDir, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
-
- Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
- var actualHandle = new byte[_handle.Length];
- sshDataStream.Read(actualHandle, 0, actualHandle.Length);
- Assert.IsTrue(_handle.SequenceEqual(actualHandle));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpReadDirRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private byte[] _handle;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _protocolVersion = (uint) random.Next(0, int.MaxValue);
+ _requestId = (uint) random.Next(0, int.MaxValue);
+ _handle = new byte[random.Next(1, 10)];
+ random.NextBytes(_handle);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new SftpReadDirRequest(_protocolVersion, _requestId, _handle, null, null);
+
+ Assert.AreSame(_handle, request.Handle);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.ReadDir, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpAttrsResponse()
+ {
+ var statusActionInvocations = new List();
+ var nameActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action nameAction = nameActionInvocations.Add;
+ var nameResponse = new SftpNameResponse(_protocolVersion, Encoding.Unicode);
+
+ var request = new SftpReadDirRequest(_protocolVersion, _requestId, _handle, nameAction, statusAction);
+
+ request.Complete(nameResponse);
+
+ Assert.AreEqual(0, statusActionInvocations.Count);
+ Assert.AreEqual(1, nameActionInvocations.Count);
+ Assert.AreSame(nameResponse, nameActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ var statusActionInvocations = new List();
+ var nameActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action nameAction = nameActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new SftpReadDirRequest(_protocolVersion, _requestId, _handle, nameAction, statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ Assert.AreEqual(0, nameActionInvocations.Count);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new SftpReadDirRequest(_protocolVersion, _requestId, _handle, null, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Handle length
+ expectedBytesLength += _handle.Length; // Handle
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.ReadDir, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+
+ Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
+ var actualHandle = new byte[_handle.Length];
+ sshDataStream.Read(actualHandle, 0, actualHandle.Length);
+ Assert.IsTrue(_handle.SequenceEqual(actualHandle));
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpReadLinkRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpReadLinkRequestTest.cs
index 3f03f766..04dccf7b 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpReadLinkRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpReadLinkRequestTest.cs
@@ -1,128 +1,128 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpReadLinkRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private Encoding _encoding;
- private string _path;
- private byte[] _pathBytes;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _protocolVersion = (uint) random.Next(0, int.MaxValue);
- _requestId = (uint) random.Next(0, int.MaxValue);
- _encoding = Encoding.Unicode;
- _path = random.Next().ToString(CultureInfo.InvariantCulture);
- _pathBytes = _encoding.GetBytes(_path);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new SftpReadLinkRequest(_protocolVersion, _requestId, _path, _encoding, null, null);
-
- Assert.AreSame(_encoding, request.Encoding);
- Assert.AreEqual(_path, request.Path);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.ReadLink, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpNameResponse()
- {
- var statusActionInvocations = new List();
- var nameActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action nameAction = nameActionInvocations.Add;
- var nameResponse = new SftpNameResponse(_protocolVersion, Encoding.Unicode);
-
- var request = new SftpReadLinkRequest(
- _protocolVersion,
- _requestId,
- _path,
- _encoding,
- nameAction,
- statusAction);
-
- request.Complete(nameResponse);
-
- Assert.AreEqual(0, statusActionInvocations.Count);
- Assert.AreEqual(1, nameActionInvocations.Count);
- Assert.AreSame(nameResponse, nameActionInvocations[0]);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- var statusActionInvocations = new List();
- var nameActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action nameAction = nameActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new SftpReadLinkRequest(
- _protocolVersion,
- _requestId,
- _path,
- _encoding,
- nameAction,
- statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- Assert.AreEqual(0, nameActionInvocations.Count);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new SftpReadLinkRequest(_protocolVersion, _requestId, _path, _encoding, null, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Path length
- expectedBytesLength += _pathBytes.Length; // Path
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.ReadLink, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
-
- Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
- var actualPath = new byte[_pathBytes.Length];
- sshDataStream.Read(actualPath, 0, actualPath.Length);
- Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
-
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpReadLinkRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private Encoding _encoding;
+ private string _path;
+ private byte[] _pathBytes;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _protocolVersion = (uint) random.Next(0, int.MaxValue);
+ _requestId = (uint) random.Next(0, int.MaxValue);
+ _encoding = Encoding.Unicode;
+ _path = random.Next().ToString(CultureInfo.InvariantCulture);
+ _pathBytes = _encoding.GetBytes(_path);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new SftpReadLinkRequest(_protocolVersion, _requestId, _path, _encoding, null, null);
+
+ Assert.AreSame(_encoding, request.Encoding);
+ Assert.AreEqual(_path, request.Path);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.ReadLink, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpNameResponse()
+ {
+ var statusActionInvocations = new List();
+ var nameActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action nameAction = nameActionInvocations.Add;
+ var nameResponse = new SftpNameResponse(_protocolVersion, Encoding.Unicode);
+
+ var request = new SftpReadLinkRequest(
+ _protocolVersion,
+ _requestId,
+ _path,
+ _encoding,
+ nameAction,
+ statusAction);
+
+ request.Complete(nameResponse);
+
+ Assert.AreEqual(0, statusActionInvocations.Count);
+ Assert.AreEqual(1, nameActionInvocations.Count);
+ Assert.AreSame(nameResponse, nameActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ var statusActionInvocations = new List();
+ var nameActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action nameAction = nameActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new SftpReadLinkRequest(
+ _protocolVersion,
+ _requestId,
+ _path,
+ _encoding,
+ nameAction,
+ statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ Assert.AreEqual(0, nameActionInvocations.Count);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new SftpReadLinkRequest(_protocolVersion, _requestId, _path, _encoding, null, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Path length
+ expectedBytesLength += _pathBytes.Length; // Path
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.ReadLink, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+
+ Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
+ var actualPath = new byte[_pathBytes.Length];
+ sshDataStream.Read(actualPath, 0, actualPath.Length);
+ Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpReadRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpReadRequestTest.cs
index 36e3ad6a..6d4dc882 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpReadRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpReadRequestTest.cs
@@ -1,134 +1,134 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpReadRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private byte[] _handle;
- private ulong _offset;
- private uint _length;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _protocolVersion = (uint) random.Next(0, int.MaxValue);
- _requestId = (uint) random.Next(0, int.MaxValue);
- _handle = new byte[random.Next(1, 10)];
- random.NextBytes(_handle);
- _offset = (ulong) random.Next(0, int.MaxValue);
- _length = (uint) random.Next(0, int.MaxValue);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var request = new SftpReadRequest(_protocolVersion, _requestId, _handle, _offset, _length, null, null);
-
- Assert.AreSame(_handle, request.Handle);
- Assert.AreEqual(_length, request.Length);
- Assert.AreEqual(_offset, request.Offset);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.Read, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpDataResponse()
- {
- var statusActionInvocations = new List();
- var dataActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action dataAction = dataActionInvocations.Add;
- var dataResponse = new SftpDataResponse(_protocolVersion);
-
- var request = new SftpReadRequest(
- _protocolVersion,
- _requestId,
- _handle,
- _offset,
- _length,
- dataAction,
- statusAction);
-
- request.Complete(dataResponse);
-
- Assert.AreEqual(0, statusActionInvocations.Count);
- Assert.AreEqual(1, dataActionInvocations.Count);
- Assert.AreSame(dataResponse, dataActionInvocations[0]);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- var statusActionInvocations = new List();
- var dataActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action dataAction = dataActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new SftpReadRequest(
- _protocolVersion,
- _requestId,
- _handle,
- _offset,
- _length,
- dataAction,
- statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- Assert.AreEqual(0, dataActionInvocations.Count);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var request = new SftpReadRequest(_protocolVersion, _requestId, _handle, _offset, _length, null, null);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Handle length
- expectedBytesLength += _handle.Length; // Handle
- expectedBytesLength += 8; // Offset
- expectedBytesLength += 4; // Length
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.Read, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
-
- Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
- var actualHandle = new byte[_handle.Length];
- sshDataStream.Read(actualHandle, 0, actualHandle.Length);
- Assert.IsTrue(_handle.SequenceEqual(actualHandle));
-
- Assert.AreEqual(_offset, sshDataStream.ReadUInt64());
- Assert.AreEqual(_length, sshDataStream.ReadUInt32());
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpReadRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private byte[] _handle;
+ private ulong _offset;
+ private uint _length;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _protocolVersion = (uint) random.Next(0, int.MaxValue);
+ _requestId = (uint) random.Next(0, int.MaxValue);
+ _handle = new byte[random.Next(1, 10)];
+ random.NextBytes(_handle);
+ _offset = (ulong) random.Next(0, int.MaxValue);
+ _length = (uint) random.Next(0, int.MaxValue);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var request = new SftpReadRequest(_protocolVersion, _requestId, _handle, _offset, _length, null, null);
+
+ Assert.AreSame(_handle, request.Handle);
+ Assert.AreEqual(_length, request.Length);
+ Assert.AreEqual(_offset, request.Offset);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.Read, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpDataResponse()
+ {
+ var statusActionInvocations = new List();
+ var dataActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action dataAction = dataActionInvocations.Add;
+ var dataResponse = new SftpDataResponse(_protocolVersion);
+
+ var request = new SftpReadRequest(
+ _protocolVersion,
+ _requestId,
+ _handle,
+ _offset,
+ _length,
+ dataAction,
+ statusAction);
+
+ request.Complete(dataResponse);
+
+ Assert.AreEqual(0, statusActionInvocations.Count);
+ Assert.AreEqual(1, dataActionInvocations.Count);
+ Assert.AreSame(dataResponse, dataActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ var statusActionInvocations = new List();
+ var dataActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action dataAction = dataActionInvocations.Add;
+ var statusResponse = new SftpStatusResponse(_protocolVersion);
+
+ var request = new SftpReadRequest(
+ _protocolVersion,
+ _requestId,
+ _handle,
+ _offset,
+ _length,
+ dataAction,
+ statusAction);
+
+ request.Complete(statusResponse);
+
+ Assert.AreEqual(1, statusActionInvocations.Count);
+ Assert.AreSame(statusResponse, statusActionInvocations[0]);
+ Assert.AreEqual(0, dataActionInvocations.Count);
+ }
+
+ [TestMethod]
+ public void GetBytes()
+ {
+ var request = new SftpReadRequest(_protocolVersion, _requestId, _handle, _offset, _length, null, null);
+
+ var bytes = request.GetBytes();
+
+ var expectedBytesLength = 0;
+ expectedBytesLength += 4; // Length
+ expectedBytesLength += 1; // Type
+ expectedBytesLength += 4; // RequestId
+ expectedBytesLength += 4; // Handle length
+ expectedBytesLength += _handle.Length; // Handle
+ expectedBytesLength += 8; // Offset
+ expectedBytesLength += 4; // Length
+
+ Assert.AreEqual(expectedBytesLength, bytes.Length);
+
+ var sshDataStream = new SshDataStream(bytes);
+
+ Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
+ Assert.AreEqual((byte) SftpMessageTypes.Read, sshDataStream.ReadByte());
+ Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
+
+ Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
+ var actualHandle = new byte[_handle.Length];
+ sshDataStream.Read(actualHandle, 0, actualHandle.Length);
+ Assert.IsTrue(_handle.SequenceEqual(actualHandle));
+
+ Assert.AreEqual(_offset, sshDataStream.ReadUInt64());
+ Assert.AreEqual(_length, sshDataStream.ReadUInt32());
+
+ Assert.IsTrue(sshDataStream.IsEndOfData);
+ }
+ }
+}
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpRealPathRequestTest.cs b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpRealPathRequestTest.cs
index fc3cb13a..1ee8653c 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpRealPathRequestTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/Requests/SftpRealPathRequestTest.cs
@@ -1,143 +1,143 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Sftp;
-using Renci.SshNet.Sftp.Requests;
-using Renci.SshNet.Sftp.Responses;
-
-namespace Renci.SshNet.Tests.Classes.Sftp.Requests
-{
- [TestClass]
- public class SftpRealPathRequestTest
- {
- private uint _protocolVersion;
- private uint _requestId;
- private Encoding _encoding;
- private string _path;
- private byte[] _pathBytes;
-
- [TestInitialize]
- public void Init()
- {
- var random = new Random();
-
- _protocolVersion = (uint) random.Next(0, int.MaxValue);
- _requestId = (uint) random.Next(0, int.MaxValue);
- _encoding = Encoding.Unicode;
- _path = random.Next().ToString(CultureInfo.InvariantCulture);
- _pathBytes = _encoding.GetBytes(_path);
- }
-
- [TestMethod]
- public void Constructor()
- {
- var statusActionInvocations = new List();
- var nameActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action nameAction = nameActionInvocations.Add;
-
- var request = new SftpRealPathRequest(
- _protocolVersion,
- _requestId,
- _path,
- _encoding,
- nameAction,
- statusAction);
-
- Assert.AreSame(_encoding, request.Encoding);
- Assert.AreEqual(_path, request.Path);
- Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
- Assert.AreEqual(_requestId, request.RequestId);
- Assert.AreEqual(SftpMessageTypes.RealPath, request.SftpMessageType);
- }
-
- [TestMethod]
- public void Complete_SftpNameResponse()
- {
- var statusActionInvocations = new List();
- var nameActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action nameAction = nameActionInvocations.Add;
- var nameResponse = new SftpNameResponse(_protocolVersion, Encoding.Unicode);
-
- var request = new SftpRealPathRequest(_protocolVersion, _requestId, _path, _encoding, nameAction, statusAction);
-
- request.Complete(nameResponse);
-
- Assert.AreEqual(0, statusActionInvocations.Count);
- Assert.AreEqual(1, nameActionInvocations.Count);
- Assert.AreSame(nameResponse, nameActionInvocations[0]);
- }
-
- [TestMethod]
- public void Complete_SftpStatusResponse()
- {
- var statusActionInvocations = new List();
- var nameActionInvocations = new List();
-
- Action statusAction = statusActionInvocations.Add;
- Action nameAction = nameActionInvocations.Add;
- var statusResponse = new SftpStatusResponse(_protocolVersion);
-
- var request = new SftpRealPathRequest(
- _protocolVersion,
- _requestId,
- _path,
- _encoding,
- nameAction,
- statusAction);
-
- request.Complete(statusResponse);
-
- Assert.AreEqual(1, statusActionInvocations.Count);
- Assert.AreSame(statusResponse, statusActionInvocations[0]);
- Assert.AreEqual(0, nameActionInvocations.Count);
- }
-
- [TestMethod]
- public void GetBytes()
- {
- var statusActionInvocations = new List();
- var nameActionInvocations = new List();
- Action statusAction = statusActionInvocations.Add;
- Action nameAction = nameActionInvocations.Add;
- var request = new SftpRealPathRequest(
- _protocolVersion,
- _requestId,
- _path,
- _encoding,
- nameAction,
- statusAction);
-
- var bytes = request.GetBytes();
-
- var expectedBytesLength = 0;
- expectedBytesLength += 4; // Length
- expectedBytesLength += 1; // Type
- expectedBytesLength += 4; // RequestId
- expectedBytesLength += 4; // Path length
- expectedBytesLength += _pathBytes.Length; // Path
-
- Assert.AreEqual(expectedBytesLength, bytes.Length);
-
- var sshDataStream = new SshDataStream(bytes);
-
- Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
- Assert.AreEqual((byte) SftpMessageTypes.RealPath, sshDataStream.ReadByte());
- Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());
-
- Assert.AreEqual((uint) _pathBytes.Length, sshDataStream.ReadUInt32());
- var actualPath = new byte[_pathBytes.Length];
- sshDataStream.Read(actualPath, 0, actualPath.Length);
- Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));
-
- Assert.IsTrue(sshDataStream.IsEndOfData);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Sftp;
+using Renci.SshNet.Sftp.Requests;
+using Renci.SshNet.Sftp.Responses;
+
+namespace Renci.SshNet.Tests.Classes.Sftp.Requests
+{
+ [TestClass]
+ public class SftpRealPathRequestTest
+ {
+ private uint _protocolVersion;
+ private uint _requestId;
+ private Encoding _encoding;
+ private string _path;
+ private byte[] _pathBytes;
+
+ [TestInitialize]
+ public void Init()
+ {
+ var random = new Random();
+
+ _protocolVersion = (uint) random.Next(0, int.MaxValue);
+ _requestId = (uint) random.Next(0, int.MaxValue);
+ _encoding = Encoding.Unicode;
+ _path = random.Next().ToString(CultureInfo.InvariantCulture);
+ _pathBytes = _encoding.GetBytes(_path);
+ }
+
+ [TestMethod]
+ public void Constructor()
+ {
+ var statusActionInvocations = new List();
+ var nameActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action nameAction = nameActionInvocations.Add;
+
+ var request = new SftpRealPathRequest(
+ _protocolVersion,
+ _requestId,
+ _path,
+ _encoding,
+ nameAction,
+ statusAction);
+
+ Assert.AreSame(_encoding, request.Encoding);
+ Assert.AreEqual(_path, request.Path);
+ Assert.AreEqual(_protocolVersion, request.ProtocolVersion);
+ Assert.AreEqual(_requestId, request.RequestId);
+ Assert.AreEqual(SftpMessageTypes.RealPath, request.SftpMessageType);
+ }
+
+ [TestMethod]
+ public void Complete_SftpNameResponse()
+ {
+ var statusActionInvocations = new List();
+ var nameActionInvocations = new List();
+
+ Action statusAction = statusActionInvocations.Add;
+ Action nameAction = nameActionInvocations.Add;
+ var nameResponse = new SftpNameResponse(_protocolVersion, Encoding.Unicode);
+
+ var request = new SftpRealPathRequest(_protocolVersion, _requestId, _path, _encoding, nameAction, statusAction);
+
+ request.Complete(nameResponse);
+
+ Assert.AreEqual(0, statusActionInvocations.Count);
+ Assert.AreEqual(1, nameActionInvocations.Count);
+ Assert.AreSame(nameResponse, nameActionInvocations[0]);
+ }
+
+ [TestMethod]
+ public void Complete_SftpStatusResponse()
+ {
+ var statusActionInvocations = new List();
+ var nameActionInvocations = new List();
+
+ Action