From 1ffb637682a09ebcd4fbd0a08953db41d4ee36ac Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Sun, 28 Sep 2025 11:52:17 +0200 Subject: [PATCH 01/12] CI: add Windows Integration Tests for .NET see https://github.com/sshnet/SSH.NET/pull/1702#issuecomment-3342506642 --- .github/workflows/build.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1bc033d8e..83d24d534 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -139,6 +139,17 @@ jobs: -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_4_8_coverage.xml ` test\Renci.SshNet.IntegrationTests\ + - name: Run Integration Tests .NET + run: + dotnet test ` + -f net9.0 ` + --logger "console;verbosity=normal" ` + --logger GitHubActions ` + -p:CollectCoverage=true ` + -p:CoverletOutputFormat=cobertura ` + -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_9_coverage.xml ` + test\Renci.SshNet.IntegrationTests\ + - name: Archive Coverlet Results uses: actions/upload-artifact@v4 with: From 58f7dd4351345597458844b578d5874ae9cd8015 Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Sun, 28 Sep 2025 12:55:44 +0200 Subject: [PATCH 02/12] fix podman setup with Windows and .NET --- .../TestsFixtures/InfrastructureFixture.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs b/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs index bcdb00d76..cdf094c5d 100644 --- a/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs +++ b/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs @@ -1,4 +1,6 @@ -using DotNet.Testcontainers.Builders; +using System.Runtime.InteropServices; + +using DotNet.Testcontainers.Builders; using DotNet.Testcontainers.Containers; using DotNet.Testcontainers.Images; @@ -38,16 +40,16 @@ private InfrastructureFixture() public async Task InitializeAsync() { - // for the .NET Framework Tests in CI, the Container is set up in WSL2 with Podman -#if NETFRAMEWORK - if (Environment.GetEnvironmentVariable("CI") == "true") +#pragma warning disable MA0144 // use System.OperatingSystem to check the current OS + // for the Windows Tests in CI, the Container is set up in WSL2 with Podman + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Environment.GetEnvironmentVariable("CI") == "true") +#pragma warning restore MA0144 // use System.OperatingSystem to check the current OS { SshServerPort = 2222; SshServerHostName = "localhost"; await Task.Delay(1_000); return; } -#endif var containerLogger = _loggerFactory.CreateLogger("testcontainers"); From eae52153e0a964bf3551753aa2519b17492c6901 Mon Sep 17 00:00:00 2001 From: Rob Hague Date: Sun, 28 Sep 2025 19:19:49 +0200 Subject: [PATCH 03/12] debug --- .github/workflows/build.yml | 198 +++++++++--------- .../TestsFixtures/InfrastructureFixture.cs | 28 ++- 2 files changed, 122 insertions(+), 104 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c211c9539..ac65bf110 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,102 +6,102 @@ on: - workflow_dispatch jobs: - Linux: - runs-on: ubuntu-24.04 - steps: - - name: Checkout - uses: actions/checkout@v5 - with: - fetch-depth: 0 # needed for Nerdbank.GitVersioning - - - name: Setup .NET - uses: actions/setup-dotnet@v4 - - - name: Build Unit Tests .NET - run: dotnet build -f net9.0 test/Renci.SshNet.Tests/ - - - name: Build IntegrationTests .NET - run: dotnet build -f net9.0 test/Renci.SshNet.IntegrationTests/ - - - name: Run Unit Tests .NET - run: | - dotnet test \ - -f net9.0 \ - --no-build \ - --logger "console;verbosity=normal" \ - --logger GitHubActions \ - -p:CollectCoverage=true \ - -p:CoverletOutputFormat=cobertura \ - -p:CoverletOutput=../../coverlet/linux_unit_test_net_9_coverage.xml \ - test/Renci.SshNet.Tests/ - - - name: Run Integration Tests .NET - run: | - dotnet test \ - -f net9.0 \ - --no-build \ - --logger "console;verbosity=normal" \ - --logger GitHubActions \ - -p:CollectCoverage=true \ - -p:CoverletOutputFormat=cobertura \ - -p:CoverletOutput=../../coverlet/linux_integration_test_net_9_coverage.xml \ - test/Renci.SshNet.IntegrationTests/ - - - name: Archive Coverlet Results - uses: actions/upload-artifact@v4 - with: - name: Coverlet Results Linux - path: coverlet - - Windows: - runs-on: windows-2025 - steps: - - name: Checkout - uses: actions/checkout@v5 - with: - fetch-depth: 0 # needed for Nerdbank.GitVersioning - - - name: Setup .NET - uses: actions/setup-dotnet@v4 - - - name: Build Solution - run: dotnet build Renci.SshNet.sln - - - name: Publish AOT Compatibility Test App - run: dotnet publish -r win-x64 /warnaserror test/Renci.SshNet.AotCompatibilityTestApp/ - - - name: Create NuGet Package - run: dotnet pack - - - name: Archive NuGet Package - uses: actions/upload-artifact@v4 - with: - name: NuGet Package - path: src/Renci.SshNet/bin/Release/*.*nupkg - - - name: Run Unit Tests .NET - run: | - dotnet test ` - -f net9.0 ` - --no-build ` - --logger "console;verbosity=normal" ` - --logger GitHubActions ` - -p:CollectCoverage=true ` - -p:CoverletOutputFormat=cobertura ` - -p:CoverletOutput=../../coverlet/windows_unit_test_net_9_coverage.xml ` - test/Renci.SshNet.Tests/ - - - name: Run Unit Tests .NET Framework - run: | - dotnet test ` - -f net462 ` - --no-build ` - --logger "console;verbosity=normal" ` - --logger GitHubActions ` - -p:CollectCoverage=true ` - -p:CoverletOutputFormat=cobertura ` - -p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml ` - test/Renci.SshNet.Tests/ + # Linux: + # runs-on: ubuntu-24.04 + # steps: + # - name: Checkout + # uses: actions/checkout@v5 + # with: + # fetch-depth: 0 # needed for Nerdbank.GitVersioning + + # - name: Setup .NET + # uses: actions/setup-dotnet@v4 + + # - name: Build Unit Tests .NET + # run: dotnet build -f net9.0 test/Renci.SshNet.Tests/ + + # - name: Build IntegrationTests .NET + # run: dotnet build -f net9.0 test/Renci.SshNet.IntegrationTests/ + + # - name: Run Unit Tests .NET + # run: | + # dotnet test \ + # -f net9.0 \ + # --no-build \ + # --logger "console;verbosity=normal" \ + # --logger GitHubActions \ + # -p:CollectCoverage=true \ + # -p:CoverletOutputFormat=cobertura \ + # -p:CoverletOutput=../../coverlet/linux_unit_test_net_9_coverage.xml \ + # test/Renci.SshNet.Tests/ + + # - name: Run Integration Tests .NET + # run: | + # dotnet test \ + # -f net9.0 \ + # --no-build \ + # --logger "console;verbosity=normal" \ + # --logger GitHubActions \ + # -p:CollectCoverage=true \ + # -p:CoverletOutputFormat=cobertura \ + # -p:CoverletOutput=../../coverlet/linux_integration_test_net_9_coverage.xml \ + # test/Renci.SshNet.IntegrationTests/ + + # - name: Archive Coverlet Results + # uses: actions/upload-artifact@v4 + # with: + # name: Coverlet Results Linux + # path: coverlet + + # Windows: + # runs-on: windows-2025 + # steps: + # - name: Checkout + # uses: actions/checkout@v5 + # with: + # fetch-depth: 0 # needed for Nerdbank.GitVersioning + + # - name: Setup .NET + # uses: actions/setup-dotnet@v4 + + # - name: Build Solution + # run: dotnet build Renci.SshNet.sln + + # - name: Publish AOT Compatibility Test App + # run: dotnet publish -r win-x64 /warnaserror test/Renci.SshNet.AotCompatibilityTestApp/ + + # - name: Create NuGet Package + # run: dotnet pack + + # - name: Archive NuGet Package + # uses: actions/upload-artifact@v4 + # with: + # name: NuGet Package + # path: src/Renci.SshNet/bin/Release/*.*nupkg + + # - name: Run Unit Tests .NET + # run: | + # dotnet test ` + # -f net9.0 ` + # --no-build ` + # --logger "console;verbosity=normal" ` + # --logger GitHubActions ` + # -p:CollectCoverage=true ` + # -p:CoverletOutputFormat=cobertura ` + # -p:CoverletOutput=../../coverlet/windows_unit_test_net_9_coverage.xml ` + # test/Renci.SshNet.Tests/ + + # - name: Run Unit Tests .NET Framework + # run: | + # dotnet test ` + # -f net462 ` + # --no-build ` + # --logger "console;verbosity=normal" ` + # --logger GitHubActions ` + # -p:CollectCoverage=true ` + # -p:CoverletOutputFormat=cobertura ` + # -p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml ` + # test/Renci.SshNet.Tests/ Windows-Integration-Tests: name: Windows Integration Tests @@ -132,8 +132,9 @@ jobs: run: dotnet test ` -f net48 ` - --logger "console;verbosity=normal" ` + --logger "console;verbosity=detailed" ` --logger GitHubActions ` + --filter "Name~Common_CreateMoreChannelsThanMaxSessions" ` -p:CollectCoverage=true ` -p:CoverletOutputFormat=cobertura ` -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_4_8_coverage.xml ` @@ -143,8 +144,9 @@ jobs: run: dotnet test ` -f net9.0 ` - --logger "console;verbosity=normal" ` + --logger "console;verbosity=detailed" ` --logger GitHubActions ` + --filter "Name~Common_CreateMoreChannelsThanMaxSessions" ` -p:CollectCoverage=true ` -p:CoverletOutputFormat=cobertura ` -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_9_coverage.xml ` diff --git a/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs b/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs index cdf094c5d..4c17c2279 100644 --- a/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs +++ b/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs @@ -30,19 +30,20 @@ private InfrastructureFixture() private IFutureDockerImage _sshServerImage; - public string SshServerHostName { get; set; } + public string SshServerHostName { get; private set; } - public ushort SshServerPort { get; set; } + public ushort SshServerPort { get; private set; } - public SshUser AdminUser = new SshUser("sshnetadm", "ssh4ever"); + public SshUser AdminUser { get; } = new SshUser("sshnetadm", "ssh4ever"); - public SshUser User = new SshUser("sshnet", "ssh4ever"); + public SshUser User { get; } = new SshUser("sshnet", "ssh4ever"); public async Task InitializeAsync() { #pragma warning disable MA0144 // use System.OperatingSystem to check the current OS // for the Windows Tests in CI, the Container is set up in WSL2 with Podman - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Environment.GetEnvironmentVariable("CI") == "true") + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && + Environment.GetEnvironmentVariable("CI") == "true") #pragma warning restore MA0144 // use System.OperatingSystem to check the current OS { SshServerPort = 2222; @@ -86,9 +87,24 @@ public async Task InitializeAsync() public async Task DisposeAsync() { +#pragma warning disable S6966 // Awaitable method should be used + try + { + using SftpClient client = new(new LinuxAdminConnectionFactory(SshServerHostName, SshServerPort).Create()); + + client.Connect(); + + Console.WriteLine("=== start auth.log ==="); + Console.WriteLine(client.ReadAllText("/var/log/auth.log")); + Console.WriteLine("=== end auth.log ==="); + } + catch (Exception ex) + { + Console.Error.WriteLine(ex.ToString()); + } + if (_sshServer != null) { -#pragma warning disable S6966 // Awaitable method should be used //try //{ // File.WriteAllBytes(@"C:\tmp\auth.log", await _sshServer.ReadFileAsync("/var/log/auth.log").ConfigureAwait(false)); From 02f71a8735b13ddcea0bb08dbde287100025cc49 Mon Sep 17 00:00:00 2001 From: Robert Hague Date: Mon, 29 Sep 2025 20:25:59 +0200 Subject: [PATCH 04/12] x --- .github/workflows/build.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac65bf110..a245cfc0d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,13 +6,13 @@ on: - workflow_dispatch jobs: - # Linux: - # runs-on: ubuntu-24.04 - # steps: - # - name: Checkout - # uses: actions/checkout@v5 - # with: - # fetch-depth: 0 # needed for Nerdbank.GitVersioning + Linux: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 0 # needed for Nerdbank.GitVersioning # - name: Setup .NET # uses: actions/setup-dotnet@v4 @@ -53,13 +53,13 @@ jobs: # name: Coverlet Results Linux # path: coverlet - # Windows: - # runs-on: windows-2025 - # steps: - # - name: Checkout - # uses: actions/checkout@v5 - # with: - # fetch-depth: 0 # needed for Nerdbank.GitVersioning + Windows: + runs-on: windows-2025 + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 0 # needed for Nerdbank.GitVersioning # - name: Setup .NET # uses: actions/setup-dotnet@v4 From b34dbb2aa42152ad57cac859ed3c25e13e376bd9 Mon Sep 17 00:00:00 2001 From: Robert Hague Date: Mon, 29 Sep 2025 20:51:32 +0200 Subject: [PATCH 05/12] x --- .github/workflows/build.yml | 10 +++++----- .github/workflows/docs.yml | 2 +- test/Renci.SshNet.IntegrationTests/Dockerfile | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a245cfc0d..cc50d7eab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: fetch-depth: 0 # needed for Nerdbank.GitVersioning # - name: Setup .NET - # uses: actions/setup-dotnet@v4 + # uses: actions/setup-dotnet@v5 # - name: Build Unit Tests .NET # run: dotnet build -f net9.0 test/Renci.SshNet.Tests/ @@ -62,7 +62,7 @@ jobs: fetch-depth: 0 # needed for Nerdbank.GitVersioning # - name: Setup .NET - # uses: actions/setup-dotnet@v4 + # uses: actions/setup-dotnet@v5 # - name: Build Solution # run: dotnet build Renci.SshNet.sln @@ -113,7 +113,7 @@ jobs: fetch-depth: 0 # needed for Nerdbank.GitVersioning - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 - name: Setup WSL2 uses: Vampire/setup-wsl@6a8db447be7ed35f2f499c02c6e60ff77ef11278 # v6.0.0 @@ -134,7 +134,7 @@ jobs: -f net48 ` --logger "console;verbosity=detailed" ` --logger GitHubActions ` - --filter "Name~Common_CreateMoreChannelsThanMaxSessions" ` + --filter "Name~ConnectivityTests" ` -p:CollectCoverage=true ` -p:CoverletOutputFormat=cobertura ` -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_4_8_coverage.xml ` @@ -146,7 +146,7 @@ jobs: -f net9.0 ` --logger "console;verbosity=detailed" ` --logger GitHubActions ` - --filter "Name~Common_CreateMoreChannelsThanMaxSessions" ` + --filter "Name~ConnectivityTests" ` -p:CollectCoverage=true ` -p:CoverletOutputFormat=cobertura ` -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_9_coverage.xml ` diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b989c225e..d33343dc0 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -28,7 +28,7 @@ jobs: uses: actions/configure-pages@v5 - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 - name: Setup docfx run: dotnet tool update -g docfx diff --git a/test/Renci.SshNet.IntegrationTests/Dockerfile b/test/Renci.SshNet.IntegrationTests/Dockerfile index 4bf20a3e2..f7a471a15 100644 --- a/test/Renci.SshNet.IntegrationTests/Dockerfile +++ b/test/Renci.SshNet.IntegrationTests/Dockerfile @@ -41,6 +41,7 @@ RUN apk update && apk upgrade --no-cache && \ echo 'sshnetadm:ssh4ever' | chpasswd && \ addgroup sshnetadm sudo && \ dos2unix /opt/sshnet/* && \ + chmod -R 777 /var/log && \ # install shadow package; we use chage command in this package to expire/unexpire password of the sshnet user apk add --no-cache shadow && \ # allow us to use telnet command; we use this in the remote port forwarding tests From 3be454040ea69afc7ecd264a35951a2d3876e1a6 Mon Sep 17 00:00:00 2001 From: Robert Hague Date: Mon, 29 Sep 2025 21:00:15 +0200 Subject: [PATCH 06/12] x --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc50d7eab..f47277c2b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -134,7 +134,7 @@ jobs: -f net48 ` --logger "console;verbosity=detailed" ` --logger GitHubActions ` - --filter "Name~ConnectivityTests" ` + --filter "FullyQualifiedName~ConnectivityTests" ` -p:CollectCoverage=true ` -p:CoverletOutputFormat=cobertura ` -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_4_8_coverage.xml ` @@ -146,7 +146,7 @@ jobs: -f net9.0 ` --logger "console;verbosity=detailed" ` --logger GitHubActions ` - --filter "Name~ConnectivityTests" ` + --filter "FullyQualifiedName~ConnectivityTests" ` -p:CollectCoverage=true ` -p:CoverletOutputFormat=cobertura ` -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_9_coverage.xml ` From c5f9f40ac9f22944a75d60730d9bc8fa0b71dd1f Mon Sep 17 00:00:00 2001 From: Rob Hague Date: Wed, 1 Oct 2025 20:22:29 +0200 Subject: [PATCH 07/12] revert --- .github/workflows/build.yml | 164 +++++++++--------- test/Renci.SshNet.IntegrationTests/Dockerfile | 1 - .../TestsFixtures/InfrastructureFixture.cs | 17 +- 3 files changed, 82 insertions(+), 100 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f47277c2b..da5c8e31c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,44 +14,44 @@ jobs: with: fetch-depth: 0 # needed for Nerdbank.GitVersioning - # - name: Setup .NET - # uses: actions/setup-dotnet@v5 - - # - name: Build Unit Tests .NET - # run: dotnet build -f net9.0 test/Renci.SshNet.Tests/ - - # - name: Build IntegrationTests .NET - # run: dotnet build -f net9.0 test/Renci.SshNet.IntegrationTests/ - - # - name: Run Unit Tests .NET - # run: | - # dotnet test \ - # -f net9.0 \ - # --no-build \ - # --logger "console;verbosity=normal" \ - # --logger GitHubActions \ - # -p:CollectCoverage=true \ - # -p:CoverletOutputFormat=cobertura \ - # -p:CoverletOutput=../../coverlet/linux_unit_test_net_9_coverage.xml \ - # test/Renci.SshNet.Tests/ - - # - name: Run Integration Tests .NET - # run: | - # dotnet test \ - # -f net9.0 \ - # --no-build \ - # --logger "console;verbosity=normal" \ - # --logger GitHubActions \ - # -p:CollectCoverage=true \ - # -p:CoverletOutputFormat=cobertura \ - # -p:CoverletOutput=../../coverlet/linux_integration_test_net_9_coverage.xml \ - # test/Renci.SshNet.IntegrationTests/ - - # - name: Archive Coverlet Results - # uses: actions/upload-artifact@v4 - # with: - # name: Coverlet Results Linux - # path: coverlet + - name: Setup .NET + uses: actions/setup-dotnet@v5 + + - name: Build Unit Tests .NET + run: dotnet build -f net9.0 test/Renci.SshNet.Tests/ + + - name: Build IntegrationTests .NET + run: dotnet build -f net9.0 test/Renci.SshNet.IntegrationTests/ + + - name: Run Unit Tests .NET + run: | + dotnet test \ + -f net9.0 \ + --no-build \ + --logger "console;verbosity=normal" \ + --logger GitHubActions \ + -p:CollectCoverage=true \ + -p:CoverletOutputFormat=cobertura \ + -p:CoverletOutput=../../coverlet/linux_unit_test_net_9_coverage.xml \ + test/Renci.SshNet.Tests/ + + - name: Run Integration Tests .NET + run: | + dotnet test \ + -f net9.0 \ + --no-build \ + --logger "console;verbosity=normal" \ + --logger GitHubActions \ + -p:CollectCoverage=true \ + -p:CoverletOutputFormat=cobertura \ + -p:CoverletOutput=../../coverlet/linux_integration_test_net_9_coverage.xml \ + test/Renci.SshNet.IntegrationTests/ + + - name: Archive Coverlet Results + uses: actions/upload-artifact@v4 + with: + name: Coverlet Results Linux + path: coverlet Windows: runs-on: windows-2025 @@ -61,47 +61,47 @@ jobs: with: fetch-depth: 0 # needed for Nerdbank.GitVersioning - # - name: Setup .NET - # uses: actions/setup-dotnet@v5 - - # - name: Build Solution - # run: dotnet build Renci.SshNet.sln - - # - name: Publish AOT Compatibility Test App - # run: dotnet publish -r win-x64 /warnaserror test/Renci.SshNet.AotCompatibilityTestApp/ - - # - name: Create NuGet Package - # run: dotnet pack - - # - name: Archive NuGet Package - # uses: actions/upload-artifact@v4 - # with: - # name: NuGet Package - # path: src/Renci.SshNet/bin/Release/*.*nupkg - - # - name: Run Unit Tests .NET - # run: | - # dotnet test ` - # -f net9.0 ` - # --no-build ` - # --logger "console;verbosity=normal" ` - # --logger GitHubActions ` - # -p:CollectCoverage=true ` - # -p:CoverletOutputFormat=cobertura ` - # -p:CoverletOutput=../../coverlet/windows_unit_test_net_9_coverage.xml ` - # test/Renci.SshNet.Tests/ - - # - name: Run Unit Tests .NET Framework - # run: | - # dotnet test ` - # -f net462 ` - # --no-build ` - # --logger "console;verbosity=normal" ` - # --logger GitHubActions ` - # -p:CollectCoverage=true ` - # -p:CoverletOutputFormat=cobertura ` - # -p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml ` - # test/Renci.SshNet.Tests/ + - name: Setup .NET + uses: actions/setup-dotnet@v5 + + - name: Build Solution + run: dotnet build Renci.SshNet.sln + + - name: Publish AOT Compatibility Test App + run: dotnet publish -r win-x64 /warnaserror test/Renci.SshNet.AotCompatibilityTestApp/ + + - name: Create NuGet Package + run: dotnet pack + + - name: Archive NuGet Package + uses: actions/upload-artifact@v4 + with: + name: NuGet Package + path: src/Renci.SshNet/bin/Release/*.*nupkg + + - name: Run Unit Tests .NET + run: | + dotnet test ` + -f net9.0 ` + --no-build ` + --logger "console;verbosity=normal" ` + --logger GitHubActions ` + -p:CollectCoverage=true ` + -p:CoverletOutputFormat=cobertura ` + -p:CoverletOutput=../../coverlet/windows_unit_test_net_9_coverage.xml ` + test/Renci.SshNet.Tests/ + + - name: Run Unit Tests .NET Framework + run: | + dotnet test ` + -f net462 ` + --no-build ` + --logger "console;verbosity=normal" ` + --logger GitHubActions ` + -p:CollectCoverage=true ` + -p:CoverletOutputFormat=cobertura ` + -p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml ` + test/Renci.SshNet.Tests/ Windows-Integration-Tests: name: Windows Integration Tests @@ -132,9 +132,8 @@ jobs: run: dotnet test ` -f net48 ` - --logger "console;verbosity=detailed" ` + --logger "console;verbosity=normal" ` --logger GitHubActions ` - --filter "FullyQualifiedName~ConnectivityTests" ` -p:CollectCoverage=true ` -p:CoverletOutputFormat=cobertura ` -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_4_8_coverage.xml ` @@ -144,9 +143,8 @@ jobs: run: dotnet test ` -f net9.0 ` - --logger "console;verbosity=detailed" ` + --logger "console;verbosity=normal" ` --logger GitHubActions ` - --filter "FullyQualifiedName~ConnectivityTests" ` -p:CollectCoverage=true ` -p:CoverletOutputFormat=cobertura ` -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_9_coverage.xml ` diff --git a/test/Renci.SshNet.IntegrationTests/Dockerfile b/test/Renci.SshNet.IntegrationTests/Dockerfile index f7a471a15..4bf20a3e2 100644 --- a/test/Renci.SshNet.IntegrationTests/Dockerfile +++ b/test/Renci.SshNet.IntegrationTests/Dockerfile @@ -41,7 +41,6 @@ RUN apk update && apk upgrade --no-cache && \ echo 'sshnetadm:ssh4ever' | chpasswd && \ addgroup sshnetadm sudo && \ dos2unix /opt/sshnet/* && \ - chmod -R 777 /var/log && \ # install shadow package; we use chage command in this package to expire/unexpire password of the sshnet user apk add --no-cache shadow && \ # allow us to use telnet command; we use this in the remote port forwarding tests diff --git a/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs b/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs index 4c17c2279..f192fe51a 100644 --- a/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs +++ b/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs @@ -87,24 +87,9 @@ public async Task InitializeAsync() public async Task DisposeAsync() { -#pragma warning disable S6966 // Awaitable method should be used - try - { - using SftpClient client = new(new LinuxAdminConnectionFactory(SshServerHostName, SshServerPort).Create()); - - client.Connect(); - - Console.WriteLine("=== start auth.log ==="); - Console.WriteLine(client.ReadAllText("/var/log/auth.log")); - Console.WriteLine("=== end auth.log ==="); - } - catch (Exception ex) - { - Console.Error.WriteLine(ex.ToString()); - } - if (_sshServer != null) { +#pragma warning disable S6966 // Awaitable method should be used //try //{ // File.WriteAllBytes(@"C:\tmp\auth.log", await _sshServer.ReadFileAsync("/var/log/auth.log").ConfigureAwait(false)); From 65a3ecabcb43a456e3087bf58f08c365e4161a70 Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Fri, 3 Oct 2025 13:24:04 +0200 Subject: [PATCH 08/12] Run Windows .NET tests in separate job so they run in parallel and we avoid the Common_CreateMoreChannelsThanMaxSessions test failure. --- .github/workflows/build.yml | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da5c8e31c..66ba9bd76 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -103,8 +103,8 @@ jobs: -p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml ` test/Renci.SshNet.Tests/ - Windows-Integration-Tests: - name: Windows Integration Tests + Windows-Integration-Tests-NetFramework: + name: Windows Integration Tests .NET Framework runs-on: windows-2025 steps: - name: Checkout @@ -139,6 +139,37 @@ jobs: -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_4_8_coverage.xml ` test\Renci.SshNet.IntegrationTests\ + - name: Archive Coverlet Results + uses: actions/upload-artifact@v4 + with: + name: Coverlet Results Windows + path: coverlet + + Windows-Integration-Tests-Net: + name: Windows Integration Tests .NET + runs-on: windows-2025 + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 0 # needed for Nerdbank.GitVersioning + + - name: Setup .NET + uses: actions/setup-dotnet@v5 + + - name: Setup WSL2 + uses: Vampire/setup-wsl@6a8db447be7ed35f2f499c02c6e60ff77ef11278 # v6.0.0 + with: + distribution: Ubuntu-24.04 + + - name: Setup SSH Server + shell: wsl-bash {0} + run: | + apt-get update && apt-get upgrade -y + apt-get install -y podman + podman build -t renci-ssh-tests-server-image -f test/Renci.SshNet.IntegrationTests/Dockerfile test/Renci.SshNet.IntegrationTests/ + podman run --rm -h renci-ssh-tests-server -d -p 2222:22 renci-ssh-tests-server-image + - name: Run Integration Tests .NET run: dotnet test ` From 0c3a1f4e54197ebeb8bbbdca4fd228c822df4946 Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Fri, 3 Oct 2025 14:22:06 +0200 Subject: [PATCH 09/12] fix coverlet artifacts --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66ba9bd76..60daadddd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -142,7 +142,7 @@ jobs: - name: Archive Coverlet Results uses: actions/upload-artifact@v4 with: - name: Coverlet Results Windows + name: Coverlet Results Windows .NET Framework path: coverlet Windows-Integration-Tests-Net: @@ -184,7 +184,7 @@ jobs: - name: Archive Coverlet Results uses: actions/upload-artifact@v4 with: - name: Coverlet Results Windows + name: Coverlet Results Windows .NET path: coverlet Publish: From ad3f0dce2c193837e05b4c76a328e1b29f1b4e01 Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Fri, 3 Oct 2025 14:12:13 +0200 Subject: [PATCH 10/12] fix missing PermitTTY in RemoteSshdConfig Reset this fixes a test failure in Common_CreateMoreChannelsThanMaxSessions when running the tests multiple times against the same SSH server instance. see https://github.com/sshnet/SSH.NET/pull/1704#issuecomment-3343210311 --- .../Common/RemoteSshdConfigExtensions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Renci.SshNet.IntegrationTests/Common/RemoteSshdConfigExtensions.cs b/test/Renci.SshNet.IntegrationTests/Common/RemoteSshdConfigExtensions.cs index 2a2ccaa4f..9309be40e 100644 --- a/test/Renci.SshNet.IntegrationTests/Common/RemoteSshdConfigExtensions.cs +++ b/test/Renci.SshNet.IntegrationTests/Common/RemoteSshdConfigExtensions.cs @@ -23,6 +23,7 @@ public static void Reset(this RemoteSshdConfig remoteSshdConfig) .ClearHostKeyAlgorithms() .ClearPublicKeyAcceptedAlgorithms() .ClearMessageAuthenticationCodeAlgorithms() + .PermitTTY(true) .WithUsePAM(true) .Update() .Restart(); From e2c0ed247f960a48c56aab72424fba7e6b557a54 Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Fri, 3 Oct 2025 19:49:00 +0200 Subject: [PATCH 11/12] speed up Windows tests turns out this is caused by DNS resolution taking about 2 seconds on every new connection... --- .../TestsFixtures/InfrastructureFixture.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs b/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs index f192fe51a..304f294a4 100644 --- a/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs +++ b/test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs @@ -47,7 +47,7 @@ public async Task InitializeAsync() #pragma warning restore MA0144 // use System.OperatingSystem to check the current OS { SshServerPort = 2222; - SshServerHostName = "localhost"; + SshServerHostName = "127.0.0.1"; await Task.Delay(1_000); return; } From e67710f77a55f894fc92d9d09eb92c92444ab88e Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Sat, 4 Oct 2025 09:11:23 +0200 Subject: [PATCH 12/12] add windows integration tests to Publish needs: --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 60daadddd..9b3759d43 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -195,6 +195,8 @@ jobs: needs: - Windows - Linux + - Windows-Integration-Tests-NetFramework + - Windows-Integration-Tests-Net steps: - name: Download NuGet Package uses: actions/download-artifact@v5