feature: RBAC + Clinical Audit Logging
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
public static class TestAuthContext
|
||||
{
|
||||
public static void AsNurse(
|
||||
IServiceProvider services,
|
||||
Guid? userId = null,
|
||||
string displayName = "Test Nurse")
|
||||
{
|
||||
var accessor = services.GetRequiredService<IHttpContextAccessor>();
|
||||
var context = new DefaultHttpContext();
|
||||
var claims = new[]
|
||||
{
|
||||
new Claim(ClaimTypes.NameIdentifier, (userId ?? Guid.NewGuid()).ToString()),
|
||||
new Claim(ClaimTypes.Name, "test-nurse"),
|
||||
new Claim("display_name", displayName),
|
||||
new Claim("clinical_role", "NURSE"),
|
||||
};
|
||||
context.User = new ClaimsPrincipal(new ClaimsIdentity(claims, TestingAuthHandler.SchemeName));
|
||||
accessor.HttpContext = context;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user