mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-11 13:39:09 +00:00
Addint test project to solution with some test cases
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<TestSettings name="Local" id="8300866b-6c03-413e-8b34-b03c6a8ecaac" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
|
||||
<Description>These are default test settings for a local test run.</Description>
|
||||
<Deployment enabled="false" />
|
||||
<Execution>
|
||||
<TestTypeSpecific />
|
||||
<AgentRule name="Execution Agents">
|
||||
</AgentRule>
|
||||
</Execution>
|
||||
</TestSettings>
|
||||
@@ -0,0 +1,356 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Renci.SshClient.Test
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
//var compressed1950 = new byte[] { 0x78, 0x9c, 0x62, 0x64, 0x60, 0x60, 0x60, 0x02, 0x62, 0xf1, 0x80, 0xc4, 0xe4, 0xec, 0xd4, 0x12, 0x85, 0xcc, 0xbc, 0x92, 0xd4, 0xf4, 0xa2, 0xcc, 0x92, 0x4a, 0x85, 0xd4, 0xa2, 0xa2, 0xfc, 0x22, 0x3d, 0xa0, 0x14, 0x03, 0x40 };
|
||||
//var compressed1951 = new byte[] { 0x62, 0x64, 0x60, 0x60, 0x60, 0x02, 0x62, 0xf1, 0x80, 0xc4, 0xe4, 0xec, 0xd4, 0x12, 0x85, 0xcc, 0xbc, 0x92, 0xd4, 0xf4, 0xa2, 0xcc, 0x92, 0x4a, 0x85, 0xd4, 0xa2, 0xa2, 0xfc, 0x22, 0x3d, 0xa0, 0x14, 0x03, 0x40 };
|
||||
//var uncompressed = new byte[] { 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x17, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x2e, 0x00, 0x00, 0x00, 0x00 };
|
||||
//var uncompressed = "ABCDEFG".GetSshBytes().ToArray();
|
||||
|
||||
//var data = new byte[] { 87, 105, 107, 105, 112, 101, 100, 105, 97 };
|
||||
//var aa = CompressionZlib.Adler32(uncompressed);
|
||||
////8f da 08 ea
|
||||
//var a1 = (byte)((aa & 0xFF000000) >> 24);
|
||||
//var a2 = (byte)((aa & 0x00FF0000) >> 16);
|
||||
//var a3 = (byte)((aa & 0x0000FF00) >> 8);
|
||||
//var a4 = (byte)((aa & 0x000000FF) >> 0);
|
||||
//Console.WriteLine("{0:x2} {1:x2} {2:x2} {3:x2} ", a1, a2, a3, a4);
|
||||
|
||||
//byte[] result1 = null;
|
||||
//using (var output = new MemoryStream())
|
||||
//{
|
||||
// using (var input = new MemoryStream(uncompressed))
|
||||
// using (var compress = new DeflateStream(output, CompressionMode.Compress))
|
||||
// {
|
||||
// compress.FlushMode = FlushType.Partial;
|
||||
// // Copy the source file into
|
||||
// // the compression stream.
|
||||
// input.CopyTo(compress);
|
||||
|
||||
// result1 = output.ToArray();
|
||||
// }
|
||||
//}
|
||||
//result1.DebugPrint();
|
||||
|
||||
//byte[] result11 = null;
|
||||
//using (var output = new MemoryStream())
|
||||
//{
|
||||
// using (var input = new MemoryStream(uncompressed))
|
||||
// using (var compress = new System.IO.Compression.DeflateStream(output, System.IO.Compression.CompressionMode.Compress))
|
||||
// {
|
||||
// // Copy the source file into
|
||||
// // the compression stream.
|
||||
// input.CopyTo(compress);
|
||||
|
||||
// result11 = output.ToArray();
|
||||
// }
|
||||
//}
|
||||
//result11.DebugPrint();
|
||||
|
||||
//byte[] result2 = null;
|
||||
//using (var output = new MemoryStream())
|
||||
//{
|
||||
// using (var decompress = new DeflateStream(new MemoryStream(result1), CompressionMode.Decompress))
|
||||
// {
|
||||
// // Copy the decompression stream
|
||||
// // into the output file.
|
||||
// decompress.CopyTo(output);
|
||||
// result2 = output.ToArray();
|
||||
// }
|
||||
//}
|
||||
|
||||
//CompressionZlib c = new CompressionZlib();
|
||||
|
||||
//var d = new byte[] { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 };
|
||||
//var rr = c.Deflate(d);
|
||||
//var b = c.Inflate(rr);
|
||||
|
||||
//var baseFile = @"D:\small.txt";
|
||||
//var inFile = new FileInfo(string.Format("{0}", baseFile));
|
||||
//var outFile = new FileInfo(string.Format("{0}.gz", baseFile));
|
||||
//Compress(inFile.OpenRead(), outFile.Create());
|
||||
//var f = File.Create(string.Format("{0}.txt", baseFile));
|
||||
//Decompress(outFile.OpenRead(), f);
|
||||
//f.Close();
|
||||
|
||||
//using (var file = File.OpenWrite("D:\\zerobunary.dat"))
|
||||
//{
|
||||
// for (int j = 0; j < 10; j++)
|
||||
// {
|
||||
// for (int i = 0; i < 1024 * 1024 * 1024; i++)
|
||||
// {
|
||||
// file.WriteByte(0);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//TestSftp();
|
||||
//TestSftpDownload();
|
||||
|
||||
|
||||
//var shell = CreateShell();
|
||||
//shell.Connect();
|
||||
//var res = shell.Execute("ls -l");
|
||||
//shell.Disconnect();
|
||||
//Console.WriteLine(DateTime.Now + ":" + res.Length);
|
||||
//res = shell.Execute("ls -l");
|
||||
//Console.WriteLine(DateTime.Now + ":" + res.Length);
|
||||
//res = shell.Execute("ls -l");
|
||||
//Console.WriteLine(DateTime.Now + ":" + res.Length);
|
||||
//shell.Disconnect();
|
||||
|
||||
//for (int i = 0; i < 2; i++)
|
||||
//{
|
||||
// TestExec(i);
|
||||
//}
|
||||
|
||||
|
||||
// Parallel testing
|
||||
var startTick = DateTime.Now.Ticks;
|
||||
TestParallelConnections();
|
||||
//TestParallelExec();
|
||||
var endTick = DateTime.Now.Ticks;
|
||||
//TestParallelAynchExec();
|
||||
|
||||
//s.Disconnect();
|
||||
Console.WriteLine("Finished in " + ((double)(endTick - startTick) / 10000000));
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
private static volatile int _counter = 0;
|
||||
|
||||
private static volatile int _errors = 0;
|
||||
|
||||
private static volatile int _connectionCount;
|
||||
|
||||
private static void TestParallelExec()
|
||||
{
|
||||
var shell = CreateShell();
|
||||
int _threadsCount = 0;
|
||||
|
||||
System.Threading.Tasks.Parallel.For(0, 100,
|
||||
new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = 15
|
||||
},
|
||||
() =>
|
||||
{
|
||||
_threadsCount++;
|
||||
return new object();
|
||||
},
|
||||
(int counter, ParallelLoopState pls, object conn) =>
|
||||
//(counter) =>
|
||||
//for (int counter = 0; counter < 100; counter++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = EchoTest(shell, counter);
|
||||
if (result == false)
|
||||
{
|
||||
_errors++;
|
||||
}
|
||||
Console.WriteLine("{5:000}: {4}: Count: {3:000}, Thread: {0:000}, i: {1:0000}, Result: {2:000000}", Thread.CurrentThread.ManagedThreadId, counter, result, _counter++, DateTime.Now, _threadsCount);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
Console.WriteLine("{5:000}: {4}: Count: {3:000}, Thread: {0:000}, i: {1:0000}, Error: {2:000000}", Thread.CurrentThread.ManagedThreadId, counter, exp.Message, _counter++, DateTime.Now, _threadsCount);
|
||||
_errors++;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
(object conn) =>
|
||||
{
|
||||
_threadsCount--;
|
||||
}
|
||||
);
|
||||
|
||||
shell.Disconnect();
|
||||
|
||||
Console.WriteLine("Parallel execution tested");
|
||||
//Console.ReadKey();
|
||||
}
|
||||
|
||||
private static void TestParallelAynchExec()
|
||||
{
|
||||
var shell = CreateShell();
|
||||
|
||||
System.Threading.Tasks.Parallel.For(0, 100000,
|
||||
new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = 10
|
||||
},
|
||||
(counter) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
MemoryStream result = new MemoryStream();
|
||||
//var asyncResult = shell.BeginExecute("cat bigtestfile.txt", result, null, null);
|
||||
var asyncResult = shell.BeginExecute("ls -l", result, null, null);
|
||||
|
||||
asyncResult.AsyncWaitHandle.WaitOne();
|
||||
|
||||
shell.EndExecute(asyncResult);
|
||||
|
||||
var r = Encoding.ASCII.GetString(result.ToArray());
|
||||
|
||||
Console.WriteLine("{4}: Count: {3:000}, Thread: {0:000}, i: {1:000}, Bytes: {2:000000}", Thread.CurrentThread.ManagedThreadId, counter, r.Length, _counter++, DateTime.Now);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
Console.WriteLine("{4}: Count: {3:000}, Thread: {0:000}, i: {1:000}, Error: {2:000000}", Thread.CurrentThread.ManagedThreadId, counter, exp.Message, _counter++, DateTime.Now);
|
||||
_errors++;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Console.WriteLine("Parallel execution tested");
|
||||
//Console.ReadKey();
|
||||
}
|
||||
|
||||
private static void TestParallelConnections()
|
||||
{
|
||||
System.Threading.Tasks.Parallel.For(0, 10000,
|
||||
new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = 10
|
||||
},
|
||||
() =>
|
||||
{
|
||||
var conn = CreateShell();
|
||||
conn.Connect();
|
||||
_connectionCount++;
|
||||
return conn;
|
||||
},
|
||||
(int counter, ParallelLoopState pls, Shell conn) =>
|
||||
//(int counter) =>
|
||||
{
|
||||
|
||||
//var conn = new Shell("152.54.9.105", 22, "oleg", "Maya1kap@");
|
||||
//conn.Connect();
|
||||
//_connectionCount++;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendFormat("{0}", DateTime.Now);
|
||||
sb.AppendFormat("Conn: {0:000} ", _connectionCount);
|
||||
sb.AppendFormat("Thread: {0:000} ", Thread.CurrentThread.ManagedThreadId);
|
||||
sb.AppendFormat("Count: {0:0000} ", _counter++);
|
||||
sb.AppendFormat("i: {0:0000} ", counter);
|
||||
try
|
||||
{
|
||||
|
||||
var result = EchoTest(conn, counter);
|
||||
if (result == false)
|
||||
{
|
||||
_errors++;
|
||||
}
|
||||
|
||||
//var r = conn.Execute("cat bigtestfile.txt");
|
||||
//sb.AppendFormat("Bytes: {0:000000} ", r.Length);
|
||||
sb.AppendFormat("Bytes: {0:000000} ", result);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
sb.AppendFormat("Error: {0}", exp.Message);
|
||||
_errors++;
|
||||
}
|
||||
Console.WriteLine(sb.ToString());
|
||||
|
||||
//conn.Disconnect();
|
||||
//_connectionCount--;
|
||||
|
||||
return conn;
|
||||
},
|
||||
(Shell conn) =>
|
||||
{
|
||||
conn.Disconnect();
|
||||
_connectionCount--;
|
||||
}
|
||||
);
|
||||
|
||||
Console.WriteLine("Parallel execution tested");
|
||||
|
||||
//Console.ReadKey();
|
||||
}
|
||||
|
||||
private static void TestSftpDownload()
|
||||
{
|
||||
Sftp sftp = new Sftp("152.54.8.155", 2222, "oleg", "Maya1kap@");
|
||||
sftp.DownloadFile("/home/oleg/uploadedfile.txt", @"D:\downloadtext1.txt");
|
||||
Console.WriteLine("SFTP tested.");
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
private static void TestSftp()
|
||||
{
|
||||
Sftp sftp = new Sftp("152.54.9.105", 2222, "oleg", "Maya1kap@");
|
||||
//sftp.UploadFile(@"D:\NoaaGetCapabilities.xml", "/home/oleg/uploadedfile.txt");
|
||||
sftp.UploadFile(@"D:\zerobunary.dat", "/home/oleg/uploadedfile.txt");
|
||||
sftp.UploadFile(@"D:\SQL Server Data\BCFS_0.ldf", "/home/oleg/uploadedfile.txt");
|
||||
|
||||
sftp.DownloadFile("/home/oleg/uploadedfile.txt", @"D:\downloadtext1.txt");
|
||||
|
||||
Console.WriteLine("SFTP tested.");
|
||||
}
|
||||
|
||||
private static void TestExec(int counter)
|
||||
{
|
||||
var s = CreateShell();
|
||||
s.Connect();
|
||||
MemoryStream debugStream = new MemoryStream();
|
||||
|
||||
//var res1 = s.Execute("cat bigtestfile.txt", debugStream);
|
||||
//var res2 = Encoding.ASCII.GetString(debugStream.ToArray());
|
||||
var result = EchoTest(s, counter);
|
||||
|
||||
|
||||
Console.WriteLine("{4}: Count: {3:000}, Thread: {0:000}, i: {1:000}, Bytes: {2:000000}", Thread.CurrentThread.ManagedThreadId, counter, result, _counter++, DateTime.Now);
|
||||
s.Disconnect();
|
||||
|
||||
//Console.WriteLine("Execute tested.");
|
||||
//Console.ReadKey();
|
||||
}
|
||||
|
||||
private static bool EchoTest(Shell shell, int counter)
|
||||
{
|
||||
bool result;
|
||||
var length = 1024 * 16;
|
||||
var btf = shell.Execute(string.Format("for i in {{1..{0}}}\ndo\necho \"ABCDEFG\"\ndone\n", length / 8));
|
||||
|
||||
result = (btf.Length == length);
|
||||
if (!result)
|
||||
return result;
|
||||
|
||||
var r = shell.Execute(string.Format("echo {0}", counter));
|
||||
int r1;
|
||||
if (int.TryParse(r, out r1))
|
||||
{
|
||||
result = (r1 == counter);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
//shell.Execute("sleep 10");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Shell CreateShell()
|
||||
{
|
||||
return new Shell("152.54.8.155", 22, "oleg", "Maya1kap@");
|
||||
//return new Shell("152.54.8.155", 22, "oleg", "Maya1kap@");
|
||||
//return new Shell("br0.renci.org", 22, "wrf", new PrivateKeyFile(@"H:\My Documents\SSHKeys\useme.key"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Renci.SshClient.Test")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("Renci.SshClient.Test")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5d878689-525b-444d-8e7e-4500e0eebd64")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{23E84A34-A9EC-47D5-BECE-0725053BB17E}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Renci.SshClient.Test</RootNamespace>
|
||||
<AssemblyName>Renci.SshClient.Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugNoTimeout|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\DebugNoTimeout\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Debug\Renci.SshClient.Test.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Renci.SshClient\Renci.SshClient.csproj">
|
||||
<Project>{2F5F8C90-0BD1-424F-997C-7BC6280919D1}</Project>
|
||||
<Name>Renci.SshClient</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,10 @@
|
||||
""
|
||||
{
|
||||
"FILE_VERSION" = "9237"
|
||||
"ENLISTMENT_CHOICE" = "NEVER"
|
||||
"PROJECT_FILE_RELATIVE_PATH" = ""
|
||||
"NUMBER_OF_EXCLUDED_FILES" = "0"
|
||||
"ORIGINAL_PROJECT_FILE_PATH" = ""
|
||||
"NUMBER_OF_NESTED_PROJECTS" = "0"
|
||||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
|
||||
}
|
||||
@@ -3,7 +3,14 @@ Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Renci.SshClient", "Renci.SshClient\Renci.SshClient.csproj", "{2F5F8C90-0BD1-424F-997C-7BC6280919D1}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Renci.SshClient.Test", "Renci.SshClient.Test\Renci.SshClient.Test.csproj", "{23E84A34-A9EC-47D5-BECE-0725053BB17E}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Renci.SshClient.Tests", "Tests\Renci.SshClient.Tests.csproj", "{C45379B9-17B1-4E89-BC2E-6D41726413E8}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A3063E62-89D5-43FF-AB1A-FFBECB4A1850}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Local.testsettings = Local.testsettings
|
||||
Renci.SshClient1.vsmdi = Renci.SshClient1.vsmdi
|
||||
TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(TeamFoundationVersionControl) = preSolution
|
||||
@@ -11,12 +18,15 @@ Global
|
||||
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
|
||||
SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs11
|
||||
SccLocalPath0 = .
|
||||
SccProjectUniqueName1 = Renci.SshClient.Test\\Renci.SshClient.Test.csproj
|
||||
SccProjectName1 = Renci.SshClient.Test
|
||||
SccLocalPath1 = Renci.SshClient.Test
|
||||
SccProjectUniqueName2 = Renci.SshClient\\Renci.SshClient.csproj
|
||||
SccProjectName2 = Renci.SshClient
|
||||
SccLocalPath2 = Renci.SshClient
|
||||
SccProjectUniqueName1 = Renci.SshClient\\Renci.SshClient.csproj
|
||||
SccProjectName1 = Renci.SshClient
|
||||
SccLocalPath1 = Renci.SshClient
|
||||
SccProjectUniqueName2 = Tests\\Renci.SshClient.Tests.csproj
|
||||
SccProjectName2 = Tests
|
||||
SccLocalPath2 = Tests
|
||||
EndGlobalSection
|
||||
GlobalSection(TestCaseManagementSettings) = postSolution
|
||||
CategoryFile = Renci.SshClient1.vsmdi
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -45,21 +55,21 @@ Global
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Debug|x86.Build.0 = Debug|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.DebugNoTimeout|Any CPU.ActiveCfg = DebugNoTimeout|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.DebugNoTimeout|Mixed Platforms.ActiveCfg = DebugNoTimeout|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.DebugNoTimeout|Mixed Platforms.Build.0 = DebugNoTimeout|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.DebugNoTimeout|x86.ActiveCfg = DebugNoTimeout|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.DebugNoTimeout|x86.Build.0 = DebugNoTimeout|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Release|x86.ActiveCfg = Release|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Release|x86.Build.0 = Release|x86
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.DebugNoTimeout|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.DebugNoTimeout|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.DebugNoTimeout|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.DebugNoTimeout|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.DebugNoTimeout|x86.ActiveCfg = Debug|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{C45379B9-17B1-4E89-BC2E-6D41726413E8}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<TestLists xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
|
||||
<TestList name="Lists of Tests" id="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
|
||||
<RunConfiguration id="8300866b-6c03-413e-8b34-b03c6a8ecaac" name="Local" storage="local.testsettings" type="Microsoft.VisualStudio.TestTools.Common.TestRunConfiguration, Microsoft.VisualStudio.QualityTools.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
</TestList>
|
||||
</TestLists>
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
namespace Renci.SshClient.Tests
|
||||
{
|
||||
public static class ConnectionData
|
||||
{
|
||||
public static string Host { get { return "you host here"; } }
|
||||
|
||||
public static int Port { get { return 22; } }
|
||||
|
||||
public static string Username { get { return "username"; } }
|
||||
|
||||
public static string Password { get { return "password@"; } }
|
||||
|
||||
public static string RsaKeyFilePath { get { return @"path to rsa key file"; } }
|
||||
|
||||
public static string DssKeyFilePath { get { return @"path to dss key file"; } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Tests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("defb66b2-a4b9-40ca-b205-2183d84b7323")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{C45379B9-17B1-4E89-BC2E-6D41726413E8}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Renci.SshClient.Tests</RootNamespace>
|
||||
<AssemblyName>Renci.SshClient.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
|
||||
<Visible>False</Visible>
|
||||
</CodeAnalysisDependentAssemblyPaths>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConnectionData.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ShellTest.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Renci.SshClient\Renci.SshClient.csproj">
|
||||
<Project>{2F5F8C90-0BD1-424F-997C-7BC6280919D1}</Project>
|
||||
<Name>Renci.SshClient</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,10 @@
|
||||
""
|
||||
{
|
||||
"FILE_VERSION" = "9237"
|
||||
"ENLISTMENT_CHOICE" = "NEVER"
|
||||
"PROJECT_FILE_RELATIVE_PATH" = ""
|
||||
"NUMBER_OF_EXCLUDED_FILES" = "0"
|
||||
"ORIGINAL_PROJECT_FILE_PATH" = ""
|
||||
"NUMBER_OF_NESTED_PROJECTS" = "0"
|
||||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshClient.Common;
|
||||
|
||||
namespace Renci.SshClient.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for UnitTest1
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ShellTest
|
||||
{
|
||||
public ShellTest()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
//
|
||||
}
|
||||
|
||||
private TestContext testContextInstance;
|
||||
|
||||
/// <summary>
|
||||
///Gets or sets the test context which provides
|
||||
///information about and functionality for the current test run.
|
||||
///</summary>
|
||||
public TestContext TestContext
|
||||
{
|
||||
get
|
||||
{
|
||||
return testContextInstance;
|
||||
}
|
||||
set
|
||||
{
|
||||
testContextInstance = value;
|
||||
}
|
||||
}
|
||||
|
||||
#region Additional test attributes
|
||||
//
|
||||
// You can use the following additional attributes as you write your tests:
|
||||
//
|
||||
// Use ClassInitialize to run code before running the first test in the class
|
||||
// [ClassInitialize()]
|
||||
// public static void MyClassInitialize(TestContext testContext) { }
|
||||
//
|
||||
// Use ClassCleanup to run code after all tests in a class have run
|
||||
// [ClassCleanup()]
|
||||
// public static void MyClassCleanup() { }
|
||||
//
|
||||
// Use TestInitialize to run code before running each test
|
||||
// [TestInitialize()]
|
||||
// public void MyTestInitialize() { }
|
||||
//
|
||||
// Use TestCleanup to run code after each test has run
|
||||
// [TestCleanup()]
|
||||
// public void MyTestCleanup() { }
|
||||
//
|
||||
#endregion
|
||||
|
||||
[TestMethod]
|
||||
public void TestConnectUsingPassword()
|
||||
{
|
||||
var s = CreateShellUsingPassword();
|
||||
s.Connect();
|
||||
s.Disconnect();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestExecuteSingleCommand()
|
||||
{
|
||||
var s = CreateShellUsingPassword();
|
||||
s.Connect();
|
||||
var result = ExecuteTestCommand(s);
|
||||
s.Disconnect();
|
||||
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestReconnecting()
|
||||
{
|
||||
var s = CreateShellUsingPassword();
|
||||
s.Connect();
|
||||
var result = ExecuteTestCommand(s);
|
||||
s.Disconnect();
|
||||
|
||||
Assert.IsTrue(result);
|
||||
|
||||
s.Connect();
|
||||
result = ExecuteTestCommand(s);
|
||||
s.Disconnect();
|
||||
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMultipleThreadMultipleSessions_10000()
|
||||
{
|
||||
var s = CreateShellUsingPassword();
|
||||
|
||||
System.Threading.Tasks.Parallel.For(0, 10000,
|
||||
(counter) =>
|
||||
{
|
||||
var result = ExecuteTestCommand(s);
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
);
|
||||
|
||||
s.Disconnect();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMultipleThreadMultipleConnections_10000()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
System.Threading.Tasks.Parallel.For(0, 10000,
|
||||
new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = 1,
|
||||
},
|
||||
() =>
|
||||
{
|
||||
var s = CreateShellUsingPassword();
|
||||
s.Connect();
|
||||
return s;
|
||||
},
|
||||
(int counter, ParallelLoopState pls, Shell s) =>
|
||||
{
|
||||
var result = ExecuteTestCommand(s);
|
||||
Debug.WriteLine(string.Format("TestMultipleThreadMultipleConnections #{0}", counter));
|
||||
Assert.IsTrue(result);
|
||||
return s;
|
||||
},
|
||||
(Shell s) =>
|
||||
{
|
||||
s.Disconnect();
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
Assert.Fail(exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestExtendedOutput()
|
||||
{
|
||||
var s = CreateShellUsingPassword();
|
||||
MemoryStream ms = new MemoryStream();
|
||||
s.Connect();
|
||||
var result = s.Execute("echo 12345; echo 654321 >&2", ms);
|
||||
var extendedData = Encoding.ASCII.GetString(ms.ToArray());
|
||||
result = result.Substring(0, result.Length - 1); // Remove \n chararacter returned by command
|
||||
extendedData = extendedData.Substring(0, extendedData.Length - 1); // Remove \n chararacter returned by command
|
||||
s.Disconnect();
|
||||
|
||||
Assert.AreEqual("12345", result);
|
||||
Assert.AreEqual("654321", extendedData);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvalidCommandExecution()
|
||||
{
|
||||
var s = CreateShellUsingPassword();
|
||||
s.Connect();
|
||||
try
|
||||
{
|
||||
s.Execute(";");
|
||||
Assert.Fail("Operation should fail");
|
||||
}
|
||||
catch (SshException exp)
|
||||
{
|
||||
Assert.AreEqual(exp.ExitStatus, (uint)2);
|
||||
}
|
||||
s.Disconnect();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvalidCommandThenValidCommandExecution()
|
||||
{
|
||||
var s = CreateShellUsingPassword();
|
||||
s.Connect();
|
||||
try
|
||||
{
|
||||
s.Execute(";");
|
||||
Assert.Fail("Operation should fail");
|
||||
}
|
||||
catch (SshException exp)
|
||||
{
|
||||
Assert.AreEqual(exp.ExitStatus, (uint)2);
|
||||
}
|
||||
var result = ExecuteTestCommand(s);
|
||||
s.Disconnect();
|
||||
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestRsaKeyConnection()
|
||||
{
|
||||
var s = CreateShellUsingRSAKey();
|
||||
s.Connect();
|
||||
var result = ExecuteTestCommand(s);
|
||||
s.Disconnect();
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestDssKeyConnection()
|
||||
{
|
||||
var s = CreateShellUsingRSAKey();
|
||||
s.Connect();
|
||||
var result = ExecuteTestCommand(s);
|
||||
s.Disconnect();
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
private static Shell CreateShellUsingPassword()
|
||||
{
|
||||
return new Shell(ConnectionData.Host, ConnectionData.Port, ConnectionData.Username, ConnectionData.Password);
|
||||
}
|
||||
|
||||
private static Shell CreateShellUsingRSAKey()
|
||||
{
|
||||
return new Shell(ConnectionData.Host, ConnectionData.Port, ConnectionData.Username, new PrivateKeyFile(ConnectionData.RsaKeyFilePath));
|
||||
}
|
||||
|
||||
private static Shell CreateShellUsingDSSKey()
|
||||
{
|
||||
return new Shell(ConnectionData.Host, ConnectionData.Port, ConnectionData.Username, new PrivateKeyFile(ConnectionData.DssKeyFilePath));
|
||||
}
|
||||
|
||||
private static bool ExecuteTestCommand(Shell s)
|
||||
{
|
||||
var testValue = Guid.NewGuid().ToString();
|
||||
var command = string.Format("echo {0}", testValue);
|
||||
var result = s.Execute(command);
|
||||
result = result.Substring(0, result.Length - 1); // Remove \n chararacter returned by command
|
||||
return result.Equals(testValue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<TestSettings name="Trace and Test Impact" id="2e20f196-5200-4e9c-80b5-9e05e847966b" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
|
||||
<Description>These are test settings for Trace and Test Impact.</Description>
|
||||
<Execution>
|
||||
<TestTypeSpecific />
|
||||
<AgentRule name="Execution Agents">
|
||||
<DataCollectors>
|
||||
<DataCollector uri="datacollector://microsoft/SystemInfo/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.DataCollection.SystemInfo.SystemInfoDataCollector, Microsoft.VisualStudio.TestTools.DataCollection.SystemInfo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="System Information">
|
||||
</DataCollector>
|
||||
<DataCollector uri="datacollector://microsoft/ActionLog/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.ManualTest.ActionLog.ActionLogPlugin, Microsoft.VisualStudio.TestTools.ManualTest.ActionLog, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="Actions">
|
||||
</DataCollector>
|
||||
<DataCollector uri="datacollector://microsoft/HttpProxy/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TraceCollector.HttpProxyCollector, Microsoft.VisualStudio.TraceCollector, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="ASP.NET Client Proxy for IntelliTrace and Test Impact">
|
||||
</DataCollector>
|
||||
<DataCollector uri="datacollector://microsoft/TestImpact/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TraceCollector.TestImpactDataCollector, Microsoft.VisualStudio.TraceCollector, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="Test Impact">
|
||||
</DataCollector>
|
||||
<DataCollector uri="datacollector://microsoft/TraceDebugger/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TraceCollector.TraceDebuggerDataCollector, Microsoft.VisualStudio.TraceCollector, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="IntelliTrace">
|
||||
</DataCollector>
|
||||
</DataCollectors>
|
||||
</AgentRule>
|
||||
</Execution>
|
||||
</TestSettings>
|
||||
Reference in New Issue
Block a user