Exemplo n.º 1
0
 @Test
 public void testGenerateRecoveryToken() {
   final User user = userManager.getUserByUsername("token-test");
   final String token = passwordTokenManager.generateRecoveryToken(user);
   assertNotNull(token);
   assertTrue(passwordTokenManager.isRecoveryTokenValid(user, token));
 }
Exemplo n.º 2
0
  @Test
  public void testConsumeRecoveryToken() throws Exception {
    final User user = userManager.getUserByUsername("token-test");
    final Integer version = user.getVersion();

    final String token = passwordTokenManager.generateRecoveryToken(user);
    assertNotNull(token);
    assertTrue(passwordTokenManager.isRecoveryTokenValid(user, token));

    // start SMTP Server
    Wiser wiser = startWiser(smtpPort);

    User updated = userManager.updatePassword(user.getUsername(), null, token, "user", "");

    wiser.stop();
    assertTrue(wiser.getMessages().size() == 1);

    assertTrue(updated.getVersion() > version);
    assertFalse(passwordTokenManager.isRecoveryTokenValid(updated, token));
  }
Exemplo n.º 3
0
 @Override
 public String generateRecoveryToken(final User user) {
   return passwordTokenManager.generateRecoveryToken(user);
 }