Search in sources :

Example 6 with EditUserRQ

use of com.epam.ta.reportportal.ws.model.user.EditUserRQ in project service-api by reportportal.

the class EditUserHandlerImplTest method editExternalUserFullName.

@Test
void editExternalUserFullName() {
    User user = new User();
    user.setUserType(UserType.GITHUB);
    when(userRepository.findByLogin("test")).thenReturn(Optional.of(user));
    final EditUserRQ editUserRQ = new EditUserRQ();
    editUserRQ.setFullName("full name");
    final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.editUser("test", editUserRQ, getRpUser("not_exist", UserRole.USER, ProjectRole.MEMBER, 1L)));
    assertEquals("You do not have enough permissions. Unable to change full name for external user", exception.getMessage());
}
Also used : EditUserRQ(com.epam.ta.reportportal.ws.model.user.EditUserRQ) User(com.epam.ta.reportportal.entity.user.User) ReportPortalUserUtil.getRpUser(com.epam.ta.reportportal.ReportPortalUserUtil.getRpUser) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Test(org.junit.jupiter.api.Test)

Example 7 with EditUserRQ

use of com.epam.ta.reportportal.ws.model.user.EditUserRQ in project service-api by reportportal.

the class EditUserHandlerImplTest method changeExternalUserEmail.

@Test
void changeExternalUserEmail() {
    User user = new User();
    user.setUserType(UserType.LDAP);
    when(userRepository.findByLogin("test")).thenReturn(Optional.of(user));
    final EditUserRQ editUserRQ = new EditUserRQ();
    editUserRQ.setEmail("newemail@domain.com");
    final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.editUser("test", editUserRQ, getRpUser("not_exist", UserRole.USER, ProjectRole.MEMBER, 1L)));
    assertEquals("You do not have enough permissions. Unable to change email for external user", exception.getMessage());
}
Also used : EditUserRQ(com.epam.ta.reportportal.ws.model.user.EditUserRQ) User(com.epam.ta.reportportal.entity.user.User) ReportPortalUserUtil.getRpUser(com.epam.ta.reportportal.ReportPortalUserUtil.getRpUser) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Test(org.junit.jupiter.api.Test)

Aggregations

ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)7 EditUserRQ (com.epam.ta.reportportal.ws.model.user.EditUserRQ)7 User (com.epam.ta.reportportal.entity.user.User)6 Test (org.junit.jupiter.api.Test)6 ReportPortalUserUtil.getRpUser (com.epam.ta.reportportal.ReportPortalUserUtil.getRpUser)5 UserBinaryDataService (com.epam.ta.reportportal.binary.UserBinaryDataService)1 Predicates (com.epam.ta.reportportal.commons.Predicates)1 Predicates.equalTo (com.epam.ta.reportportal.commons.Predicates.equalTo)1 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 BusinessRule (com.epam.ta.reportportal.commons.validation.BusinessRule)1 BusinessRule.expect (com.epam.ta.reportportal.commons.validation.BusinessRule.expect)1 BusinessRule.fail (com.epam.ta.reportportal.commons.validation.BusinessRule.fail)1 EditUserHandler (com.epam.ta.reportportal.core.user.EditUserHandler)1 ProjectRepository (com.epam.ta.reportportal.dao.ProjectRepository)1 UserRepository (com.epam.ta.reportportal.dao.UserRepository)1 ImageFormat (com.epam.ta.reportportal.entity.enums.ImageFormat)1 Project (com.epam.ta.reportportal.entity.project.Project)1 ProjectUtils (com.epam.ta.reportportal.entity.project.ProjectUtils)1 UserRole (com.epam.ta.reportportal.entity.user.UserRole)1 INTERNAL (com.epam.ta.reportportal.entity.user.UserType.INTERNAL)1