Skip to content

Commit

Permalink
Possible fix for #17644
Browse files Browse the repository at this point in the history
  • Loading branch information
vilmosnagy committed Aug 30, 2023
1 parent b0e3013 commit 2e39ead
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ public interface FormContext {
AuthenticationExecutionModel getExecution();

/**
* Current user attached to this flow. It can return null if no uesr has been identified yet
* Current user attached to this flow. It can return null if no user has been identified yet
*
* @return
*/
UserModel getUser();

/**
* Attach a specific user to this flow.
*
* If there was another user attached to this flow calling this method overrides the previous setting.
*
* @param user
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public UserModel getUser() {

@Override
public void setUser(UserModel user) {
processor.clearAuthenticatedUser();
processor.setAutheticatedUser(user);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,8 @@ public void testRegisterShouldFailBeforeUserCreationWhenUserIsInContext() throws
driver.navigate().back();
driver.navigate().back();
driver.navigate().back();

int greenMailMessageCountBeforeRegistrer = greenMail.getReceivedMessages().length;
registerPage.assertCurrent();

registerPage.registerWithEmailAsUsername(
Expand All @@ -1127,11 +1129,14 @@ public void testRegisterShouldFailBeforeUserCreationWhenUserIsInContext() throws
assertFalse("The user is created even when an error page was shown, yet the user has no password", userByUsername.getCredentials().isEmpty());
}
} else {
throw new UnsupportedOperationException("If someone ever refactors the reset password flow, and the previous steps no more cause an error, " +
"then we should check the following: \n" +
" - the newly created user exists\n" +
" - the registration flow is executed until the last step (eg.: the user has a password)\n" +
" - no error page was shown");
verifyEmailPage.assertCurrent();

Assert.assertEquals(1+greenMailMessageCountBeforeRegistrer, greenMail.getReceivedMessages().length);
MimeMessage message = greenMail.getReceivedMessages()[greenMailMessageCountBeforeRegistrer];
String verificationUrl = getPasswordResetEmailLink(message);

driver.navigate().to(verificationUrl.trim());
appPage.assertCurrent();
}
}
}
Expand Down

0 comments on commit 2e39ead

Please sign in to comment.