Search in sources :

Example 1 with ChangePasswordRQ

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());
}
Also used : User(com.epam.ta.reportportal.entity.user.User) ReportPortalUserUtil.getRpUser(com.epam.ta.reportportal.ReportPortalUserUtil.getRpUser) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ChangePasswordRQ(com.epam.ta.reportportal.ws.model.user.ChangePasswordRQ) Test(org.junit.jupiter.api.Test)

Example 2 with ChangePasswordRQ

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());
}
Also used : User(com.epam.ta.reportportal.entity.user.User) ReportPortalUserUtil.getRpUser(com.epam.ta.reportportal.ReportPortalUserUtil.getRpUser) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ChangePasswordRQ(com.epam.ta.reportportal.ws.model.user.ChangePasswordRQ) Test(org.junit.jupiter.api.Test)

Example 3 with ChangePasswordRQ

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());
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ChangePasswordRQ(com.epam.ta.reportportal.ws.model.user.ChangePasswordRQ) Test(org.junit.jupiter.api.Test)

Aggregations

ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)3 ChangePasswordRQ (com.epam.ta.reportportal.ws.model.user.ChangePasswordRQ)3 Test (org.junit.jupiter.api.Test)3 ReportPortalUserUtil.getRpUser (com.epam.ta.reportportal.ReportPortalUserUtil.getRpUser)2 User (com.epam.ta.reportportal.entity.user.User)2