Files
raceplanner/backend/backend.Tests/Utilities/TestUserClaims.cs
T
Denis Urs Rudolph 571fe5bc7c Add comprehensive test suite infrastructure
- Create backend xUnit test project with Moq and FluentAssertions
- Add test utilities: TestDataFactory, MockHttpContext, TestUserClaims
- Create AuthControllerTests with comprehensive auth scenarios
- Install Jest and React Testing Library for frontend
- Configure jest.config.ts and jest.setup.ts with Next.js support
- Add test scripts to package.json
2026-04-05 22:16:44 +02:00

38 lines
1.2 KiB
C#

using System.Security.Claims;
namespace backend.Tests.Utilities;
public static class TestUserClaims
{
public static ClaimsPrincipal CreateOrganizer(Guid? userId = null, string email = "organizer@example.com")
{
var claims = new List<Claim>
{
new Claim(ClaimTypes.NameIdentifier, (userId ?? Guid.NewGuid()).ToString()),
new Claim(ClaimTypes.Email, email),
new Claim(ClaimTypes.Role, "Organizer")
};
var identity = new ClaimsIdentity(claims, "TestAuthType");
return new ClaimsPrincipal(identity);
}
public static ClaimsPrincipal CreateParticipant(Guid? userId = null, string email = "participant@example.com")
{
var claims = new List<Claim>
{
new Claim(ClaimTypes.NameIdentifier, (userId ?? Guid.NewGuid()).ToString()),
new Claim(ClaimTypes.Email, email),
new Claim(ClaimTypes.Role, "Participant")
};
var identity = new ClaimsIdentity(claims, "TestAuthType");
return new ClaimsPrincipal(identity);
}
public static ClaimsPrincipal CreateUnauthenticated()
{
return new ClaimsPrincipal(new ClaimsIdentity());
}
}