From 425ff1580735e76243fe1c721502bbbed3f4080c Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Tue, 18 Aug 2026 09:27:46 +0100 Subject: [PATCH 1/6] nuget updates --- Directory.Packages.props | 102 +++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 4973e8e..557b7e2 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,56 +1,56 @@ - true + true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + \ No newline at end of file From d138a39fd4bb94694316d2ed9808051980937b59 Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Tue, 18 Aug 2026 09:43:59 +0100 Subject: [PATCH 2/6] ... --- .github/workflows/pullrequest.yml | 6 +++--- Directory.Packages.props | 3 ++- .../SecurityService.IntegrationTests.csproj | 1 + .../SecurityService.OpenIdConnect.IntegrationTests.csproj | 1 + SecurityService.UnitTests/SecurityService.UnitTests.csproj | 3 ++- global.json | 5 +++++ 6 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 global.json diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 0204894..5fc2059 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -47,7 +47,7 @@ jobs: - name: Run Unit Tests run: | echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" - dotnet test "SecurityService.UnitTests\SecurityService.UnitTests.csproj" --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=unit-test-results.trx" + dotnet test "SecurityService.UnitTests\SecurityService.UnitTests.csproj" --configuration Release --no-build --verbosity normal --report-trx --report-trx-filename unit-test-results.trx --results-directory TestResults - name: Build Docker Images @@ -56,7 +56,7 @@ jobs: - name: Run Integration Tests (Non UI) run: | - dotnet test "SecurityService.IntegrationTests\SecurityService.IntegrationTests.csproj" --filter Category=PRTest --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=nonui-test-results.trx" + dotnet test "SecurityService.IntegrationTests\SecurityService.IntegrationTests.csproj" --filter Category=PRTest --configuration Release --no-build --verbosity normal --report-trx --report-trx-filename nonui-test-results.trx --results-directory TestResults - uses: actions/upload-artifact@v4 with: @@ -123,7 +123,7 @@ jobs: env: Browser: Firefox run: | - dotnet test "SecurityService.OpenIdConnect.IntegrationTests\SecurityService.OpenIdConnect.IntegrationTests.csproj" --filter Category=PRTest --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=firefoxui-test-results.trx" + dotnet test "SecurityService.OpenIdConnect.IntegrationTests\SecurityService.OpenIdConnect.IntegrationTests.csproj" --filter Category=PRTest --configuration Release --no-build --verbosity normal --report-trx --report-trx-filename firefoxui-test-results.trx --results-directory TestResults - uses: actions/upload-artifact@v4 with: diff --git a/Directory.Packages.props b/Directory.Packages.props index 557b7e2..97156cb 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -17,6 +17,7 @@ + @@ -53,4 +54,4 @@ - \ No newline at end of file + diff --git a/SecurityService.IntegrationTests/SecurityService.IntegrationTests.csproj b/SecurityService.IntegrationTests/SecurityService.IntegrationTests.csproj index 2489cd7..c613ccc 100644 --- a/SecurityService.IntegrationTests/SecurityService.IntegrationTests.csproj +++ b/SecurityService.IntegrationTests/SecurityService.IntegrationTests.csproj @@ -15,6 +15,7 @@ + diff --git a/SecurityService.OpenIdConnect.IntegrationTests/SecurityService.OpenIdConnect.IntegrationTests.csproj b/SecurityService.OpenIdConnect.IntegrationTests/SecurityService.OpenIdConnect.IntegrationTests.csproj index dd8ef58..fcf7e2d 100644 --- a/SecurityService.OpenIdConnect.IntegrationTests/SecurityService.OpenIdConnect.IntegrationTests.csproj +++ b/SecurityService.OpenIdConnect.IntegrationTests/SecurityService.OpenIdConnect.IntegrationTests.csproj @@ -13,6 +13,7 @@ + diff --git a/SecurityService.UnitTests/SecurityService.UnitTests.csproj b/SecurityService.UnitTests/SecurityService.UnitTests.csproj index a742452..e027a9d 100644 --- a/SecurityService.UnitTests/SecurityService.UnitTests.csproj +++ b/SecurityService.UnitTests/SecurityService.UnitTests.csproj @@ -6,12 +6,13 @@ false - + all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/global.json b/global.json new file mode 100644 index 0000000..3140116 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +} From 5fe4e9c4badad156e237f6bc2af564301ecb8c59 Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Tue, 18 Aug 2026 09:53:11 +0100 Subject: [PATCH 3/6] .... --- .github/workflows/pullrequest.yml | 7 ++++--- SecurityService.UnitTests/SecurityService.UnitTests.csproj | 1 + global.json => SecurityService.UnitTests/global.json | 0 3 files changed, 5 insertions(+), 3 deletions(-) rename global.json => SecurityService.UnitTests/global.json (100%) diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 5fc2059..e352c4c 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -45,9 +45,10 @@ jobs: run: dotnet build SecurityService.slnx --configuration Release - name: Run Unit Tests + working-directory: SecurityService.UnitTests run: | echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" - dotnet test "SecurityService.UnitTests\SecurityService.UnitTests.csproj" --configuration Release --no-build --verbosity normal --report-trx --report-trx-filename unit-test-results.trx --results-directory TestResults + dotnet test "SecurityService.UnitTests.csproj" --configuration Release --no-build --verbosity normal --report-trx --report-trx-filename unit-test-results.trx --results-directory TestResults - name: Build Docker Images @@ -56,7 +57,7 @@ jobs: - name: Run Integration Tests (Non UI) run: | - dotnet test "SecurityService.IntegrationTests\SecurityService.IntegrationTests.csproj" --filter Category=PRTest --configuration Release --no-build --verbosity normal --report-trx --report-trx-filename nonui-test-results.trx --results-directory TestResults + dotnet test "SecurityService.IntegrationTests\SecurityService.IntegrationTests.csproj" --filter Category=PRTest --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=nonui-test-results.trx" - uses: actions/upload-artifact@v4 with: @@ -123,7 +124,7 @@ jobs: env: Browser: Firefox run: | - dotnet test "SecurityService.OpenIdConnect.IntegrationTests\SecurityService.OpenIdConnect.IntegrationTests.csproj" --filter Category=PRTest --configuration Release --no-build --verbosity normal --report-trx --report-trx-filename firefoxui-test-results.trx --results-directory TestResults + dotnet test "SecurityService.OpenIdConnect.IntegrationTests\SecurityService.OpenIdConnect.IntegrationTests.csproj" --filter Category=PRTest --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=firefoxui-test-results.trx" - uses: actions/upload-artifact@v4 with: diff --git a/SecurityService.UnitTests/SecurityService.UnitTests.csproj b/SecurityService.UnitTests/SecurityService.UnitTests.csproj index e027a9d..ab04571 100644 --- a/SecurityService.UnitTests/SecurityService.UnitTests.csproj +++ b/SecurityService.UnitTests/SecurityService.UnitTests.csproj @@ -4,6 +4,7 @@ enable enable false + true diff --git a/global.json b/SecurityService.UnitTests/global.json similarity index 100% rename from global.json rename to SecurityService.UnitTests/global.json From 097900c4c37e36778abae27a6cb9b160a6c6e07f Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Tue, 18 Aug 2026 10:20:42 +0100 Subject: [PATCH 4/6] Fix CI test and coverage workflows --- .github/workflows/codecoverage.yml | 15 ++++----------- .github/workflows/nightlybuild.yml | 6 ++++-- Directory.Packages.props | 2 +- .../SecurityService.UnitTests.csproj | 8 +++----- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/.github/workflows/codecoverage.yml b/.github/workflows/codecoverage.yml index a4f1335..d8ceba2 100644 --- a/.github/workflows/codecoverage.yml +++ b/.github/workflows/codecoverage.yml @@ -25,20 +25,13 @@ jobs: run: dotnet build SecurityService.slnx --configuration Release - name: Run Unit Tests + working-directory: SecurityService.UnitTests run: | echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" - dotnet test "SecurityService.UnitTests\SecurityService.UnitTests.csproj" /p:ExcludeByFile="\SecurityService\Views\**\*.cshtml" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov1.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" + dotnet test "SecurityService.UnitTests.csproj" --configuration Release --verbosity normal --coverage --coverage-output-format cobertura --results-directory TestResults - - name: Install LCOV merger - run: npm install -g lcov-result-merger - - - name: Merge LCOV reports - run: | - mkdir -p coverage - lcov-result-merger "*.info" > lcov.info - - - name: Upload merged coverage to Codacy + - name: Upload coverage to Codacy uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - coverage-reports: ./lcov.info + coverage-reports: ./SecurityService.UnitTests/TestResults/*.cobertura.xml diff --git a/.github/workflows/nightlybuild.yml b/.github/workflows/nightlybuild.yml index deced09..a9bb789 100644 --- a/.github/workflows/nightlybuild.yml +++ b/.github/workflows/nightlybuild.yml @@ -54,9 +54,10 @@ jobs: run: dotnet build SecurityService.slnx --configuration Release - name: Run Unit Tests + working-directory: SecurityService.UnitTests run: | echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" - dotnet test "SecurityService.UnitTests\SecurityService.UnitTests.csproj" /p:ExcludeByFile="\SecurityService\Views\**\*.cshtml" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov1.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" + dotnet test "SecurityService.UnitTests.csproj" --configuration Release --no-build --verbosity normal - name: Build Docker Images run: | @@ -204,9 +205,10 @@ jobs: run: dotnet build SecurityService.slnx --configuration Release - name: Run Unit Tests + working-directory: SecurityService.UnitTests run: | echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" - dotnet test "SecurityService.UnitTests\SecurityService.UnitTests.csproj" /p:ExcludeByFile="\SecurityService\Views\**\*.cshtml" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov1.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" + dotnet test "SecurityService.UnitTests.csproj" --configuration Release --no-build --verbosity normal - name: Build Docker Images run: | diff --git a/Directory.Packages.props b/Directory.Packages.props index 97156cb..2b302d6 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -14,9 +14,9 @@ - + diff --git a/SecurityService.UnitTests/SecurityService.UnitTests.csproj b/SecurityService.UnitTests/SecurityService.UnitTests.csproj index ab04571..3a84388 100644 --- a/SecurityService.UnitTests/SecurityService.UnitTests.csproj +++ b/SecurityService.UnitTests/SecurityService.UnitTests.csproj @@ -5,13 +5,11 @@ enable false true + true - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + From 9ffe5ea5533d12c5480f64ff25be0efd032832d9 Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Tue, 18 Aug 2026 10:58:22 +0100 Subject: [PATCH 5/6] configure sql retrys --- SecurityService/Program.cs | 41 ++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/SecurityService/Program.cs b/SecurityService/Program.cs index 34207f3..89e7ec6 100644 --- a/SecurityService/Program.cs +++ b/SecurityService/Program.cs @@ -23,6 +23,7 @@ using SecurityService.HealthChecks; using SecurityService.HostedServices; using Sentry.Extensibility; +using Shared.EntityFramework; using Shared.Extensions; using Shared.General; using Shared.Logger; @@ -104,22 +105,46 @@ }); } -builder.Services.AddDbContext(dbOptions => +if (options.UseInMemoryDatabase) { - if (options.UseInMemoryDatabase) + builder.Services.AddDbContext(builder => { + builder.UseInMemoryDatabase(options.InMemoryDatabaseName); + builder.UseOpenIddict(); + }); +} +else +{ + SqlServerRetryOptions retryOptions; + try + { + retryOptions = ConfigurationReader.GetSection("AppSettings:SqlServerRetry"); + } + catch (KeyNotFoundException) + { + retryOptions = null; + } + + if (retryOptions != null) { - dbOptions.UseInMemoryDatabase(options.InMemoryDatabaseName); + builder.Services.AddDbContext(options => { + + options.UseSharedSqlServer(ConfigurationReader.GetConnectionString("AuthenticationDbContext"), retry => { + retry.AdditionalTransientErrorNumbers = retryOptions.AdditionalTransientErrorNumbers; + retry.MaxRetryCount = retryOptions.MaxRetryCount; + retry.MaxRetryDelay = retryOptions.MaxRetryDelay; + }); + options.UseOpenIddict(); + }); } else { - dbOptions.UseSqlServer(builder.Configuration.GetConnectionString("AuthenticationDbContext"), sqlServerOptions => - { - sqlServerOptions.MigrationsAssembly("SecurityService.SqlServerMigrations"); + builder.Services.AddDbContext(options => { + options.UseSqlServer(ConfigurationReader.GetConnectionString("AuthenticationDbContext"), retry => { retry.EnableRetryOnFailure(); }); + options.UseOpenIddict(); }); } +} - dbOptions.UseOpenIddict(); -}); builder.Services.AddSingleton(); builder.Services.AddSingleton(); From 26b3a96ebf64cededb18edcc282f3d7d3db852ac Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Tue, 18 Aug 2026 11:37:50 +0100 Subject: [PATCH 6/6] bootstrapping crime --- SecurityService/Program.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SecurityService/Program.cs b/SecurityService/Program.cs index 89e7ec6..3d6ba58 100644 --- a/SecurityService/Program.cs +++ b/SecurityService/Program.cs @@ -134,14 +134,22 @@ retry.MaxRetryDelay = retryOptions.MaxRetryDelay; }); options.UseOpenIddict(); + options.UseSqlServer(options => { + options.MigrationsAssembly("SecurityService.SqlServerMigrations"); + }); }); } else { builder.Services.AddDbContext(options => { - options.UseSqlServer(ConfigurationReader.GetConnectionString("AuthenticationDbContext"), retry => { retry.EnableRetryOnFailure(); }); + options.UseSqlServer(ConfigurationReader.GetConnectionString("AuthenticationDbContext"), retry => { + retry.EnableRetryOnFailure(); + retry.MigrationsAssembly("SecurityService.SqlServerMigrations"); + }); options.UseOpenIddict(); + }); + } }