diff --git a/Renci.SshClient/Renci.SshNet.Tests/Properties/Resources.Designer.cs b/Renci.SshClient/Renci.SshNet.Tests/Properties/Resources.Designer.cs index e1158938..28f131e5 100644 --- a/Renci.SshClient/Renci.SshNet.Tests/Properties/Resources.Designer.cs +++ b/Renci.SshClient/Renci.SshNet.Tests/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.235 +// Runtime Version:4.0.30319.261 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -140,6 +140,24 @@ namespace Renci.SshNet.Tests.Properties { } } + /// + /// Looks up a localized string similar to proxy.oleg-centos.edc.renci.org. + /// + internal static string PROXY_HOST { + get { + return ResourceManager.GetString("PROXY_HOST", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 8123. + /// + internal static string PROXY_PORT { + get { + return ResourceManager.GetString("PROXY_PORT", resourceCulture); + } + } + /// /// Looks up a localized string similar to -----BEGIN RSA PRIVATE KEY----- ///Proc-Type: 4,ENCRYPTED diff --git a/Renci.SshClient/Renci.SshNet.Tests/Properties/Resources.resx b/Renci.SshClient/Renci.SshNet.Tests/Properties/Resources.resx index bbb70965..1b97000e 100644 --- a/Renci.SshClient/Renci.SshNet.Tests/Properties/Resources.resx +++ b/Renci.SshClient/Renci.SshNet.Tests/Properties/Resources.resx @@ -171,6 +171,12 @@ tM7dZpB+reWl9L5e2L8= 22 + + proxy.oleg-centos.edc.renci.org + + + 8123 + -----BEGIN RSA PRIVATE KEY----- MIIEogIBAAKCAQEA8ZsD8jgH7ySXnd4dprEFFkJ+zs1ne81E8febjR8hekiKrc+D diff --git a/Renci.SshClient/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj b/Renci.SshClient/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj index ed86a7d2..66c0b2fc 100644 --- a/Renci.SshClient/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj +++ b/Renci.SshClient/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj @@ -76,10 +76,12 @@ + + diff --git a/Renci.SshClient/Renci.SshNet.Tests/SftpClientTests/ProxyTest.cs b/Renci.SshClient/Renci.SshNet.Tests/SftpClientTests/ProxyTest.cs new file mode 100644 index 00000000..b8ba447d --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.Tests/SftpClientTests/ProxyTest.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Renci.SshNet.Common; +using Renci.SshNet.Tests.Properties; +using System.IO; +using System.Security.Cryptography; +using Renci.SshNet.Sftp; +using System.Threading; +using System.Diagnostics; + +namespace Renci.SshNet.Tests.SftpClientTests +{ + [TestClass] + public class ProxyTest + { + [TestMethod] + [Owner("Kenneth_aa")] + [Description("Test connect to remote server via a SOCKS4 proxy server.")] + [TestCategory("Proxy")] + public void Test_Sftp_Connect_Via_Socks4() + { + var connInfo = new PasswordConnectionInfo(Resources.HOST,Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Socks4, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT)); + using (var client = new SftpClient(connInfo)) + { + client.Connect(); + + var ret = client.GetLastWriteTime("."); + Debug.WriteLine(ret, "GetLastWriteTime"); + + client.Disconnect(); + } + } + + [TestMethod] + [Owner("Kenneth_aa")] + [Description("Test connect to remote server via a TCP SOCKS5 proxy server.")] + [TestCategory("Proxy")] + public void Test_Sftp_Connect_Via_TcpSocks5() + { + var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Socks5, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT)); + using (var client = new SftpClient(connInfo)) + { + client.Connect(); + + var ret = client.GetLastWriteTime("."); + Debug.WriteLine(ret, "GetLastWriteTime"); + + client.Disconnect(); + } + } + + [TestMethod] + [Owner("Kenneth_aa")] + [Description("Test connect to remote server via a HTTP proxy server.")] + [TestCategory("Proxy")] + public void Test_Sftp_Connect_Via_HttpProxy() + { + var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Http, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT)); + using (var client = new SftpClient(connInfo)) + { + client.Connect(); + + var ret = client.GetLastWriteTime("."); + Debug.WriteLine(ret, "GetLastWriteTime"); + + client.Disconnect(); + } + } + } +} diff --git a/Renci.SshClient/Renci.SshNet.Tests/SshClientTests/ProxyTest.cs b/Renci.SshClient/Renci.SshNet.Tests/SshClientTests/ProxyTest.cs new file mode 100644 index 00000000..af8b06cd --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.Tests/SshClientTests/ProxyTest.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Renci.SshNet.Common; +using Renci.SshNet.Tests.Properties; +using System.IO; +using System.Security.Cryptography; +using Renci.SshNet.Sftp; +using System.Threading; +using System.Diagnostics; + +namespace Renci.SshNet.Tests.SshClientTests +{ + [TestClass] + public class ProxyTest + { + [TestMethod] + [Owner("Kenneth_aa")] + [Description("Test connect to remote server via a SOCKS4 proxy server.")] + [TestCategory("Proxy")] + public void Test_Ssh_Connect_Via_Socks4() + { + var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Socks4, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT)); + using (var client = new SshClient(connInfo)) + { + client.Connect(); + + var ret = client.RunCommand("ls -la"); + Debug.WriteLine(ret.Result, "Command result:"); + + client.Disconnect(); + } + } + + [TestMethod] + [Owner("Kenneth_aa")] + [Description("Test connect to remote server via a TCP SOCKS5 proxy server.")] + [TestCategory("Proxy")] + public void Test_Ssh_Connect_Via_TcpSocks5() + { + var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Socks5, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT)); + using (var client = new SshClient(connInfo)) + { + client.Connect(); + + var ret = client.RunCommand("ls -la"); + Debug.WriteLine(ret.Result, "Command result:"); + + client.Disconnect(); + } + } + + [TestMethod] + [Owner("Kenneth_aa")] + [Description("Test connect to remote server via a HTTP proxy server.")] + [TestCategory("Proxy")] + public void Test_Ssh_Connect_Via_HttpProxy() + { + var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Http, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT)); + using (var client = new SshClient(connInfo)) + { + client.Connect(); + + var ret = client.RunCommand("ls -la"); + Debug.WriteLine(ret.Result, "Command result:"); + + client.Disconnect(); + } + } + } +}