feat(users): allow admins to update email
This commit is contained in:
1 parent
1107aa6170
commit
d2e291c4b1
9 files changed
+185
-8
No files matched your search
@@ -4,6 +4,7 @@ using Heimdall.Application.Assignments.Commands.CreateUserCameraAccess;
|
||||
using Heimdall.Application.Common;
|
||||
using Heimdall.Application.DTOs;
|
||||
using Heimdall.Application.Users.Commands.ConfirmEmail;
|
||||
using Heimdall.Application.Users.Commands.UpdateUser;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -30,6 +31,24 @@ public class UserCameraAccessControllerTests
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Admin_user_update_passes_email_and_authenticated_actor()
|
||||
{
|
||||
var mediator = Substitute.For<IMediator>();
|
||||
mediator.Send(Arg.Any<UpdateUserCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ServiceResult<UserResponse>.NotFound("User not found"));
|
||||
var actorId = Guid.NewGuid();
|
||||
var userId = Guid.NewGuid();
|
||||
var controller = CreateUsersController(mediator, actorId);
|
||||
|
||||
await controller.Update(userId, new UpdateUserRequest("Name", null, null, "new@example.test"), CancellationToken.None);
|
||||
|
||||
await mediator.Received(1).Send(
|
||||
Arg.Is<UpdateUserCommand>(command => command != null && command.Id == userId
|
||||
&& command.Email == "new@example.test" && command.ActorId == actorId),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Create_passes_authenticated_actor_to_command()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user