feat(users): confirm email from admin page
This commit is contained in:
1 parent
02082e504d
commit
1107aa6170
8 files changed
+156
-10
No files matched your search
@@ -3,6 +3,7 @@ using Heimdall.Api.Controllers;
|
||||
using Heimdall.Application.Assignments.Commands.CreateUserCameraAccess;
|
||||
using Heimdall.Application.Common;
|
||||
using Heimdall.Application.DTOs;
|
||||
using Heimdall.Application.Users.Commands.ConfirmEmail;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -13,6 +14,22 @@ namespace Heimdall.Web.Tests.Controllers;
|
||||
|
||||
public class UserCameraAccessControllerTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Admin_email_confirmation_passes_authenticated_actor()
|
||||
{
|
||||
var mediator = Substitute.For<IMediator>();
|
||||
mediator.Send(Arg.Any<ConfirmEmailCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ServiceResult.Success());
|
||||
var actorId = Guid.NewGuid();
|
||||
var controller = CreateUsersController(mediator, actorId);
|
||||
|
||||
await controller.ConfirmEmail(Guid.NewGuid(), CancellationToken.None);
|
||||
|
||||
await mediator.Received(1).Send(
|
||||
Arg.Is<ConfirmEmailCommand>(command => command != null && command.ActorId == actorId),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Create_passes_authenticated_actor_to_command()
|
||||
{
|
||||
@@ -58,4 +75,18 @@ public class UserCameraAccessControllerTests
|
||||
};
|
||||
return controller;
|
||||
}
|
||||
|
||||
private static UsersController CreateUsersController(IMediator mediator, Guid userId) =>
|
||||
new(mediator)
|
||||
{
|
||||
ControllerContext = new ControllerContext
|
||||
{
|
||||
HttpContext = new DefaultHttpContext
|
||||
{
|
||||
User = new ClaimsPrincipal(new ClaimsIdentity([
|
||||
new Claim(ClaimTypes.NameIdentifier, userId.ToString())
|
||||
], "test"))
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user