mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 01:05:42 +00:00
Enable all net48 integration tests (#1456)
* Enable all net48 integration tests * Skip ECDsa in net48 integration tests * Stabilise tests * Stabilise tests * Stabilise tests * Stabilise tests * Spelling
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ for:
|
||||
- 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
|
||||
- sh: echo "Run integration tests"
|
||||
- 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
|
||||
- sh: dotnet test -f net48 -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=linux_integration_test_net_48_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/linux_integration_test_net_48_coverage.xml --filter "Name=ChaCha20Poly1305|Name~Ecdh|Name~Zlib" test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
|
||||
- sh: dotnet test -f net48 -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=linux_integration_test_net_48_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/linux_integration_test_net_48_coverage.xml --filter Name\!~ECDsa test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
|
||||
|
||||
-
|
||||
matrix:
|
||||
|
||||
@@ -655,17 +655,32 @@ namespace Renci.SshNet.IntegrationTests
|
||||
var endpoint1 = new IPEndPoint(ipv4HostAddress, 10000);
|
||||
var endpoint2 = new IPEndPoint(ipv4HostAddress, 10001);
|
||||
|
||||
var areBytesReceivedOnListener1 = false;
|
||||
var areBytesReceivedOnListener2 = false;
|
||||
|
||||
var bytesReceivedOnListener1 = new List<byte>();
|
||||
var bytesReceivedOnListener2 = new List<byte>();
|
||||
|
||||
using (var socketListener1 = new AsyncSocketListener(endpoint1))
|
||||
using (var socketListener2 = new AsyncSocketListener(endpoint2))
|
||||
using (var bytesReceivedEventOnListener1 = new AutoResetEvent(false))
|
||||
using (var bytesReceivedEventOnListener2 = new AutoResetEvent(false))
|
||||
using (var client = new SshClient(_connectionInfoFactory.Create()))
|
||||
{
|
||||
socketListener1.BytesReceived += (received, socket) => bytesReceivedOnListener1.AddRange(received);
|
||||
socketListener1.BytesReceived += (received, socket) =>
|
||||
{
|
||||
bytesReceivedOnListener1.AddRange(received);
|
||||
bytesReceivedEventOnListener1.Set();
|
||||
};
|
||||
|
||||
socketListener1.Start();
|
||||
|
||||
socketListener2.BytesReceived += (received, socket) => bytesReceivedOnListener2.AddRange(received);
|
||||
socketListener2.BytesReceived += (received, socket) =>
|
||||
{
|
||||
bytesReceivedOnListener2.AddRange(received);
|
||||
bytesReceivedEventOnListener2.Set();
|
||||
};
|
||||
|
||||
socketListener2.Start();
|
||||
|
||||
client.Connect();
|
||||
@@ -706,10 +721,16 @@ namespace Renci.SshNet.IntegrationTests
|
||||
s.Close();
|
||||
}
|
||||
|
||||
areBytesReceivedOnListener1 = bytesReceivedEventOnListener1.WaitOne(1000);
|
||||
areBytesReceivedOnListener2 = bytesReceivedEventOnListener2.WaitOne(1000);
|
||||
|
||||
forwardedPort1.Stop();
|
||||
forwardedPort2.Stop();
|
||||
}
|
||||
|
||||
Assert.IsTrue(areBytesReceivedOnListener1);
|
||||
Assert.IsTrue(areBytesReceivedOnListener2);
|
||||
|
||||
var textReceivedOnListener1 = Encoding.ASCII.GetString(bytesReceivedOnListener1.ToArray());
|
||||
Assert.AreEqual("ABC\r\n", textReceivedOnListener1);
|
||||
|
||||
|
||||
+1
-1
@@ -61,6 +61,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
_closeTimer.Start();
|
||||
Thread.Sleep(100);
|
||||
// raise ChannelCloseReceived event to set waithandle for receiving
|
||||
// SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
|
||||
@@ -68,7 +69,6 @@ namespace Renci.SshNet.Tests.Classes.Channels
|
||||
SessionMock.Raise(s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}).Start();
|
||||
_closeTimer.Start();
|
||||
try
|
||||
{
|
||||
waitHandle.WaitOne();
|
||||
|
||||
+1
-1
@@ -66,6 +66,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
_closeTimer.Start();
|
||||
Thread.Sleep(100);
|
||||
// raise ChannelCloseReceived event to set waithandle for receiving
|
||||
// SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
|
||||
@@ -74,7 +75,6 @@ namespace Renci.SshNet.Tests.Classes.Channels
|
||||
new MessageEventArgs<ChannelCloseMessage>(
|
||||
new ChannelCloseMessage(_localChannelNumber)));
|
||||
}).Start();
|
||||
_closeTimer.Start();
|
||||
try
|
||||
{
|
||||
w.WaitOne();
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace Renci.SshNet.Tests.Classes
|
||||
[TestMethod]
|
||||
public void IncludeStrictKexPseudoAlgorithmInInitKex()
|
||||
{
|
||||
Assert.IsTrue(FirstKexReceived.Wait(1000));
|
||||
Assert.IsTrue(ServerBytesReceivedRegister.Count > 0);
|
||||
|
||||
var kexInitMessage = new KeyExchangeInitMessage();
|
||||
@@ -51,7 +52,9 @@ namespace Renci.SshNet.Tests.Classes
|
||||
[TestMethod]
|
||||
public void ShouldNotIncludeStrictKexPseudoAlgorithmInSubsequentKex()
|
||||
{
|
||||
using var kexReceived = new ManualResetEventSlim();
|
||||
Assert.IsTrue(FirstKexReceived.Wait(1000));
|
||||
|
||||
using var subsequentKexReceived = new ManualResetEventSlim();
|
||||
bool kexContainsPseudoAlg = true;
|
||||
|
||||
ServerListener.BytesReceived += ServerListener_BytesReceived;
|
||||
@@ -64,13 +67,13 @@ namespace Renci.SshNet.Tests.Classes
|
||||
var kexInitMessage = new KeyExchangeInitMessage();
|
||||
kexInitMessage.Load(bytesReceived, 6, bytesReceived.Length - 6);
|
||||
kexContainsPseudoAlg = kexInitMessage.KeyExchangeAlgorithms.Contains("kex-strict-c-v00@openssh.com");
|
||||
kexReceived.Set();
|
||||
subsequentKexReceived.Set();
|
||||
}
|
||||
}
|
||||
|
||||
Session.SendMessage(Session.ClientInitMessage);
|
||||
|
||||
Assert.IsTrue(kexReceived.Wait(1000));
|
||||
Assert.IsTrue(subsequentKexReceived.Wait(1000));
|
||||
Assert.IsFalse(kexContainsPseudoAlg);
|
||||
|
||||
ServerListener.BytesReceived -= ServerListener_BytesReceived;
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Globalization;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
@@ -43,6 +44,7 @@ namespace Renci.SshNet.Tests.Classes
|
||||
protected IList<ExceptionEventArgs> ErrorOccurredRegister { get; private set; }
|
||||
protected AsyncSocketListener ServerListener { get; private set; }
|
||||
protected IList<byte[]> ServerBytesReceivedRegister { get; private set; }
|
||||
protected ManualResetEventSlim FirstKexReceived { get; private set; }
|
||||
protected Session Session { get; private set; }
|
||||
protected Socket ClientSocket { get; private set; }
|
||||
protected Socket ServerSocket { get; private set; }
|
||||
@@ -87,6 +89,12 @@ namespace Renci.SshNet.Tests.Classes
|
||||
ClientSocket.Shutdown(SocketShutdown.Both);
|
||||
ClientSocket.Dispose();
|
||||
}
|
||||
|
||||
if (FirstKexReceived != null)
|
||||
{
|
||||
FirstKexReceived.Dispose();
|
||||
FirstKexReceived = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void SetupData()
|
||||
@@ -107,6 +115,7 @@ namespace Renci.SshNet.Tests.Classes
|
||||
DisconnectReceivedRegister = new List<MessageEventArgs<DisconnectMessage>>();
|
||||
ErrorOccurredRegister = new List<ExceptionEventArgs>();
|
||||
ServerBytesReceivedRegister = new List<byte[]>();
|
||||
FirstKexReceived = new ManualResetEventSlim();
|
||||
ServerIdentification = new SshIdentification("2.0", "OurServerStub");
|
||||
_authenticationStarted = false;
|
||||
_socketFactory = new SocketFactory();
|
||||
@@ -151,11 +160,16 @@ namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
ServerBytesReceivedRegister.Add(received);
|
||||
|
||||
if (WaitForClientKeyExchangeInit && received.Length > 5 && received[5] == 20)
|
||||
if (received.Length > 5 && received[5] == 20)
|
||||
{
|
||||
// This is the KEXINIT. Send one back.
|
||||
SendKeyExchangeInit();
|
||||
WaitForClientKeyExchangeInit = false;
|
||||
if (WaitForClientKeyExchangeInit)
|
||||
{
|
||||
// This is the KEXINIT. Send one back.
|
||||
SendKeyExchangeInit();
|
||||
WaitForClientKeyExchangeInit = false;
|
||||
}
|
||||
|
||||
FirstKexReceived.Set();
|
||||
}
|
||||
};
|
||||
ServerListener.Start();
|
||||
|
||||
Reference in New Issue
Block a user