Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions .github/workflows/codecoverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions .github/workflows/nightlybuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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: |
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 --logger "trx;LogFileName=unit-test-results.trx"
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
Expand Down Expand Up @@ -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 --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 --logger "trx;LogFileName=firefoxui-test-results.trx"

- uses: actions/upload-artifact@v4
with:
Expand Down
101 changes: 51 additions & 50 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,56 +1,57 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="MediatR" Version="14.1.0" />
<PackageVersion Include="MessagingService.Client" Version="2026.5.1" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.9" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.9" />
<PackageVersion Include="OpenIddict.Abstractions" Version="7.5.0" />
<PackageVersion Include="OpenIddict.Server" Version="7.5.0" />
<PackageVersion Include="OpenIddict.Server.AspNetCore" Version="7.5.0" />
<PackageVersion Include="OpenIddict.Validation.AspNetCore" Version="7.5.0" />
<PackageVersion Include="Shared.Logger" Version="2026.5.7" />
<PackageVersion Include="Shared.Results" Version="2026.5.7" />
<PackageVersion Include="SimpleResults" Version="4.0.0" />
<PackageVersion Include="coverlet.msbuild" Version="10.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.9" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="xunit.v3" Version="3.2.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.9" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.9" />
<PackageVersion Include="OpenIddict.EntityFrameworkCore" Version="7.5.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.9" />
<PackageVersion Include="ClientProxyBase" Version="2026.5.7" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="10.0.9" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.9" />
<PackageVersion Include="Reqnroll" Version="3.3.4" />
<PackageVersion Include="Reqnroll.Tools.MsBuild.Generation" Version="3.3.4" />
<PackageVersion Include="NUnit" Version="4.6.1" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.2.0" />
<PackageVersion Include="Reqnroll.NUnit" Version="3.3.3" />
<PackageVersion Include="Shared.IntegrationTesting" Version="2026.5.7" />
<PackageVersion Include="System.Data.SqlClient" Version="4.9.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.9" />
<PackageVersion Include="coverlet.collector" Version="10.0.1" />
<PackageVersion Include="Ductus.FluentDocker" Version="2.85.0" />
<PackageVersion Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.9" />
<PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="10.0.9" />
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageVersion Include="OpenIddict.AspNetCore" Version="7.5.0" />
<PackageVersion Include="Shared" Version="2026.5.7" />
<PackageVersion Include="Shared.Results.Web" Version="2026.5.7" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.2.1" />
<PackageVersion Include="Sentry.AspNetCore" Version="6.6.0" />
<PackageVersion Include="NLog.Web.AspNetCore" Version="6.1.3" />
<PackageVersion Include="HtmlAgilityPack" Version="1.12.4" />
<PackageVersion Include="Selenium.Support" Version="4.44.0" />
<PackageVersion Include="Selenium.WebDriver" Version="4.44.0" />
<PackageVersion Include="Reqnroll.NUnit" Version="3.3.4" />
<PackageVersion Include="MediatR" Version="14.2.0" />
<PackageVersion Include="MessagingService.Client" Version="2026.7.1" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.11" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.11" />
<PackageVersion Include="OpenIddict.Abstractions" Version="7.6.0" />
<PackageVersion Include="OpenIddict.Server" Version="7.6.0" />
<PackageVersion Include="OpenIddict.Server.AspNetCore" Version="7.6.0" />
<PackageVersion Include="OpenIddict.Validation.AspNetCore" Version="7.6.0" />
<PackageVersion Include="Shared.Logger" Version="2026.8.2" />
<PackageVersion Include="Shared.Results" Version="2026.8.2" />
<PackageVersion Include="SimpleResults" Version="4.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.11" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.9.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="2.3.3" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="xunit.v3" Version="4.0.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="4.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.11" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.11" />
<PackageVersion Include="OpenIddict.EntityFrameworkCore" Version="7.6.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.11" />
<PackageVersion Include="ClientProxyBase" Version="2026.8.2" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="10.0.11" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.11" />
<PackageVersion Include="Reqnroll" Version="3.3.4" />
<PackageVersion Include="Reqnroll.Tools.MsBuild.Generation" Version="3.3.4" />
<PackageVersion Include="NUnit" Version="4.6.1" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.2.0" />
<PackageVersion Include="Reqnroll.NUnit" Version="3.3.3" />
<PackageVersion Include="Shared.IntegrationTesting" Version="2026.8.2" />
<PackageVersion Include="System.Data.SqlClient" Version="4.9.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.11" />
<PackageVersion Include="coverlet.collector" Version="10.0.1" />
<PackageVersion Include="Ductus.FluentDocker" Version="2.85.0" />
<PackageVersion Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.11" />
<PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="10.0.11" />
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageVersion Include="OpenIddict.AspNetCore" Version="7.6.0" />
<PackageVersion Include="Shared" Version="2026.8.2" />
<PackageVersion Include="Shared.Results.Web" Version="2026.8.2" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.2.3" />
<PackageVersion Include="Sentry.AspNetCore" Version="6.9.0" />
<PackageVersion Include="NLog.Web.AspNetCore" Version="6.2.0" />
<PackageVersion Include="HtmlAgilityPack" Version="1.12.4" />
<PackageVersion Include="Selenium.Support" Version="4.47.0" />
<PackageVersion Include="Selenium.WebDriver" Version="4.47.0" />
<PackageVersion Include="Reqnroll.NUnit" Version="3.3.4" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />

