Skip to content

Commit c4f8992

Browse files
Merge branch 'develop' into SshCommandInputStream
2 parents 01733fb + bfe6718 commit c4f8992

File tree

13 files changed

+211
-269
lines changed

13 files changed

+211
-269
lines changed

appveyor.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ for:
1919

2020
build_script:
2121
- echo build
22-
- dotnet build Renci.SshNet.sln -c Debug -f net8.0
22+
- dotnet build -f net8.0 -c Debug test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
23+
- dotnet build -f net8.0 -c Debug test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
2324

2425
test_script:
2526
- sh: echo "Run unit tests"
2627
- sh: dotnet test -f net8.0 -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=linux_unit_test_net_8_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/linux_unit_test_net_8_coverage.xml test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
2728
- sh: echo "Run integration tests"
28-
- sh: dotnet test -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=linux_integration_test_net_8_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/linux_integration_test_net_8_coverage.xml test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
29+
- sh: dotnet test -f net8.0 -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=linux_integration_test_net_8_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/linux_integration_test_net_8_coverage.xml test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
2930

3031
# on_failure:
3132
# - sh: appveyor PushArtifact artifacts/tcpdump.pcap

src/Renci.SshNet/Session.cs

Lines changed: 178 additions & 184 deletions
Large diffs are not rendered by default.

test/Renci.SshNet.IntegrationTests/App.config

Lines changed: 0 additions & 23 deletions
This file was deleted.

test/Renci.SshNet.IntegrationTests/Common/DateTimeExtensions.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ public static class DateTimeExtensions
44
{
55
public static DateTime TruncateToWholeSeconds(this DateTime dateTime)
66
{
7-
return dateTime.AddMilliseconds(-dateTime.Millisecond)
8-
.AddMicroseconds(-dateTime.Microsecond)
9-
.AddTicks(-(dateTime.Nanosecond / 100));
7+
return new DateTime(dateTime.Ticks - (dateTime.Ticks % TimeSpan.TicksPerSecond), dateTime.Kind);
108
}
119
}
1210
}

test/Renci.SshNet.IntegrationTests/HostConfig.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ public static HostConfig Read(ScpClient scpClient, string path)
2929
while ((line = sr.ReadLine()) != null)
3030
{
3131
// skip comments
32+
#if NET
3233
if (line.StartsWith('#'))
34+
#else
35+
if (line.StartsWith("#"))
36+
#endif
3337
{
3438
continue;
3539
}

test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
using System.Diagnostics;
2+
#if !NET6_0_OR_GREATER
3+
using System.Net;
4+
#endif
25

36
using Renci.SshNet.Common;
47

@@ -46,8 +49,8 @@ public void Test_PortForwarding_Local_Stop_Hangs_On_Wait()
4649
.GetAwaiter()
4750
.GetResult();
4851
#else
49-
var request = (HttpWebRequest) WebRequest.Create(url);
50-
var response = (HttpWebResponse) request.GetResponse();
52+
var request = (HttpWebRequest) WebRequest.Create(url);
53+
var response = (HttpWebResponse) request.GetResponse();
5154
#endif // NET6_0_OR_GREATER
5255

5356
Assert.IsNotNull(response);
@@ -122,10 +125,10 @@ public void Test_PortForwarding_Local_Without_Connecting()
122125
{
123126
var data = ReadStream(response.Content.ReadAsStream());
124127
#else
125-
var request = (HttpWebRequest) WebRequest.Create("http://localhost:8084");
126-
using (var response = (HttpWebResponse) request.GetResponse())
127-
{
128-
var data = ReadStream(response.GetResponseStream());
128+
var request = (HttpWebRequest) WebRequest.Create("http://localhost:8084");
129+
using (var response = (HttpWebResponse) request.GetResponse())
130+
{
131+
var data = ReadStream(response.GetResponseStream());
129132
#endif // NET6_0_OR_GREATER
130133
var end = DateTime.Now;
131134

test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ protected static string CalculateMD5(string fileName)
1414
{
1515
using (FileStream file = new FileStream(fileName, FileMode.Open))
1616
{
17-
var hash = MD5.HashData(file);
17+
byte[] hash;
18+
using (var md5 = MD5.Create())
19+
{
20+
hash = md5.ComputeHash(file);
21+
}
1822

1923
file.Close();
2024

test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -442,47 +442,18 @@ public void Test_Execute_Invalid_Command()
442442
}
443443
}
444444

445-
[TestMethod]
446-
public void Test_MultipleThread_Example_MultipleConnections()
447-
{
448-
try
449-
{
450-
#region Example SshCommand RunCommand Parallel
451-
Parallel.For(0, 100,
452-
() =>
453-
{
454-
var client = new SshClient(SshServerHostName, SshServerPort, User.UserName, User.Password);
455-
client.Connect();
456-
return client;
457-
},
458-
(int counter, ParallelLoopState pls, SshClient client) =>
459-
{
460-
var result = client.RunCommand("echo 123");
461-
Debug.WriteLine(string.Format("TestMultipleThreadMultipleConnections #{0}", counter));
462-
return client;
463-
},
464-
(SshClient client) =>
465-
{
466-
client.Disconnect();
467-
client.Dispose();
468-
}
469-
);
470-
#endregion
471-
472-
}
473-
catch (Exception exp)
474-
{
475-
Assert.Fail(exp.ToString());
476-
}
477-
}
478-
479445
[TestMethod]
480446

481447
public void Test_MultipleThread_100_MultipleConnections()
482448
{
483449
try
484450
{
485-
Parallel.For(0, 100,
451+
var options = new ParallelOptions()
452+
{
453+
MaxDegreeOfParallelism = 8
454+
};
455+
456+
Parallel.For(0, 100, options,
486457
() =>
487458
{
488459
var client = new SshClient(SshServerHostName, SshServerPort, User.UserName, User.Password);

test/Renci.SshNet.IntegrationTests/Program.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net48;net8.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<IsPackable>false</IsPackable>
77
<IsTestProject>true</IsTestProject>
88
<NoWarn>$(NoWarn);SYSLIB0021;SYSLIB1045;SYSLIB0014;IDE0220;IDE0010</NoWarn>
9+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
910
</PropertyGroup>
1011

1112
<ItemGroup>

0 commit comments

Comments
 (0)