Implement US-14 assigned professional read access

This commit is contained in:
Steffen committed 2026-10-05 11:40:34 +02:00
1 parent 0ce9b2b168
commit 5996481081
11 files changed
+441 -24

No files matched your search

@@ -42,14 +42,19 @@ public sealed class AuthenticationIntegrationTests
finally { if (Directory.Exists(authentication.KeyDirectory)) Directory.Delete(authentication.KeyDirectory, true); }
}
[Fact]
public async Task Standard_replacement_handler_with_same_identity_retains_ownership_policy()
[Theory]
[InlineData("Patient", "test-0")]
[InlineData("HealthcareProfessional", "professional")]
public async Task Standard_replacement_handler_with_same_identity_retains_ownership_policy(string role, string accountId)
{
var authentication = new AuthenticatedTestClient();
var patient = Guid.NewGuid();
try
{
var configuration = authentication.Configuration();
configuration["TestIdentity:Role"] = role;
configuration["TestIdentity:AccountId"] = accountId;
configuration[$"Access:ProfessionalAssignments:{accountId}:0"] = patient.ToString();
foreach (var service in new[] { "PatientProfile", "Observation", "Insights" })
configuration[$"Services:{service}:BaseUrl"] = "http://service.example.test/";
using var host = new WebApplicationFactory<ApiGateway.Program>().WithWebHostBuilder(builder =>
@@ -73,13 +78,13 @@ public sealed class AuthenticationIntegrationTests
finally { if (Directory.Exists(authentication.KeyDirectory)) Directory.Delete(authentication.KeyDirectory, true); }
}
public sealed class ReplacementHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder)
public sealed class ReplacementHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, IConfiguration configuration)
: AuthenticationHandler<AuthenticationSchemeOptions>(options, logger, encoder)
{
protected override Task<AuthenticateResult> HandleAuthenticateAsync() => Task.FromResult(
AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(new ClaimsIdentity(new[]
{
new Claim(ClaimTypes.NameIdentifier, "test-0"), new Claim(ClaimTypes.Role, "Patient")
new Claim(ClaimTypes.NameIdentifier, configuration["TestIdentity:AccountId"]!), new Claim(ClaimTypes.Role, configuration["TestIdentity:Role"]!)
}, Scheme.Name)), Scheme.Name)));
}