Refactors current user identity handling in handlers

This commit is contained in:
BinaryAlley committed 2026-08-16 04:59:44 -07:00
1 parent a7dfcbe926
commit f0a1942691
28 files changed
+336 -30

No files matched your search

@@ -73,6 +73,23 @@ public class GetUsersQueryHandlerTests
await _mockUserRepository.DidNotReceive().GetAllAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenUserIsNotAuthenticated_ShouldReturnNotAuthorizedError()
{
// Arrange
GetUsersQuery query = _getUsersQueryFixture.Create();
_mockCurrentUserService.UserId.Returns((Guid?)null);
// Act
Result<IEnumerable<UserResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.Authorization.NotAuthorized, result.FirstError);
await _mockAuthorizationService.DidNotReceive().IsInRoleAsync(Arg.Any<Guid>(), Arg.Any<string>(), Arg.Any<CancellationToken>());
await _mockUserRepository.DidNotReceive().GetAllAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenGetUsersFails_ShouldReturnError()
{