|
|
@@ -15,6 +15,7 @@ namespace Renci.SshNet.Tests
|
|
|
public class ConnectionTest
|
|
|
{
|
|
|
[TestMethod]
|
|
|
+ [TestCategory("Authentication")]
|
|
|
public void Test_Connect_Using_Correct_Password()
|
|
|
{
|
|
|
using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
|
|
|
@@ -24,7 +25,8 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [TestMethod]
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("Authentication")]
|
|
|
[ExpectedException(typeof(SshAuthenticationException))]
|
|
|
public void Test_Connect_Using_Invalid_Password()
|
|
|
{
|
|
|
@@ -35,7 +37,8 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [TestMethod]
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("Authentication")]
|
|
|
public void Test_Connect_Using_Rsa_Key_Without_PassPhrase()
|
|
|
{
|
|
|
MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITHOUT_PASS));
|
|
|
@@ -46,7 +49,8 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [TestMethod]
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("Authentication")]
|
|
|
public void Test_Connect_Using_RsaKey_With_PassPhrase()
|
|
|
{
|
|
|
MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITH_PASS));
|
|
|
@@ -57,7 +61,8 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [TestMethod]
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("Authentication")]
|
|
|
[ExpectedException(typeof(SshPassPhraseNullOrEmptyException))]
|
|
|
public void Test_Connect_Using_Key_With_Empty_PassPhrase()
|
|
|
{
|
|
|
@@ -69,7 +74,8 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [TestMethod]
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("Authentication")]
|
|
|
public void Test_Connect_Using_DsaKey_Without_PassPhrase()
|
|
|
{
|
|
|
MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.DSA_KEY_WITHOUT_PASS));
|
|
|
@@ -80,7 +86,8 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [TestMethod]
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("Authentication")]
|
|
|
public void Test_Connect_Using_DsaKey_With_PassPhrase()
|
|
|
{
|
|
|
MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.DSA_KEY_WITH_PASS));
|
|
|
@@ -91,7 +98,8 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [TestMethod]
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("Authentication")]
|
|
|
[ExpectedException(typeof(SshAuthenticationException))]
|
|
|
public void Test_Connect_Using_Invalid_PrivateKey()
|
|
|
{
|
|
|
@@ -103,7 +111,8 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [TestMethod]
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("Authentication")]
|
|
|
public void Test_Connect_Using_Multiple_PrivateKeys()
|
|
|
{
|
|
|
using (var client = new SshClient(Resources.HOST, Resources.USERNAME,
|
|
|
@@ -120,7 +129,8 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
|
|
|
|
|
|
- [TestMethod]
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("Authentication")]
|
|
|
public void Test_Connect_Then_Reconnect()
|
|
|
{
|
|
|
using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
|
|
|
@@ -132,21 +142,24 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [WorkItem(703), TestMethod]
|
|
|
+ [WorkItem(703), TestMethod]
|
|
|
+ [TestCategory("PasswordConnectionInfo")]
|
|
|
[ExpectedException(typeof(ArgumentException))]
|
|
|
public void Test_ConnectionInfo_Host_Is_Null()
|
|
|
{
|
|
|
var connectionInfo = new PasswordConnectionInfo(null, "username", "password");
|
|
|
}
|
|
|
|
|
|
- [WorkItem(703), TestMethod]
|
|
|
+ [WorkItem(703), TestMethod]
|
|
|
+ [TestCategory("PasswordConnectionInfo")]
|
|
|
[ExpectedException(typeof(ArgumentException))]
|
|
|
public void Test_ConnectionInfo_Username_Is_Null()
|
|
|
{
|
|
|
var connectionInfo = new PasswordConnectionInfo("host", null, "password");
|
|
|
}
|
|
|
|
|
|
- [WorkItem(703), TestMethod]
|
|
|
+ [WorkItem(703), TestMethod]
|
|
|
+ [TestCategory("PasswordConnectionInfo")]
|
|
|
[ExpectedException(typeof(ArgumentNullException))]
|
|
|
public void Test_ConnectionInfo_Password_Is_Null()
|
|
|
{
|
|
|
@@ -154,6 +167,7 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
|
|
|
[TestMethod]
|
|
|
+ [TestCategory("PasswordConnectionInfo")]
|
|
|
[Description("Test passing whitespace to host parameter.")]
|
|
|
[ExpectedException(typeof(ArgumentException))]
|
|
|
public void Test_ConnectionInfo_Host_Is_Whitespace()
|
|
|
@@ -162,6 +176,7 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
|
|
|
[TestMethod]
|
|
|
+ [TestCategory("PasswordConnectionInfo")]
|
|
|
[Description("Test passing whitespace to username parameter.")]
|
|
|
[ExpectedException(typeof(ArgumentException))]
|
|
|
public void Test_ConnectionInfo_Username_Is_Whitespace()
|
|
|
@@ -170,6 +185,7 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
|
|
|
[WorkItem(703), TestMethod]
|
|
|
+ [TestCategory("PasswordConnectionInfo")]
|
|
|
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
|
|
public void Test_ConnectionInfo_SmallPortNumber()
|
|
|
{
|
|
|
@@ -177,11 +193,129 @@ namespace Renci.SshNet.Tests
|
|
|
}
|
|
|
|
|
|
[WorkItem(703), TestMethod]
|
|
|
+ [TestCategory("PasswordConnectionInfo")]
|
|
|
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
|
|
public void Test_ConnectionInfo_BigPortNumber()
|
|
|
{
|
|
|
var connectionInfo = new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MaxPort + 1, Resources.USERNAME, Resources.PASSWORD);
|
|
|
}
|
|
|
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("ConnectionInfo")]
|
|
|
+ [Description("Pass null as proxy host.")]
|
|
|
+ [Owner("Kenneth_aa")]
|
|
|
+ [ExpectedException(typeof(ArgumentException))]
|
|
|
+ public void Test_ConnectionInfo_ProxyHost_Null()
|
|
|
+ {
|
|
|
+ new ConnectionInfo(Resources.HOST, 22, Resources.USERNAME, ProxyTypes.None, null, 22, Resources.USERNAME, Resources.PASSWORD, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("ConnectionInfo")]
|
|
|
+ [Description("Pass String.Empty as proxy host.")]
|
|
|
+ [Owner("Kenneth_aa")]
|
|
|
+ [ExpectedException(typeof(ArgumentException))]
|
|
|
+ public void Test_ConnectionInfo_ProxyHost_Empty()
|
|
|
+ {
|
|
|
+ new ConnectionInfo(Resources.HOST, 22, Resources.USERNAME, ProxyTypes.None, string.Empty, 22, Resources.USERNAME, Resources.PASSWORD, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("ConnectionInfo")]
|
|
|
+ [Description("Pass too large proxy port.")]
|
|
|
+ [Owner("Kenneth_aa")]
|
|
|
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
|
|
|
+ public void Test_ConnectionInfo_ProxyPort_Large()
|
|
|
+ {
|
|
|
+ new ConnectionInfo(Resources.HOST, 22, Resources.USERNAME, ProxyTypes.None, Resources.HOST, int.MaxValue, Resources.USERNAME, Resources.PASSWORD, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("ConnectionInfo")]
|
|
|
+ [Description("Pass too small proxy port.")]
|
|
|
+ [Owner("Kenneth_aa")]
|
|
|
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
|
|
|
+ public void Test_ConnectionInfo_ProxyPort_Small()
|
|
|
+ {
|
|
|
+ new ConnectionInfo(Resources.HOST, 22, Resources.USERNAME, ProxyTypes.None, Resources.HOST, int.MinValue, Resources.USERNAME, Resources.PASSWORD, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("ConnectionInfo")]
|
|
|
+ [Description("Pass a valid proxy port.")]
|
|
|
+ [Owner("Kenneth_aa")]
|
|
|
+ public void Test_ConnectionInfo_ProxyPort_Valid()
|
|
|
+ {
|
|
|
+ new ConnectionInfo(Resources.HOST, 22, Resources.USERNAME, ProxyTypes.None, Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("ConnectionInfo")]
|
|
|
+ [Description("Pass null as host.")]
|
|
|
+ [Owner("Kenneth_aa")]
|
|
|
+ [ExpectedException(typeof(ArgumentException))]
|
|
|
+ public void Test_ConnectionInfo_Host_Null()
|
|
|
+ {
|
|
|
+ new ConnectionInfo(null, 22, Resources.USERNAME, ProxyTypes.None, Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("ConnectionInfo")]
|
|
|
+ [Description("Pass String.Empty as host.")]
|
|
|
+ [Owner("Kenneth_aa")]
|
|
|
+ [ExpectedException(typeof(ArgumentException))]
|
|
|
+ public void Test_ConnectionInfo_Host_Empty()
|
|
|
+ {
|
|
|
+ new ConnectionInfo(string.Empty, 22, Resources.USERNAME, ProxyTypes.None, Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("ConnectionInfo")]
|
|
|
+ [Description("Pass a valid host.")]
|
|
|
+ [Owner("Kenneth_aa")]
|
|
|
+ public void Test_ConnectionInfo_Host_Valid()
|
|
|
+ {
|
|
|
+ new ConnectionInfo(Resources.HOST, 22, Resources.USERNAME, ProxyTypes.None, Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("ConnectionInfo")]
|
|
|
+ [Description("Pass too large port.")]
|
|
|
+ [Owner("Kenneth_aa")]
|
|
|
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
|
|
|
+ public void Test_ConnectionInfo_Port_Large()
|
|
|
+ {
|
|
|
+ new ConnectionInfo(Resources.HOST, int.MaxValue, Resources.USERNAME, ProxyTypes.None, Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("ConnectionInfo")]
|
|
|
+ [Description("Pass too small port.")]
|
|
|
+ [Owner("Kenneth_aa")]
|
|
|
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
|
|
|
+ public void Test_ConnectionInfo_Port_Small()
|
|
|
+ {
|
|
|
+ new ConnectionInfo(Resources.HOST, int.MinValue, Resources.USERNAME, ProxyTypes.None, Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("ConnectionInfo")]
|
|
|
+ [Description("Pass a valid port.")]
|
|
|
+ [Owner("Kenneth_aa")]
|
|
|
+ public void Test_ConnectionInfo_Port_Valid()
|
|
|
+ {
|
|
|
+ new ConnectionInfo(Resources.HOST, 22, Resources.USERNAME, ProxyTypes.None, Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ [TestCategory("ConnectionInfo")]
|
|
|
+ [Description("Pass null as session.")]
|
|
|
+ [Owner("Kenneth_aa")]
|
|
|
+ [ExpectedException(typeof(ArgumentNullException))]
|
|
|
+ public void Test_ConnectionInfo_Authenticate_Null()
|
|
|
+ {
|
|
|
+ var ret = new ConnectionInfo(Resources.HOST, 22, Resources.USERNAME, ProxyTypes.None, Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD, null);
|
|
|
+ ret.Authenticate(null);
|
|
|
+ }
|
|
|
}
|
|
|
}
|