2023-04-14 19:25:56 +02:00
|
|
|
|
using Bit.Core.Auth.Models.Api.Request.Accounts;
|
2022-05-20 21:24:59 +02:00
|
|
|
|
using Bit.IntegrationTestCommon.Factories;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
namespace Bit.Identity.IntegrationTest.Controllers;
|
|
|
|
|
|
|
|
|
|
public class AccountsControllerTests : IClassFixture<IdentityApplicationFactory>
|
2022-05-20 21:24:59 +02:00
|
|
|
|
{
|
2022-08-29 22:06:55 +02:00
|
|
|
|
private readonly IdentityApplicationFactory _factory;
|
2022-05-20 21:24:59 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
public AccountsControllerTests(IdentityApplicationFactory factory)
|
|
|
|
|
{
|
|
|
|
|
_factory = factory;
|
|
|
|
|
}
|
2022-08-29 21:53:48 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
[Fact]
|
|
|
|
|
public async Task PostRegister_Success()
|
|
|
|
|
{
|
|
|
|
|
var context = await _factory.RegisterAsync(new RegisterRequestModel
|
2022-05-20 21:24:59 +02:00
|
|
|
|
{
|
2022-08-29 22:06:55 +02:00
|
|
|
|
Email = "test+register@email.com",
|
|
|
|
|
MasterPasswordHash = "master_password_hash"
|
|
|
|
|
});
|
2022-05-20 21:24:59 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
Assert.Equal(StatusCodes.Status200OK, context.Response.StatusCode);
|
2022-05-20 21:24:59 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
var database = _factory.GetDatabaseContext();
|
|
|
|
|
var user = await database.Users
|
|
|
|
|
.SingleAsync(u => u.Email == "test+register@email.com");
|
2022-05-20 21:24:59 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
Assert.NotNull(user);
|
2022-05-20 21:24:59 +02:00
|
|
|
|
}
|
|
|
|
|
}
|