<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" />

<PackageReference Include="Reqnroll" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />

<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" />

<PackageReference Include="Reqnroll" />

Expand Down
10 changes: 5 additions & 5 deletions SecurityService.UnitTests/SecurityService.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" />
<PackageReference Include="Moq" />
<PackageReference Include="Shouldly" />
<PackageReference Include="xunit.v3" />
Expand Down
5 changes: 5 additions & 0 deletions SecurityService.UnitTests/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
49 changes: 41 additions & 8 deletions SecurityService/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -104,22 +105,54 @@
});
}

builder.Services.AddDbContext<SecurityServiceDbContext>(dbOptions =>
if (options.UseInMemoryDatabase)
{
if (options.UseInMemoryDatabase)
builder.Services.AddDbContext<SecurityServiceDbContext>(builder => {
builder.UseInMemoryDatabase(options.InMemoryDatabaseName);
builder.UseOpenIddict();
});
}
else
{
SqlServerRetryOptions retryOptions;
try
{
retryOptions = ConfigurationReader.GetSection<SqlServerRetryOptions>("AppSettings:SqlServerRetry");
}
catch (KeyNotFoundException)
{
retryOptions = null;
}

if (retryOptions != null)
{
dbOptions.UseInMemoryDatabase(options.InMemoryDatabaseName);
builder.Services.AddDbContext<SecurityServiceDbContext>(options => {

options.UseSharedSqlServer<SecurityServiceDbContext>(ConfigurationReader.GetConnectionString("AuthenticationDbContext"), retry => {
retry.AdditionalTransientErrorNumbers = retryOptions.AdditionalTransientErrorNumbers;
retry.MaxRetryCount = retryOptions.MaxRetryCount;
retry.MaxRetryDelay = retryOptions.MaxRetryDelay;
});
options.UseOpenIddict();
options.UseSqlServer(options => {
options.MigrationsAssembly("SecurityService.SqlServerMigrations");
});
});
}
else
{
dbOptions.UseSqlServer(builder.Configuration.GetConnectionString("AuthenticationDbContext"), sqlServerOptions =>
{
sqlServerOptions.MigrationsAssembly("SecurityService.SqlServerMigrations");
builder.Services.AddDbContext<SecurityServiceDbContext>(options => {
options.UseSqlServer(ConfigurationReader.GetConnectionString("AuthenticationDbContext"), retry => {
retry.EnableRetryOnFailure();
retry.MigrationsAssembly("SecurityService.SqlServerMigrations");
});
options.UseOpenIddict();

});

}
}

dbOptions.UseOpenIddict();
});

builder.Services.AddSingleton<IMessagingServiceClient, TestMessagingServiceClient>();
builder.Services.AddSingleton<IClientJwtService, ClientJwtService>();
Expand Down
Loading