use of io.gravitee.rest.api.service.common.JWTHelper.DefaultValues.DEFAULT_JWT_EMAIL_REGISTRATION_EXPIRE_AFTER in project gravitee-management-rest-api by gravitee-io.
the class UserServiceTest method shouldResetPassword_auditEventNotMatch.
@Test
public void shouldResetPassword_auditEventNotMatch() throws TechnicalException {
when(environment.getProperty("jwt.secret")).thenReturn(JWT_SECRET);
when(environment.getProperty("user.creation.token.expire-after", Integer.class, DEFAULT_JWT_EMAIL_REGISTRATION_EXPIRE_AFTER)).thenReturn(1000);
when(user.getId()).thenReturn(USER_NAME);
when(user.getSource()).thenReturn("gravitee");
when(userRepository.findById(USER_NAME)).thenReturn(of(user));
MetadataPage mdPage = mock(MetadataPage.class);
AuditEntity entity1 = new AuditEntity();
entity1.setProperties(Collections.singletonMap("USER", "unknown"));
when(mdPage.getContent()).thenReturn(Arrays.asList(entity1));
when(auditService.search(argThat(arg -> arg.getEvents().contains(User.AuditEvent.PASSWORD_RESET.name())))).thenReturn(mdPage);
userService.resetPassword(USER_NAME);
verify(user, never()).setPassword(null);
verify(userRepository, never()).update(user);
verify(emailService).sendAsyncEmailNotification(any(), any());
}
Aggregations