mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
Auth/PM-6198 - Registration with Email Verification - Add email clicked endpoint (#4520)
* PM-6198 - RegistrationEmailVerificationTokenable - add new static validate token method * PM-6198 - Rename RegistrationStart to Registration as we now have to add another anonymous reference event. * PM-6198 - rest of work * PM-6198 - Unit test new account controller method. * PM-6198 - Integration test new account controller endpoint
This commit is contained in:
@ -268,6 +268,43 @@ public class AccountsControllerTests : IClassFixture<IdentityApplicationFactory>
|
||||
Assert.Equal(kdfParallelism, user.KdfParallelism);
|
||||
}
|
||||
|
||||
[Theory, BitAutoData]
|
||||
public async Task PostRegisterVerificationEmailClicked_Success(
|
||||
[Required, StringLength(20)] string name,
|
||||
string emailVerificationToken)
|
||||
{
|
||||
// Arrange
|
||||
// Localize substitutions to this test.
|
||||
var localFactory = new IdentityApplicationFactory();
|
||||
|
||||
var email = $"test+register+{name}@email.com";
|
||||
var registrationEmailVerificationTokenable = new RegistrationEmailVerificationTokenable(email);
|
||||
|
||||
localFactory.SubstituteService<IDataProtectorTokenFactory<RegistrationEmailVerificationTokenable>>(emailVerificationTokenDataProtectorFactory =>
|
||||
{
|
||||
emailVerificationTokenDataProtectorFactory.TryUnprotect(Arg.Is(emailVerificationToken), out Arg.Any<RegistrationEmailVerificationTokenable>())
|
||||
.Returns(callInfo =>
|
||||
{
|
||||
callInfo[1] = registrationEmailVerificationTokenable;
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
var requestModel = new RegisterVerificationEmailClickedRequestModel
|
||||
{
|
||||
Email = email,
|
||||
EmailVerificationToken = emailVerificationToken
|
||||
};
|
||||
|
||||
// Act
|
||||
var httpContext = await localFactory.PostRegisterVerificationEmailClicked(requestModel);
|
||||
|
||||
var body = await httpContext.ReadBodyAsStringAsync();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(StatusCodes.Status200OK, httpContext.Response.StatusCode);
|
||||
}
|
||||
|
||||
private async Task<User> CreateUserAsync(string email, string name, IdentityApplicationFactory factory = null)
|
||||
{
|
||||
var factoryToUse = factory ?? _factory;
|
||||
|
Reference in New Issue
Block a user