diff --git a/appveyor.yml b/appveyor.yml index c9bb51683..883cb4cdd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,14 +1,46 @@ -os: Visual Studio 2022 +image: + - Visual Studio 2022 + - Ubuntu before_build: - - nuget restore src\Renci.SshNet.sln +- cmd: >- + nuget restore src\Renci.SshNet.sln +- sh: >- + dotnet restore src/Renci.SshNet.sln build: project: src\Renci.SshNet.sln verbosity: minimal -test_script: -- cmd: >- - vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net462\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration" --blame +configuration: + - Debug + - Release + +for: +- + matrix: + only: + - configuration: Debug + + test_script: + - cmd: >- + vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net462\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration" --blame - vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net7.0\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration" --blame + dotnet test src\Renci.SshNet.Tests\bin\Debug\net7.0\Renci.SshNet.Tests.dll --logger Appveyor --filter "TestCategory!=integration" --blame + + - sh: >- + dotnet test src/Renci.SshNet.Tests/bin/Debug/net7.0/Renci.SshNet.Tests.dll --logger Appveyor --filter "TestCategory!=integration" --blame + +- + matrix: + only: + - configuration: Release + + test_script: + - cmd: >- + vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Release\net462\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration" --blame + + dotnet test src\Renci.SshNet.Tests\bin\Release\net7.0\Renci.SshNet.Tests.dll --logger Appveyor --filter "TestCategory!=integration" --blame + + - sh: >- + dotnet test src/Renci.SshNet.Tests/bin/Release/net7.0/Renci.SshNet.Tests.dll --logger Appveyor --filter "TestCategory!=integration" --blame \ No newline at end of file diff --git a/src/Renci.SshNet.Tests/Classes/Common/SemaphoreLightTest.cs b/src/Renci.SshNet.Tests/Classes/Common/SemaphoreLightTest.cs index 17d5e72f2..94201a9bd 100644 --- a/src/Renci.SshNet.Tests/Classes/Common/SemaphoreLightTest.cs +++ b/src/Renci.SshNet.Tests/Classes/Common/SemaphoreLightTest.cs @@ -78,7 +78,7 @@ public void WaitTest() watch.Stop(); - Assert.IsTrue(watch.ElapsedMilliseconds > 200); + Assert.IsTrue(watch.ElapsedMilliseconds >= sleepTime - 5); Assert.IsTrue(watch.ElapsedMilliseconds < 250); } diff --git a/src/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTestBase.cs b/src/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTestBase.cs index d1989c3de..7eb9040e9 100644 --- a/src/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTestBase.cs +++ b/src/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTestBase.cs @@ -36,7 +36,7 @@ protected sealed override void Arrange() protected ConnectionInfo CreateConnectionInfo(string hostName) { return new ConnectionInfo(hostName, - 777, + 1027, "user", new KeyboardInteractiveAuthenticationMethod("user")); } diff --git a/src/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_TimeoutConnectingToServer.cs b/src/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_TimeoutConnectingToServer.cs index 661b286ae..64e8bfe13 100644 --- a/src/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_TimeoutConnectingToServer.cs +++ b/src/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_TimeoutConnectingToServer.cs @@ -27,7 +27,7 @@ protected override void SetupData() var random = new Random(); _connectionInfo = CreateConnectionInfo(IPAddress.Loopback.ToString()); - _connectionInfo.Timeout = TimeSpan.FromMilliseconds(random.Next(50, 200)); + _connectionInfo.Timeout = TimeSpan.FromMilliseconds(random.Next(0, 5)); _stopWatch = new Stopwatch(); _actualException = null; diff --git a/src/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutConnectingToProxy.cs b/src/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutConnectingToProxy.cs index bb8041c89..815543700 100644 --- a/src/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutConnectingToProxy.cs +++ b/src/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutConnectingToProxy.cs @@ -36,7 +36,7 @@ protected override void SetupData() "proxyPwd", new KeyboardInteractiveAuthenticationMethod("user")) { - Timeout = TimeSpan.FromMilliseconds(random.Next(50, 200)) + Timeout = TimeSpan.FromMilliseconds(random.Next(0, 5)) }; _stopWatch = new Stopwatch(); _actualException = null; diff --git a/src/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutReadingHttpContent.cs b/src/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutReadingHttpContent.cs index 98ffde6aa..6808bfb50 100644 --- a/src/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutReadingHttpContent.cs +++ b/src/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutReadingHttpContent.cs @@ -36,7 +36,7 @@ protected override void SetupData() var random = new Random(); _connectionInfo = new ConnectionInfo(IPAddress.Loopback.ToString(), - 777, + 1026, "user", ProxyTypes.Http, IPAddress.Loopback.ToString(), diff --git a/src/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutReadingStatusLine.cs b/src/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutReadingStatusLine.cs index bec205f1a..38f65634c 100644 --- a/src/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutReadingStatusLine.cs +++ b/src/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutReadingStatusLine.cs @@ -32,7 +32,7 @@ protected override void SetupData() var random = new Random(); _connectionInfo = new ConnectionInfo(IPAddress.Loopback.ToString(), - 777, + 1028, "user", ProxyTypes.Http, IPAddress.Loopback.ToString(), diff --git a/src/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTestBase.cs b/src/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTestBase.cs index 0c3497f12..d8dbe8871 100644 --- a/src/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTestBase.cs +++ b/src/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTestBase.cs @@ -38,7 +38,7 @@ protected sealed override void Arrange() protected ConnectionInfo CreateConnectionInfo(string proxyUser, string proxyPassword) { return new ConnectionInfo(IPAddress.Loopback.ToString(), - 777, + 1025, "user", ProxyTypes.Socks4, IPAddress.Loopback.ToString(), diff --git a/src/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTest_Connect_ConnectionSucceeded.cs b/src/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTest_Connect_ConnectionSucceeded.cs index 5aabb8164..7edde74c5 100644 --- a/src/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTest_Connect_ConnectionSucceeded.cs +++ b/src/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTest_Connect_ConnectionSucceeded.cs @@ -103,8 +103,8 @@ public void ProxyShouldHaveReceivedExpectedSocksRequest() // CONNECT request 0x01, // Destination port - 0x03, - 0x09, + 0x04, + 0x01, // Destination address (IPv4) 0x7f, 0x00, diff --git a/src/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTest_Connect_TimeoutConnectingToProxy.cs b/src/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTest_Connect_TimeoutConnectingToProxy.cs index d7ad42157..a76d07482 100644 --- a/src/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTest_Connect_TimeoutConnectingToProxy.cs +++ b/src/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTest_Connect_TimeoutConnectingToProxy.cs @@ -23,7 +23,7 @@ protected override void SetupData() var random = new Random(); _connectionInfo = CreateConnectionInfo("proxyUser", "proxyPwd"); - _connectionInfo.Timeout = TimeSpan.FromMilliseconds(random.Next(50, 200)); + _connectionInfo.Timeout = TimeSpan.FromMilliseconds(random.Next(0, 5)); _stopWatch = new Stopwatch(); _clientSocket = SocketFactory.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _actualException = null; diff --git a/src/Renci.SshNet.Tests/Classes/Connection/Socks5ConnectorTest_Connect_TimeoutConnectingToProxy.cs b/src/Renci.SshNet.Tests/Classes/Connection/Socks5ConnectorTest_Connect_TimeoutConnectingToProxy.cs index 720c24ff9..3ebe4e01f 100644 --- a/src/Renci.SshNet.Tests/Classes/Connection/Socks5ConnectorTest_Connect_TimeoutConnectingToProxy.cs +++ b/src/Renci.SshNet.Tests/Classes/Connection/Socks5ConnectorTest_Connect_TimeoutConnectingToProxy.cs @@ -26,7 +26,7 @@ protected override void SetupData() var random = new Random(); _connectionInfo = CreateConnectionInfo("proxyUser", "proxyPwd"); - _connectionInfo.Timeout = TimeSpan.FromMilliseconds(random.Next(50, 200)); + _connectionInfo.Timeout = TimeSpan.FromMilliseconds(random.Next(0, 5)); _stopWatch = new Stopwatch(); _actualException = null; diff --git a/src/Renci.SshNet.Tests/Classes/SftpClientTest.ConnectAsync.cs b/src/Renci.SshNet.Tests/Classes/SftpClientTest.ConnectAsync.cs index df7a8f0b6..88ab436db 100644 --- a/src/Renci.SshNet.Tests/Classes/SftpClientTest.ConnectAsync.cs +++ b/src/Renci.SshNet.Tests/Classes/SftpClientTest.ConnectAsync.cs @@ -21,7 +21,7 @@ public async Task ConnectAsync_HostNameInvalid_ShouldThrowSocketExceptionWithErr } catch (SocketException ex) { - Assert.AreEqual(SocketError.HostNotFound, ex.SocketErrorCode); + Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain, $"Socket error is {ex.SocketErrorCode}"); } } @@ -39,8 +39,8 @@ public async Task ConnectAsync_ProxyHostNameInvalid_ShouldThrowSocketExceptionWi } catch (SocketException ex) { - Assert.AreEqual(SocketError.HostNotFound, ex.SocketErrorCode); + Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain, $"Socket error is {ex.SocketErrorCode}"); } } } -} \ No newline at end of file +} diff --git a/src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj b/src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj index aa9d79a2a..6a3c424c6 100644 --- a/src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj +++ b/src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj @@ -38,6 +38,7 @@ +