mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-10-21 08:20:10 +08:00
Added test cases for SOCKS4, SOCKS5 an HTTP proxies for SftpClient and SshClient.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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 {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to proxy.oleg-centos.edc.renci.org.
|
||||
/// </summary>
|
||||
internal static string PROXY_HOST {
|
||||
get {
|
||||
return ResourceManager.GetString("PROXY_HOST", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to 8123.
|
||||
/// </summary>
|
||||
internal static string PROXY_PORT {
|
||||
get {
|
||||
return ResourceManager.GetString("PROXY_PORT", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to -----BEGIN RSA PRIVATE KEY-----
|
||||
///Proc-Type: 4,ENCRYPTED
|
||||
|
||||
@@ -171,6 +171,12 @@ tM7dZpB+reWl9L5e2L8=
|
||||
<data name="PORT" xml:space="preserve">
|
||||
<value>22</value>
|
||||
</data>
|
||||
<data name="PROXY_HOST" xml:space="preserve">
|
||||
<value>proxy.oleg-centos.edc.renci.org</value>
|
||||
</data>
|
||||
<data name="PROXY_PORT" xml:space="preserve">
|
||||
<value>8123</value>
|
||||
</data>
|
||||
<data name="RSA_KEY_WITHOUT_PASS" xml:space="preserve">
|
||||
<value>-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEogIBAAKCAQEA8ZsD8jgH7ySXnd4dprEFFkJ+zs1ne81E8febjR8hekiKrc+D
|
||||
|
||||
@@ -76,10 +76,12 @@
|
||||
<Compile Include="SftpClientTests\DeleteFileTest.cs" />
|
||||
<Compile Include="SftpClientTests\GetTest.cs" />
|
||||
<Compile Include="SftpClientTests\ListDirectoryTest.cs" />
|
||||
<Compile Include="SftpClientTests\ProxyTest.cs" />
|
||||
<Compile Include="SftpClientTests\RenameFileTest.cs" />
|
||||
<Compile Include="SftpClientTests\SftpFileStreamTest.cs" />
|
||||
<Compile Include="SftpClientTests\SftpFileTest.cs" />
|
||||
<Compile Include="SftpClientTests\UploadDownloadFileTest.cs" />
|
||||
<Compile Include="SshClientTests\ProxyTest.cs" />
|
||||
<Compile Include="SshClientTests\TestPortForwarding.NET40.cs" />
|
||||
<Compile Include="SshClientTests\TestSshCommand.NET40.cs" />
|
||||
<Compile Include="SshClientTests\TestPortForwarding.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user