use of com.epam.ta.reportportal.ws.model.user.ChangePasswordRQ in project service-api by reportportal.
the class EditUserHandlerImplTest method changePasswordWithIncorrectOldPassword.
@Test
void changePasswordWithIncorrectOldPassword() {
User user = new User();
user.setLogin("test");
user.setUserType(UserType.INTERNAL);
user.setPassword("CBBA6D57536106F93CDEB6E426C2750E");
when(userRepository.findByLogin("test")).thenReturn(Optional.of(user));
final ChangePasswordRQ changePasswordRQ = new ChangePasswordRQ();
changePasswordRQ.setOldPassword("wrongPass");
final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.changePassword(getRpUser("test", UserRole.USER, ProjectRole.MEMBER, 1L), changePasswordRQ));
assertEquals("Forbidden operation. Old password not match with stored.", exception.getMessage());
}
use of com.epam.ta.reportportal.ws.model.user.ChangePasswordRQ in project service-api by reportportal.
the class EditUserHandlerImplTest method changeExternalUserPassword.
@Test
void changeExternalUserPassword() {
User user = new User();
user.setLogin("test");
user.setUserType(UserType.UPSA);
when(userRepository.findByLogin("test")).thenReturn(Optional.of(user));
final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.changePassword(getRpUser("test", UserRole.USER, ProjectRole.MEMBER, 1L), new ChangePasswordRQ()));
assertEquals("Forbidden operation. Impossible to change password for external users.", exception.getMessage());
}
use of com.epam.ta.reportportal.ws.model.user.ChangePasswordRQ in project service-api by reportportal.
the class EditUserHandlerImplTest method changeNotExistUserPassword.
@Test
void changeNotExistUserPassword() {
when(userRepository.findByLogin("not_exist")).thenReturn(Optional.empty());
final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.changePassword(getRpUser("not_exist", UserRole.USER, ProjectRole.MEMBER, 1L), new ChangePasswordRQ()));
assertEquals("User 'not_exist' not found.", exception.getMessage());
}
Aggregations