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
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user