Soenneker.Utils.Test.AuthHandler
4.0.328
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Utils.Test.AuthHandler --version 4.0.328
NuGet\Install-Package Soenneker.Utils.Test.AuthHandler -Version 4.0.328
<PackageReference Include="Soenneker.Utils.Test.AuthHandler" Version="4.0.328" />
<PackageVersion Include="Soenneker.Utils.Test.AuthHandler" Version="4.0.328" />
<PackageReference Include="Soenneker.Utils.Test.AuthHandler" />
paket add Soenneker.Utils.Test.AuthHandler --version 4.0.328
#r "nuget: Soenneker.Utils.Test.AuthHandler, 4.0.328"
#:package Soenneker.Utils.Test.AuthHandler@4.0.328
#addin nuget:?package=Soenneker.Utils.Test.AuthHandler&version=4.0.328
#tool nuget:?package=Soenneker.Utils.Test.AuthHandler&version=4.0.328
Soenneker.Utils.Test.AuthHandler
A test authentication handler for integration tests. It creates an authenticated user from simple request headers or an existing bearer token.
Installation
dotnet add package Soenneker.Utils.Test.AuthHandler
Setup
using Microsoft.AspNetCore.Authentication;
using Soenneker.Utils.Test.AuthHandler;
services
.AddAuthentication("Test")
.AddScheme<AuthenticationSchemeOptions, TestAuthHandler>("Test", _ => { });
TestAuthHandler depends on IJwtUtil, so register that in the test host as well.
Authenticate a test request
The simplest option is to send a user ID. Email and roles are optional:
client.DefaultRequestHeaders.Add("AuthorizationUserId", "test-user-123");
client.DefaultRequestHeaders.Add("AuthorizationEmail", "test@example.com");
client.DefaultRequestHeaders.Add("AuthorizationRoles", "Admin,Manager");
If AuthorizationRoles is omitted, the handler assigns the Admin role. Alternatively, send a normal Authorization: Bearer <token> header to build the principal from a JWT.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.11)
- Soenneker.Extensions.List.Claims (>= 4.0.52)
- Soenneker.Utils.Jwt (>= 4.0.1468)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Soenneker.Utils.Test.AuthHandler:
| Package | Downloads |
|---|---|
|
Soenneker.Fixtures.Integration
Provides a reusable and generic integration test xunit fixture that dynamically registers and configures WebApplicationFactory instances for multiple ASP.NET Core projects with support for custom app settings, authentication, logging, and test utilities. |
|
|
Soenneker.TestHosts.Integration
Provides a reusable and generic integration test host that dynamically registers and configures WebApplicationFactory instances for multiple ASP.NET Core projects with support for custom app settings, authentication, logging, and test utilities. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.334 | 0 | 8/31/2026 |
| 4.0.333 | 0 | 8/30/2026 |
| 4.0.332 | 29 | 8/30/2026 |
| 4.0.331 | 51 | 8/30/2026 |
| 4.0.330 | 52 | 8/30/2026 |
| 4.0.329 | 42 | 8/30/2026 |
| 4.0.328 | 38 | 8/29/2026 |
| 4.0.327 | 42 | 8/29/2026 |
| 4.0.326 | 92 | 8/29/2026 |
| 4.0.325 | 288 | 8/26/2026 |
| 4.0.324 | 95 | 8/26/2026 |
| 4.0.323 | 86 | 8/26/2026 |
| 4.0.322 | 146 | 8/25/2026 |
| 4.0.321 | 208 | 8/21/2026 |
| 4.0.320 | 313 | 8/18/2026 |
| 4.0.319 | 314 | 8/12/2026 |
| 4.0.318 | 134 | 8/11/2026 |
| 4.0.317 | 305 | 8/8/2026 |
| 4.0.316 | 193 | 8/7/2026 |
| 4.0.315 | 242 | 7/29/2026 |
Update dependency Soenneker.Extensions.List.Claims to 4.0.52 (#873)