mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 23:52:50 -05:00
Auth/PM-7322 - Registration with Email verification - Finish registration endpoint (#4182)
* PM-7322 - AccountsController.cs - create empty method + empty req model to be able to create draft PR. * PM-7322 - Start on RegisterFinishRequestModel.cs * PM-7322 - WIP on Complete Registration endpoint * PM-7322 - UserService.cs - RegisterUserAsync - Tweak of token to be orgInviteToken as we are adding a new email verification token to the mix. * PM-7322 - UserService - Rename MP to MPHash * PM-7322 - More WIP progress on getting new finish registration process in place. * PM-7322 Create IRegisterUserCommand * PM-7322 - RegisterUserCommand.cs - first WIP draft * PM-7322 - Implement use of new command in Identity. * PM-7322 - Rename RegisterUserViaOrgInvite to just be RegisterUser as orgInvite is optional. * PM07322 - Test RegisterUserCommand.RegisterUser(...) happy paths and one bad request path. * PM-7322 - More WIP on RegisterUserCommand.cs and tests * PM-7322 - RegisterUserCommand.cs - refactor ValidateOrgInviteToken logic to always validate the token if we have one. * PM-7322 - RegisterUserCommand.cs - Refactor OrgInviteToken validation to be more clear + validate org invite token even in open registration scenarios + added tests. * PM-7322 - Add more test coverage to RegisterUserWithOptionalOrgInvite * PM-7322 - IRegisterUserCommand - DOCS * PM-7322 - Test RegisterUser * PM-7322 - IRegisterUserCommand - Add more docs. * PM-7322 - Finish updating all existing user service register calls to use the new command. * PM-7322 - RegistrationEmailVerificationTokenable.cs changes + tests * PM-7322 - RegistrationEmailVerificationTokenable.cs changed to only verify email as it's the only thing we need to verify + updated tests. * PM-7322 - Get RegisterUserViaEmailVerificationToken built and tested * PM-7322 - AccountsController.cs - get bones of PostRegisterFinish in place * PM-7322 - SendVerificationEmailForRegistrationCommand - Feature flag timing attack delays per architecture discussion with a default of keeping them around. * PM-7322 - RegisterFinishRequestModel.cs - EmailVerificationToken must be optional for org invite scenarios. * PM-7322 - HandlebarsMailService.cs - SendRegistrationVerificationEmailAsync - must URL encode email to avoid invalid email upon submission to server on complete registration step * PM-7322 - RegisterUserCommandTests.cs - add API key assertions * PM-7322 - Clean up RegisterUserCommand.cs * PM-7322 - Refactor AccountsController.cs existing org invite method and new process to consider new feature flag for delays. * PM-7322 - Add feature flag svc to AccountsControllerTests.cs + add TODO * PM-7322 - AccountsController.cs - Refactor shared IdentityResult logic into private helper. * PM-7322 - Work on getting PostRegisterFinish tests in place. * PM-7322 - AccountsControllerTests.cs - test new method. * PM-7322 - RegisterFinishRequestModel.cs - Update to use required keyword instead of required annotations as it is easier to catch mistakes. * PM-7322 - Fix misspelling * PM-7322 - Integration tests for RegistrationWithEmailVerification * PM-7322 - Fix leaky integration tests. * PM-7322 - Another leaky test fix. * PM-7322 - AccountsControllerTests.cs - fix RegistrationWithEmailVerification_WithOrgInviteToken_Succeeds * PM-7322 - AccountsControllerTests.cs - Finish out integration test suite!
This commit is contained in:
@ -95,31 +95,6 @@ public class RegistrationEmailVerificationTokenableTests
|
||||
Assert.True(token.Valid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the token validity when the name is null
|
||||
/// </summary>
|
||||
[Theory, AutoData]
|
||||
public void TokenIsValid_NullName_ReturnsTrue(string email)
|
||||
{
|
||||
var token = new RegistrationEmailVerificationTokenable(email, null);
|
||||
|
||||
Assert.True(token.TokenIsValid(email, null));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the token validity when the receiveMarketingEmails input is not provided
|
||||
/// </summary>
|
||||
[Theory, AutoData]
|
||||
public void TokenIsValid_ReceiveMarketingEmailsNotProvided_ReturnsTrue(string email, string name)
|
||||
{
|
||||
var token = new RegistrationEmailVerificationTokenable(email, name);
|
||||
|
||||
Assert.True(token.TokenIsValid(email, name));
|
||||
}
|
||||
|
||||
|
||||
// TokenIsValid_IncorrectEmail_ReturnsFalse
|
||||
|
||||
/// <summary>
|
||||
/// Tests the token validity when an incorrect email is provided
|
||||
/// </summary>
|
||||
@ -128,41 +103,9 @@ public class RegistrationEmailVerificationTokenableTests
|
||||
{
|
||||
var token = new RegistrationEmailVerificationTokenable(email, name, receiveMarketingEmails);
|
||||
|
||||
Assert.False(token.TokenIsValid("wrong@email.com", name, receiveMarketingEmails));
|
||||
Assert.False(token.TokenIsValid("wrong@email.com"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the token validity when an incorrect name is provided
|
||||
/// </summary>
|
||||
[Theory, AutoData]
|
||||
public void TokenIsValid_IncorrectName_ReturnsFalse(string email, string name, bool receiveMarketingEmails)
|
||||
{
|
||||
var token = new RegistrationEmailVerificationTokenable(email, name, receiveMarketingEmails);
|
||||
|
||||
Assert.False(token.TokenIsValid(email, "wrongName", receiveMarketingEmails));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the token validity when an incorrect receiveMarketingEmails is provided
|
||||
/// </summary>
|
||||
[Theory, AutoData]
|
||||
public void TokenIsValid_IncorrectReceiveMarketingEmails_ReturnsFalse(string email, string name, bool receiveMarketingEmails)
|
||||
{
|
||||
var token = new RegistrationEmailVerificationTokenable(email, name, receiveMarketingEmails);
|
||||
|
||||
Assert.False(token.TokenIsValid(email, name, !receiveMarketingEmails));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the token validity when valid inputs are provided
|
||||
/// </summary>
|
||||
[Theory, AutoData]
|
||||
public void TokenIsValid_ValidInputs_ReturnsTrue(string email, string name, bool receiveMarketingEmails)
|
||||
{
|
||||
var token = new RegistrationEmailVerificationTokenable(email, name, receiveMarketingEmails);
|
||||
|
||||
Assert.True(token.TokenIsValid(email, name, receiveMarketingEmails));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the deserialization of a token to ensure that the expiration date is preserved.
|
||||
|
Reference in New Issue
Block a user