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;
|
|
|
|
|
|
|
|
|
|
namespace Bit.Identity.IntegrationTest.Controllers;
|
2022-08-29 22:06:55 +02:00
|
|
|
|
|
2022-05-20 21:24:59 +02:00
|
|
|
|
public class AccountsControllerTests : IClassFixture<IdentityApplicationFactory>
|
|
|
|
|
{
|
|
|
|
|
private readonly IdentityApplicationFactory _factory;
|
|
|
|
|
|
|
|
|
|
public AccountsControllerTests(IdentityApplicationFactory factory)
|
2022-08-29 21:53:48 +02:00
|
|
|
|
{
|
2022-05-20 21:24:59 +02:00
|
|
|
|
_factory = factory;
|
2022-08-29 21:53:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 21:24:59 +02:00
|
|
|
|
[Fact]
|
|
|
|
|
public async Task PostRegister_Success()
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2022-05-20 21:24:59 +02:00
|
|
|
|
var context = await _factory.RegisterAsync(new RegisterRequestModel
|
|
|
|
|
{
|
|
|
|
|
Email = "test+register@email.com",
|
|
|
|
|
MasterPasswordHash = "master_password_hash"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Assert.Equal(StatusCodes.Status200OK, context.Response.StatusCode);
|
|
|
|
|
|
|
|
|
|
var database = _factory.GetDatabaseContext();
|
|
|
|
|
var user = await database.Users
|
|
|
|
|
.SingleAsync(u => u.Email == "test+register@email.com");
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(user);
|
|
|
|
|
}
|
|
|
|
|
}
|